/// <summary> /// Convert BbCode to HTML /// </summary> /// <param name="token">Parsed token</param> /// <param name="content">Code content</param> /// <returns>Formatted code</returns> public override string Format(BbCodeToken token, string content) { // Map parameter values to indices var values = new object[Parameters.Length]; for (int i = 0; i < Parameters.Length; i++) { string value; token.Parameters.TryGetValue(Parameters[i], out value); values[i] = value; } return(string.Format(Template, values)); }
/// <summary> /// Parse a bb code and retun HTML markup /// </summary> /// <param name="bbCodeToken"></param> /// <param name="content"></param> /// <returns></returns> protected string ParseBbCode(BbCodeToken bbCodeToken, string content) { if (Configuration.EnableBbCodes && Configuration.BbCodes.ContainsKey(bbCodeToken.Identifier)) { // TODO: Parse all parameters if (!string.IsNullOrEmpty(bbCodeToken.UnnamedParameter)) { var parser = new Parser(Configuration); bbCodeToken.UnnamedParameter = parser.Parse(bbCodeToken.UnnamedParameter); } return(Configuration.BbCodes[bbCodeToken.Identifier].Format(bbCodeToken, content)); } return(string.Format("{0}{1}[/{2}]", bbCodeToken.Contents, content, bbCodeToken.Identifier)); }
/// <summary> /// Convert BbCode to HTML /// </summary> /// <param name="token">Parsed token</param> /// <param name="content">Code content</param> /// <returns>Formatted code</returns> public override string Format(BbCodeToken token, string content) { return(token.UnnamedParameter == null?String.Format(Template, content) : String.Format(TemplateParameterized ?? Template, content, token.UnnamedParameter)); }
/// <summary> /// Convert BbCode to HTML /// </summary> /// <param name="token">Parsed token</param> /// <param name="content">Code content</param> /// <returns>Formatted code</returns> public abstract string Format(BbCodeToken token, string content);