コード例 #1
0
        /// <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 + "]");
        }
コード例 #2
0
        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);
        }
コード例 #3
0
        string GetContent()
        {
            var content = string.Concat(SubNodes.Select(s => s.ToHtml()).ToArray());

            return(Tag.ContentTransformer == null
                ? content
                : Tag.ContentTransformer(content));
        }
コード例 #4
0
        public override string ToText()
        {
            var result =
                string.Concat(
                    SubNodes
                    .Select(s => s.ToText())
                    .ToArray());

            return(result);
        }
コード例 #5
0
        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]))
コード例 #6
0
ファイル: TagNode.cs プロジェクト: kyoronz/Anime-Forum
 public override string ToText()
 {
     return(string.Concat(SubNodes.Select(s => s.ToText()).ToArray()));
 }
コード例 #7
0
ファイル: SequenceNode.cs プロジェクト: crazyants/forum
 public override string ToBBCode() => string.Concat(SubNodes.Select(s => s.ToBBCode()).ToArray());