public virtual StringBuffer Render(IMarkdownRenderer renderer, MarkdownCodeBlockToken token, MarkdownBlockContext context) { bool escaped = false; string code = token.Code; if (renderer.Options.Highlight != null) { var highlightCode = renderer.Options.Highlight(code, token.Lang); if (highlightCode != null && highlightCode != code) { escaped = true; code = highlightCode; } } if (string.IsNullOrEmpty(token.Lang)) { return((StringBuffer)"<pre><code>" + (escaped ? code : StringHelper.Escape(code, true)) + "\n</code></pre>"); } return("<pre><code class=\"" + renderer.Options.LangPrefix + StringHelper.Escape(token.Lang, true) + "\">" + (escaped ? code : StringHelper.Escape(code, true)) + "\n</code></pre>\n"); }
public virtual StringBuffer Render(IMarkdownRenderer renderer, MarkdownCodeBlockToken token, MarkdownBlockContext context) { var result = StringBuffer.Empty; bool escaped = false; string code = token.Code; if (renderer.Options.Highlight != null) { var highlightCode = renderer.Options.Highlight(code, token.Lang); if (highlightCode != null && highlightCode != code) { escaped = true; code = highlightCode; } } result = result + "<pre"; result = AppendSourceInfo(result, renderer, token); result += "><code"; if (!string.IsNullOrEmpty(token.Lang)) { result = result + " class=\"" + renderer.Options.LangPrefix + StringHelper.Escape(token.Lang, true) + "\""; } result += ">"; result += (escaped ? code : StringHelper.Escape(code, true)); result += "\n</code></pre>"; return(result); }
public virtual StringBuffer Render(IMarkdownRenderer engine, MarkdownCodeBlockToken token, MarkdownBlockContext context) { bool escaped = false; string code = token.Code; if (engine.Options.Highlight != null) { var highlightCode = engine.Options.Highlight(code, token.Lang); if (highlightCode != null && highlightCode != code) { escaped = true; code = highlightCode; } } if (string.IsNullOrEmpty(token.Lang)) { return (StringBuffer)"<pre><code>" + (escaped ? code : StringHelper.Escape(code, true)) + "\n</code></pre>"; } return "<pre><code class=\"" + engine.Options.LangPrefix + StringHelper.Escape(token.Lang, true) + "\">" + (escaped ? code : StringHelper.Escape(code, true)) + "\n</code></pre>\n"; }
public virtual StringBuffer Render(IMarkdownRenderer renderer, MarkdownCodeBlockToken token, MarkdownBlockContext context) { if (!string.IsNullOrEmpty(token.Lang)) { return(Insert(token, $"{ExposeTokenName(token)}({token.Lang})>{Escape(token.Code)}")); } else { return(Insert(token, $"{ExposeTokenName(token)}>{Escape(token.Code)}")); } }
public virtual StringBuffer Render(IMarkdownRenderer renderer, MarkdownCodeBlockToken token, MarkdownBlockContext context) { return(this.Insert("Code(" + token.Lang + ")", this.GetSize(), Type.Leaf)); }