コード例 #1
0
ファイル: MarkdownRenderer.cs プロジェクト: yodamaster/docfx
        public virtual StringBuffer Render(IMarkdownRenderer render, MarkdownListBlockToken token, MarkdownBlockContext context)
        {
            const string ListStartString = "* ";
            var content = StringBuffer.Empty;

            if (token.Ordered)
            {
                foreach (var t in token.Tokens)
                {
                    var listItemToken = t as MarkdownListItemBlockToken;
                    if (listItemToken == null)
                    {
                        throw new Exception($"token {t.GetType()} is not MarkdownListItemBlockToken in MarkdownListBlockToken. Token raw:{t.RawMarkdown}");
                    }
                    content += ListStartString;
                    content += render.Render(t);
                }
            }
            else
            {
                for (int i = 1; i < token.Tokens.Length; ++i)
                {
                    var listItemToken = token.Tokens[i] as MarkdownListItemBlockToken;

                    if (listItemToken == null)
                    {
                        throw new Exception($"token {token.Tokens[i].GetType()} is not MarkdownListItemBlockToken in MarkdownListBlockToken. Token raw:{token.Tokens[i].RawMarkdown}");
                    }

                    content += i.ToString();
                    content += ". ";
                }
            }
            return content;
        }
コード例 #2
0
        public virtual StringBuffer Render(IMarkdownRenderer render, MarkdownListBlockToken token, MarkdownBlockContext context)
        {
            const string ListStartString = "* ";
            var          content         = StringBuffer.Empty;

            if (token.Ordered)
            {
                foreach (var t in token.Tokens)
                {
                    var listItemToken = t as MarkdownListItemBlockToken;
                    if (listItemToken == null)
                    {
                        throw new Exception($"token {t.GetType()} is not MarkdownListItemBlockToken in MarkdownListBlockToken. Token raw:{t.RawMarkdown}");
                    }
                    content += ListStartString;
                    content += render.Render(t);
                }
            }
            else
            {
                for (int i = 1; i < token.Tokens.Length; ++i)
                {
                    var listItemToken = token.Tokens[i] as MarkdownListItemBlockToken;

                    if (listItemToken == null)
                    {
                        throw new Exception($"token {token.Tokens[i].GetType()} is not MarkdownListItemBlockToken in MarkdownListBlockToken. Token raw:{token.Tokens[i].RawMarkdown}");
                    }

                    content += i.ToString();
                    content += ". ";
                }
            }
            return(content);
        }
コード例 #3
0
        public virtual StringBuffer Render(IMarkdownRenderer render, MarkdownListBlockToken token, MarkdownBlockContext context)
        {
            var content = StringBuffer.Empty;

            if (!token.Ordered)
            {
                const string ListStartString = "* ";
                foreach (var t in token.Tokens)
                {
                    if (!(t is MarkdownListItemBlockToken listItemToken))
                    {
                        throw new Exception($"token {t.GetType()} is not unordered MarkdownListItemBlockToken in MarkdownListBlockToken. Token raw:{t.SourceInfo.Markdown}");
                    }
                    content += ListStartString;
                    content += Render(render, listItemToken, "  ");
                }
            }
            else
            {
                for (int i = 0; i < token.Tokens.Length; ++i)
                {
                    if (!(token.Tokens[i] is MarkdownListItemBlockToken listItemToken))
                    {
                        throw new Exception($"token {token.Tokens[i].GetType()} is not ordered MarkdownListItemBlockToken in MarkdownListBlockToken. Token raw:{token.Tokens[i].SourceInfo.Markdown}");
                    }

                    content += $"{i + 1}. ";
                    string indent = new string(' ', (i + 1).ToString().Length + 2);
                    content += Render(render, listItemToken, indent);
                }
            }
            return(content + "\n");
        }
コード例 #4
0
        public virtual StringBuffer Render(IMarkdownRenderer renderer, MarkdownListBlockToken token, MarkdownBlockContext context)
        {
            var type         = token.Ordered ? "ol" : "ul";
            var childContent = StringBuffer.Empty;

            foreach (var item in token.Tokens)
            {
                childContent += Render(renderer, (MarkdownListItemBlockToken)item);
            }
            return(Insert(token, type, childContent));
        }
コード例 #5
0
ファイル: HtmlRenderer.cs プロジェクト: yodamaster/docfx
 public virtual StringBuffer Render(IMarkdownRenderer engine, MarkdownListBlockToken token, MarkdownBlockContext context)
 {
     var type = token.Ordered ? "ol" : "ul";
     StringBuffer content = "<";
     content += type;
     content += ">\n";
     foreach (var t in token.Tokens)
     {
         content += engine.Render(t);
     }
     return content + "</" + type + ">\n";
 }
コード例 #6
0
ファイル: HtmlRenderer.cs プロジェクト: stuartleeks/docfx
        public virtual StringBuffer Render(IMarkdownRenderer renderer, MarkdownListBlockToken token, MarkdownBlockContext context)
        {
            var          type    = token.Ordered ? "ol" : "ul";
            StringBuffer content = "<";

            content += type;
            content += ">\n";
            foreach (var t in token.Tokens)
            {
                content += Render(renderer, (MarkdownListItemBlockToken)t);
            }
            return(content + "</" + type + ">\n");
        }
コード例 #7
0
        public virtual StringBuffer Render(MarkdownEngine engine, MarkdownListBlockToken token, MarkdownBlockContext context)
        {
            var          type    = token.Ordered ? "ol" : "ul";
            StringBuffer content = "<";

            content += type;
            content += ">\n";
            foreach (var t in token.Tokens)
            {
                content += engine.Render(t, context);
            }
            return(content + "</" + type + ">\n");
        }
コード例 #8
0
ファイル: HtmlRenderer.cs プロジェクト: zsvanderlaan/docfx
        public virtual StringBuffer Render(IMarkdownRenderer renderer, MarkdownListBlockToken token, MarkdownBlockContext context)
        {
            var          type   = token.Ordered ? "ol" : "ul";
            StringBuffer result = "<";

            result += type;
            result  = AppendSourceInfo(result, renderer, token);
            result += ">\n";
            foreach (var t in token.Tokens)
            {
                result += Render(renderer, (MarkdownListItemBlockToken)t);
            }
            return(result + "</" + type + ">\n");
        }
コード例 #9
0
ファイル: MarkdownRenderer.cs プロジェクト: dotnet/docfx
        public virtual StringBuffer Render(IMarkdownRenderer render, MarkdownListBlockToken token, MarkdownBlockContext context)
        {
            var content = StringBuffer.Empty;

            if (!token.Ordered)
            {
                const string ListStartString = "* ";
                foreach (var t in token.Tokens)
                {
                    var listItemToken = t as MarkdownListItemBlockToken;
                    if (listItemToken == null)
                    {
                        throw new Exception($"token {t.GetType()} is not unordered MarkdownListItemBlockToken in MarkdownListBlockToken. Token raw:{t.SourceInfo.Markdown}");
                    }
                    content += ListStartString;
                    content += Render(render, listItemToken, "  ");
                }
            }
            else
            {
                for (int i = 0; i < token.Tokens.Length; ++i)
                {
                    var listItemToken = token.Tokens[i] as MarkdownListItemBlockToken;

                    if (listItemToken == null)
                    {
                        throw new Exception($"token {token.Tokens[i].GetType()} is not ordered MarkdownListItemBlockToken in MarkdownListBlockToken. Token raw:{token.Tokens[i].SourceInfo.Markdown}");
                    }

                    content += $"{i + 1}. ";
                    string indent = new string(' ', (i + 1).ToString().Length + 2);
                    content += Render(render, listItemToken, indent);
                }
            }
            return content + "\n";
        }