本文整理汇总了C#中MarkdownDeep.Markdown.FormatCodeBlock方法的典型用法代码示例。如果您正苦于以下问题:C# Markdown.FormatCodeBlock方法的具体用法?C# Markdown.FormatCodeBlock怎么用?C# Markdown.FormatCodeBlock使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MarkdownDeep.Markdown
的用法示例。
在下文中一共展示了Markdown.FormatCodeBlock方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RenderCodeBlock
internal void RenderCodeBlock(Markdown m, StringBuilder b)
{
if (m.FormatCodeBlock != null)
{
var sb = new StringBuilder();
foreach (var line in children)
{
m.HtmlEncodeAndConvertTabsToSpaces(sb, line.buf, line.contentStart, line.contentLen);
sb.Append(RenderTokens.NewLine);
}
b.Append(m.FormatCodeBlock(m, sb.ToString()));
}
else
{
var attr = string.Empty;
if (m.ExtraMode && !string.IsNullOrEmpty(this.codeBlockLang))
{
attr = string.Format(RenderTokens.ClassAttr, this.codeBlockLang);
}
b.Append(string.Format(RenderTokens.CodeBlockStart, attr));
foreach (var line in children)
{
m.HtmlEncodeAndConvertTabsToSpaces(b, line.buf, line.contentStart, line.contentLen);
b.Append(RenderTokens.NewLine);
}
b.Append(RenderTokens.CodeBlockEnd);
}
return;
}
示例2: Render
//.........这里部分代码省略.........
if (children == null)
{
foreach (var l in Content.Split('\n'))
{
b.Append("<dt>");
m.SpanFormatter.Format(b, l.Trim());
b.Append("</dt>\n");
}
}
else
{
b.Append("<dt>\n");
RenderChildren(m, b);
b.Append("</dt>\n");
}
break;
}
case BlockType.dl:
b.Append("<dl>\n");
RenderChildren(m, b);
b.Append("</dl>\n");
return;
case BlockType.html:
b.Append(buf, contentStart, contentLen);
return;
case BlockType.unsafe_html:
m.HtmlEncode(b, buf, contentStart, contentLen);
return;
case BlockType.codeblock:
if (m.FormatCodeBlock != null)
{
var sb = new StringBuilder();
foreach (var line in children)
{
m.HtmlEncodeAndConvertTabsToSpaces(sb, line.buf, line.contentStart, line.contentLen);
sb.Append("\n");
}
b.Append(m.FormatCodeBlock(m, sb.ToString()));
}
else
{
b.Append("<pre><code>");
foreach (var line in children)
{
m.HtmlEncodeAndConvertTabsToSpaces(b, line.buf, line.contentStart, line.contentLen);
b.Append("\n");
}
b.Append("</code></pre>\n\n");
}
return;
case BlockType.quote:
b.Append("<blockquote>\n");
RenderChildren(m, b);
b.Append("</blockquote>\n");
return;
case BlockType.li:
b.Append("<li>\n");
RenderChildren(m, b);
b.Append("</li>\n");
return;