public BBTag(string name, string openTagTemplate, string closeTagTemplate, bool autoRenderContent, BBTagClosingStyle tagClosingClosingStyle, Func <string, string> contentTransformer, bool enableIterationElementBehavior, params BBAttribute[] attributes) { if (name == null) { throw new ArgumentNullException("name"); } if (openTagTemplate == null) { throw new ArgumentNullException("openTagTemplate"); } if (closeTagTemplate == null) { throw new ArgumentNullException("closeTagTemplate"); } if (!Enum.IsDefined(typeof(BBTagClosingStyle), tagClosingClosingStyle)) { throw new ArgumentException("tagClosingClosingStyle"); } Name = name; OpenTagTemplate = openTagTemplate; CloseTagTemplate = closeTagTemplate; AutoRenderContent = autoRenderContent; TagClosingStyle = tagClosingClosingStyle; ContentTransformer = contentTransformer; EnableIterationElementBehavior = enableIterationElementBehavior; Attributes = attributes ?? new BBAttribute[0]; }
public void NoCrash(ErrorMode errorMode, [PexAssumeNotNull] string input, BBTagClosingStyle listItemBbTagClosingStyle, out string output) { PexAssume.EnumIsDefined(errorMode); PexAssume.EnumIsDefined(listItemBbTagClosingStyle); try { output = BBEncodeForTest(input, errorMode, listItemBbTagClosingStyle, false); Assert.IsNotNull(output); } catch (BBCodeParsingException) { Assert.AreNotEqual(ErrorMode.ErrorFree, errorMode); output = null; } }
public BBTag(string name, string openTagTemplate, string closeTagTemplate, bool autoRenderContent, BBTagClosingStyle tagClosingClosingStyle, Func<string, string> contentTransformer, bool enableIterationElementBehavior, params BBAttribute[] attributes) { if (name == null) throw new ArgumentNullException("name"); if (openTagTemplate == null) throw new ArgumentNullException("openTagTemplate"); if (closeTagTemplate == null) throw new ArgumentNullException("closeTagTemplate"); if (!Enum.IsDefined(typeof(BBTagClosingStyle), tagClosingClosingStyle)) throw new ArgumentException("tagClosingClosingStyle"); Name = name; OpenTagTemplate = openTagTemplate; CloseTagTemplate = closeTagTemplate; AutoRenderContent = autoRenderContent; TagClosingStyle = tagClosingClosingStyle; ContentTransformer = contentTransformer; EnableIterationElementBehavior = enableIterationElementBehavior; Attributes = attributes ?? new BBAttribute[0]; }
public BBTag(string name, BBTagClosingStyle tagClosingClosingStyle, bool enableIterationElementBehavior, params BBAttribute[] attributes) { if (name == null) { throw new ArgumentNullException("name"); } if (!Enum.IsDefined(typeof(BBTagClosingStyle), tagClosingClosingStyle)) { throw new ArgumentException("tagClosingClosingStyle"); } Name = name; TagClosingStyle = tagClosingClosingStyle; EnableIterationElementBehavior = enableIterationElementBehavior; Attributes = attributes ?? new BBAttribute[0]; }
public static BBCodeParser GetParserForTest(ErrorMode errorMode, bool includePlaceholder, BBTagClosingStyle listItemBBTagClosingStyle, bool enableIterationElementBehavior) { return new BBCodeParser(errorMode, null, new[] { new BBTag("b", "<b>", "</b>"), new BBTag("i", "<span style=\"font-style:italic;\">", "</span>"), new BBTag("u", "<span style=\"text-decoration:underline;\">", "</span>"), new BBTag("code", "<pre class=\"prettyprint\">", "</pre>"), new BBTag("img", "<img src=\"${content}\" />", "", false, true), new BBTag("quote", "<blockquote>", "</blockquote>"), new BBTag("list", "<ul>", "</ul>"), new BBTag("*", "<li>", "</li>", true, listItemBBTagClosingStyle, null, enableIterationElementBehavior), new BBTag("url", "<a href=\"${href}\">", "</a>", new BBAttribute("href", ""), new BBAttribute("href", "href")), new BBTag("url2", "<a href=\"${href}\">", "</a>", new BBAttribute("href", "", GetUrl2Href), new BBAttribute("href", "href", GetUrl2Href)), !includePlaceholder ? null : new BBTag("placeholder", "${name}", "", false, BBTagClosingStyle.LeafElementWithoutContent, null, new BBAttribute("name", "", name => "xxx" + name.AttributeValue + "yyy")), }.Where(x => x != null).ToArray()); }
public BBTag(string name, string openTagTemplate, string closeTagTemplate, bool autoRenderContent, BBTagClosingStyle tagClosingClosingStyle, Func <string, string> contentTransformer, bool enableIterationElementBehavior, int id, string bbcodeUid = "", bool allowUrlProcessingAsText = true, params BBAttribute[] attributes) { if (!Enum.IsDefined(typeof(BBTagClosingStyle), tagClosingClosingStyle)) { throw new ArgumentException(null, nameof(tagClosingClosingStyle)); } Name = name ?? throw new ArgumentNullException(nameof(name)); OpenTagTemplate = openTagTemplate ?? throw new ArgumentNullException(nameof(openTagTemplate)); CloseTagTemplate = closeTagTemplate ?? throw new ArgumentNullException(nameof(closeTagTemplate)); AutoRenderContent = autoRenderContent; TagClosingStyle = tagClosingClosingStyle; ContentTransformer = contentTransformer; EnableIterationElementBehavior = enableIterationElementBehavior; Attributes = attributes ?? Array.Empty <BBAttribute>(); Id = id; BBCodeUid = bbcodeUid; AllowUrlProcessingAsText = allowUrlProcessingAsText; }
public static BBCodeParser GetParserForTest(ErrorMode errorMode, bool includePlaceholder, BBTagClosingStyle listItemBBTagClosingStyle, bool enableIterationElementBehavior) { return(new BBCodeParser(errorMode, null, new[] { new BBTag("b", "<b>", "</b>"), new BBTag("i", "<span style=\"font-style:italic;\">", "</span>"), new BBTag("u", "<span style=\"text-decoration:underline;\">", "</span>"), new BBTag("code", "<pre class=\"prettyprint\">", "</pre>"), new BBTag("img", "<img src=\"${content}\" />", "", false, true), new BBTag("quote", "<blockquote>", "</blockquote>"), new BBTag("list", "<ul>", "</ul>"), new BBTag("*", "<li>", "</li>", true, listItemBBTagClosingStyle, null, enableIterationElementBehavior), new BBTag("url", "<a href=\"${href}\">", "</a>", new BBAttribute("href", ""), new BBAttribute("href", "href")), new BBTag("url2", "<a href=\"${href}\">", "</a>", new BBAttribute("href", "", GetUrl2Href), new BBAttribute("href", "href", GetUrl2Href)), !includePlaceholder ? null : new BBTag("placeholder", "${name}", "", false, BBTagClosingStyle.LeafElementWithoutContent, null, new BBAttribute("name", "", name => "xxx" + name.AttributeValue + "yyy")), }.Where(x => x != null).ToArray())); }
public static string BBEncodeForTest(string bbCode, ErrorMode errorMode, BBTagClosingStyle listItemBbTagClosingStyle, bool enableIterationElementBehavior) { return(BBCodeTestUtil.GetParserForTest(errorMode, true, listItemBbTagClosingStyle, enableIterationElementBehavior).ToHtml(bbCode).Replace("\r", "").Replace("\n", "<br/>")); }
public BBTag(string name, string openTagTemplate, string closeTagTemplate, bool autoRenderContent, BBTagClosingStyle tagClosingClosingStyle, Func<string, string> contentTransformer, params BBAttribute[] attributes) : this(name, openTagTemplate, closeTagTemplate, autoRenderContent, tagClosingClosingStyle, contentTransformer, false, attributes) { }
public BBTag(string name, string openTagTemplate, string closeTagTemplate, bool autoRenderContent, BBTagClosingStyle tagClosingClosingStyle, Func <string, string> contentTransformer, params BBAttribute[] attributes) : this(name, openTagTemplate, closeTagTemplate, autoRenderContent, tagClosingClosingStyle, contentTransformer, false, attributes) { }
public BBTag(string name, BBTagClosingStyle tagClosingClosingStyle, params BBAttribute[] attributes) : this(name, tagClosingClosingStyle, false, attributes) { }
public BBTag(string name, string openTagTemplate, string closeTagTemplate, bool autoRenderContent, BBTagClosingStyle tagClosingClosingStyle, Func <string, string> contentTransformer, int id, string bbcodeUid = "", bool allowUrlProcessingAsText = true, params BBAttribute[] attributes) : this(name, openTagTemplate, closeTagTemplate, autoRenderContent, tagClosingClosingStyle, contentTransformer, false, id, bbcodeUid, allowUrlProcessingAsText, attributes) { }
public static string BBEncodeForTest(string bbCode, ErrorMode errorMode, BBTagClosingStyle listItemBbTagClosingStyle, bool enableIterationElementBehavior) { return BBCodeTestUtil.GetParserForTest(errorMode, true, listItemBbTagClosingStyle, enableIterationElementBehavior).ToHtml(bbCode).Replace("\r", "").Replace("\n", "<br/>"); }