本文整理汇总了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;
}
示例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;
}
示例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";
}
示例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);
}
示例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);
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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";
}
示例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;
}
示例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;
}