当前位置: 首页>>代码示例>>C#>>正文


C# IMarkdownRenderer.Render方法代码示例

本文整理汇总了C#中IMarkdownRenderer.Render方法的典型用法代码示例。如果您正苦于以下问题:C# IMarkdownRenderer.Render方法的具体用法?C# IMarkdownRenderer.Render怎么用?C# IMarkdownRenderer.Render使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IMarkdownRenderer的用法示例。


在下文中一共展示了IMarkdownRenderer.Render方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Render

        public virtual StringBuffer Render(IMarkdownRenderer render, MarkdownBlockquoteBlockToken token, MarkdownBlockContext context)
        {
            const string BlockQuoteStartString = "> ";
            const string BlockQuoteJoinString = "\n" + BlockQuoteStartString;

            var content = StringBuffer.Empty;
            foreach (var t in token.Tokens)
            {
                content += render.Render(t);
            }
            var contents = content.ToString().Split('\n');
            content = StringBuffer.Empty;
            foreach (var item in contents)
            {
                if (content == StringBuffer.Empty)
                {
                    content += BlockQuoteStartString;
                    content += item;
                }
                else
                {
                    content += BlockQuoteJoinString;
                    content += item;
                }
            }
            return content;
        }
开发者ID:yodamaster,项目名称:docfx,代码行数:27,代码来源:MarkdownRenderer.cs

示例2: RenderAzureIncludeToken

 private StringBuffer RenderAzureIncludeToken(IMarkdownRenderer render, AzureIncludeBasicToken token, IMarkdownContext context)
 {
     StringBuffer content = StringBuffer.Empty;
     foreach(var t in token.Tokens)
     {
         content += render.Render(t);
     }
     return content;
 }
开发者ID:vicancy,项目名称:docfx,代码行数:9,代码来源:AzureMarkdownRenderer.cs

示例3: Render

 public virtual StringBuffer Render(IMarkdownRenderer renderer, MarkdownBlockquoteBlockToken token, MarkdownBlockContext context)
 {
     StringBuffer content = "<blockquote>\n";
     foreach (var item in token.Tokens)
     {
         content += renderer.Render(item);
     }
     return content + "</blockquote>\n";
 }
开发者ID:yodamaster,项目名称:docfx,代码行数:9,代码来源:HtmlRenderer.cs

示例4: Render

 public virtual StringBuffer Render(IMarkdownRenderer renderer, MarkdownHtmlBlockToken token, MarkdownBlockContext context)
 {
     var childContent = StringBuffer.Empty;
     foreach (var item in token.Content.Tokens)
     {
         childContent += renderer.Render(item);
     }
     return Insert(token, ExposeTokenName(token), childContent);
 }
开发者ID:dotnet,项目名称:docfx,代码行数:9,代码来源:JsonTokenTreeRenderer.cs

示例5: Render

 public virtual StringBuffer Render(IMarkdownRenderer renderer, DfmXrefInlineToken token, MarkdownInlineContext context)
 {
     var childContent = StringBuffer.Empty;
     foreach (var item in token.Content)
     {
         childContent += renderer.Render(item);
     }
     return Insert(token, $"{ExposeTokenNameInDfm(token)}>{Escape(token.Href)}", childContent);
 }
开发者ID:dotnet,项目名称:docfx,代码行数:9,代码来源:DfmJsonTokenTreeRender.cs

示例6: Render

 public virtual StringBuffer Render(IMarkdownRenderer render, MarkdownHtmlBlockToken token, MarkdownBlockContext context)
 {
     StringBuffer content = StringBuffer.Empty;
     foreach(var t in token.Content.Tokens)
     {
         content += render.Render(t);
     }
     return content;
 }
开发者ID:ansyral,项目名称:docfx,代码行数:9,代码来源:MarkdownRenderer.cs

示例7: Render

        public virtual StringBuffer Render(IMarkdownRenderer renderer, DfmXrefInlineToken token, MarkdownInlineContext context)
        {
            StringBuffer result = "<xref";
            result = AppendAttribute(result, "href", token.Href);
            result = AppendAttribute(result, "title", token.Title);
            result = AppendAttribute(result, "data-throw-if-not-resolved", token.ThrowIfNotResolved.ToString());
            result = AppendAttribute(result, "data-raw-source", token.SourceInfo.Markdown);
            result = AppendSourceInfo(result, renderer, token);
            result += ">";

            foreach (var item in token.Content)
            {
                result += renderer.Render(item);
            }

            result += "</xref>";
            return result;
        }
开发者ID:dotnet,项目名称:docfx,代码行数:18,代码来源:DfmRenderer.cs

示例8: RenderLinkNormalLink

 private StringBuffer RenderLinkNormalLink(IMarkdownRenderer render, MarkdownLinkInlineToken token, MarkdownInlineContext context)
 {
     StringBuffer content = StringBuffer.Empty;
     content += "[";
     foreach (var t in token.Content)
     {
         content += render.Render(t);
     }
     content += "](";
     content += Regexes.Helper.MarkdownUnescape.Replace(token.Href, m => "\\" + m.Value);
     if (!string.IsNullOrEmpty(token.Title))
     {
         content += " \"";
         content += Regexes.Helper.MarkdownUnescape.Replace(token.Title, m => "\\" + m.Value);
         content += "\"";
     }
     content += ")";
     return content;
 }
开发者ID:dotnet,项目名称:docfx,代码行数:19,代码来源:MarkdownRenderer.cs

示例9: Render

 public override StringBuffer Render(IMarkdownRenderer renderer, MarkdownBlockquoteBlockToken token, MarkdownBlockContext context)
 {
     StringBuffer content = string.Empty;
     var splitTokens = DfmRendererHelper.SplitBlockquoteTokens(token.Tokens);
     foreach (var splitToken in splitTokens)
     {
         if (splitToken.Token is DfmSectionBlockToken)
         {
             content += "<div";
             content += ((DfmSectionBlockToken)splitToken.Token).Attributes;
             content += ">";
             foreach (var item in splitToken.InnerTokens)
             {
                 content += renderer.Render(item);
             }
             content += "</div>\n";
         }
         else if (splitToken.Token is DfmNoteBlockToken)
         {
             var noteToken = (DfmNoteBlockToken)splitToken.Token;
             content += "<div class=\"";
             content += noteToken.NoteType;
             content += "\"><h5>";
             content += noteToken.NoteType;
             content += "</h5>";
             foreach (var item in splitToken.InnerTokens)
             {
                 content += renderer.Render(item);
             }
             content += "</div>\n";
         }
         else
         {
             content += "<blockquote>";
             foreach (var item in splitToken.InnerTokens)
             {
                 content += renderer.Render(item);
             }
             content += "</blockquote>\n";
         }
     }
     return content;
 }
开发者ID:xier2012,项目名称:docfx,代码行数:43,代码来源:DfmRenderer.cs

示例10: Render

        public virtual StringBuffer Render(IMarkdownRenderer render, MarkdownTableBlockToken token, MarkdownBlockContext context)
        {
            var content = StringBuffer.Empty;

            // Generate header line
            content += "|";
            foreach (var header in token.Header)
            {
                content += " ";
                foreach (var t in header.Content.Tokens)
                {
                    content += render.Render(t);
                }
                content += " |";
            }
            content += "\n";

            // Generate align line
            content += "|";
            foreach (var align in token.Align)
            {
                switch (align)
                {
                    case Align.NotSpec:
                        content += " --- ";
                        break;
                    case Align.Left:
                        content += ":--- ";
                        break;
                    case Align.Right:
                        content += " ---:";
                        break;
                    case Align.Center:
                        content += ":---:";
                        break;
                    default:
                        throw new NotSupportedException($"align:{align} doesn't support in GFM table");
                }
                content += "|";
            }
            content += "\n";

            // Generate content lines
            foreach (var row in token.Cells)
            {
                content += "| ";
                foreach (var column in row)
                {
                    foreach (var t in column.Content.Tokens)
                    {
                        content += render.Render(t);
                    }
                    content += " |";
                }
                content += "\n";
            }

            return content += "\n";
        }
开发者ID:dotnet,项目名称:docfx,代码行数:59,代码来源:MarkdownRenderer.cs

示例11: RenderNumberLink

        private StringBuffer RenderNumberLink(IMarkdownRenderer render, IMarkdownToken token, MarkdownInlineContext context)
        {
            StringBuffer content = StringBuffer.Empty;
            if(token is MarkdownImageInlineToken)
            {
                var realToken = token as MarkdownImageInlineToken;
                content += "![";
                content += realToken.Text;
                content += "]";
            }
            else if(token is MarkdownLinkInlineToken)
            {
                var realToken = token as MarkdownLinkInlineToken;
                content += "[";
                foreach (var t in realToken.Content)
                {
                    content += render.Render(t);
                }
                content += "]";
            }
            else
            {
                throw new NotSupportedException("Number link token should be either link token or image token");
            }

            return content;
        }
开发者ID:dotnet,项目名称:docfx,代码行数:27,代码来源:MarkdownRenderer.cs

示例12: RenderTokens

 protected StringBuffer RenderTokens(IMarkdownRenderer engine, ImmutableArray<IMarkdownToken> tokens, MarkdownBlockContext context, bool wrapParagraph = false, IMarkdownRule rule = null)
 {
     var content = StringBuffer.Empty;
     var textContent = StringBuffer.Empty;
     foreach (var t in tokens)
     {
         var text = t as MarkdownTextToken;
         if (text != null)
         {
             if (textContent != StringBuffer.Empty)
             {
                 textContent += "\n";
             }
             textContent += text.Content;
             continue;
         }
         if (!wrapParagraph && t is MarkdownNewLineBlockToken)
         {
             continue;
         }
         if (textContent != StringBuffer.Empty)
         {
             content += RenderTextInTokens(engine, context, wrapParagraph, rule, textContent, t.RawMarkdown);
             textContent = StringBuffer.Empty;
         }
         content += engine.Render(t);
     }
     if (textContent != StringBuffer.Empty)
     {
         content += RenderTextInTokens(engine, context, wrapParagraph, rule, textContent, textContent);
     }
     return content;
 }
开发者ID:yodamaster,项目名称:docfx,代码行数:33,代码来源:HtmlRenderer.cs


注:本文中的IMarkdownRenderer.Render方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。