/// <summary> /// Get the node content as a formatted BBCode string. /// </summary> public override string ToBBCode() { string content = string.Concat(SubNodes.Select(s => s.ToBBCode()).ToArray()); string attrs = ""; BBAttribute defAttr = Tag.FindAttribute(""); if (defAttr != null) { if (AttributeValues.ContainsKey(defAttr)) { attrs += "=" + AttributeValues[defAttr]; } } foreach (var attrKvp in AttributeValues) { if (attrKvp.Key.Name == "") { continue; } attrs += " " + attrKvp.Key.Name + "=" + attrKvp.Value; } return("[" + Tag.Name + attrs + "]" + content + "[/" + Tag.Name + "]"); }
public override string ToBbCode() { var content = string.Concat(SubNodes.Select(s => s.ToBbCode()).ToArray()); var defAttr = Tag.FindAttribute(string.Empty); var attrStringBuilder = new StringBuilder(); if (defAttr != null) { if (AttributeValues.ContainsKey(defAttr)) { var attrString = $"={AttributeValues[defAttr]}"; attrStringBuilder.Append(attrString); } } foreach (var attrKvp in AttributeValues) { if (string.IsNullOrEmpty(attrKvp.Key.Name)) { continue; } var attrString = $" {attrKvp.Key.Name}={attrKvp.Value}"; attrStringBuilder.Append(attrString); } var attrs = attrStringBuilder.ToString(); var result = $"[{Tag.Name}{attrs}]{content}[/{Tag.Name}]"; return(result); }
string GetContent() { var content = string.Concat(SubNodes.Select(s => s.ToHtml()).ToArray()); return(Tag.ContentTransformer == null ? content : Tag.ContentTransformer(content)); }
public override string ToText() { var result = string.Concat( SubNodes .Select(s => s.ToText()) .ToArray()); return(result); }
public override string ToLegacyBBCode() { var content = string.Concat(SubNodes.Select(s => s.ToLegacyBBCode()).ToArray()); var attrs = ""; var defAttr = Tag.FindAttribute(""); var attachFlag = ""; if (defAttr != null && AttributeValues.ContainsKey(defAttr)) { attrs += "=" + AttributeValues[defAttr]; } foreach (var attrKvp in AttributeValues) { if (Tag.Name.Equals("attachment", StringComparison.OrdinalIgnoreCase) && string.IsNullOrWhiteSpace(attachFlag) && attrKvp.Key.ID.Equals("num", StringComparison.OrdinalIgnoreCase) && int.TryParse(attrKvp.Value, out var id)) { attachFlag = $"<!-- ia{id} -->"; } if (attrKvp.Key.Name == "") { continue; } attrs += " " + attrKvp.Key.Name + "=" + attrKvp.Value; } var toReturn = new StringBuilder("[").Append(Tag.Name).Append(HttpUtility.HtmlEncode(attrs)); if (!string.IsNullOrWhiteSpace(Tag.BBCodeUid)) { toReturn.Append(':').Append(Tag.BBCodeUid); } string nonEmptyContent = content, trailingWhitespace = ""; if (Tag.EnableIterationElementBehavior && !string.IsNullOrWhiteSpace(content) && char.IsWhiteSpace(content[^ 1]))
public override string ToText() { return(string.Concat(SubNodes.Select(s => s.ToText()).ToArray())); }
public override string ToBBCode() => string.Concat(SubNodes.Select(s => s.ToBBCode()).ToArray());