public virtual StringBuffer Render(IMarkdownRenderer engine, DfmXrefInlineToken token, MarkdownInlineContext context) { var href = token.Href == null ? string.Empty : $" href=\"{StringHelper.HtmlEncode(token.Href)}\""; var name = token.Name == null ? null : StringHelper.HtmlEncode(token.Name); var title = token.Title == null ? null : $" title=\"{StringHelper.HtmlEncode(token.Title)}\""; return $"<xref{href}{title}>{name}</xref>"; }
public virtual StringBuffer Render(IMarkdownRenderer renderer, DfmIncludeInlineToken token, MarkdownInlineContext context) { lock (_inlineInclusionHelper) { return _inlineInclusionHelper.Load(renderer, token.Src, token.Raw, token.SourceInfo, context, (DfmEngine)renderer.Engine); } }
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); }
public virtual StringBuffer Render(IMarkdownRenderer render, MarkdownStrongInlineToken token, MarkdownInlineContext context) { StringBuffer content = StringBuffer.Empty; content += "**"; foreach (var t in token.Content) { content += render.Render(t); } content += "**"; return content; }
public virtual StringBuffer Render(IMarkdownRenderer render, MarkdownImageInlineToken token, MarkdownInlineContext context) { switch(token.LinkType) { case MarkdownLinkType.NormalLink: return RenderImageNormalLink(render, token, context); case MarkdownLinkType.NumberLink: return RenderNumberLink(render, token, context); case MarkdownLinkType.RefLink: return RenderRefLink(render, token, context); default: throw new NotSupportedException($"Link type: {token.LinkType} doesn't support in Image Link Render"); } }
private StringBuffer RenderImageNormalLink(IMarkdownRenderer render, MarkdownImageInlineToken token, MarkdownInlineContext context) { StringBuffer content = StringBuffer.Empty; content += "!["; content += token.Text; 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; }
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", token.RawMarkdown); result += ">"; if (token.Name != null) { result += StringHelper.HtmlEncode(token.Name); } result += "</xref>"; return result; }
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; }
public virtual StringBuffer Render(IMarkdownRenderer render, MarkdownLinkInlineToken token, MarkdownInlineContext context) { StringBuffer content = StringBuffer.Empty; content += "["; foreach(var t in token.Content) { content += render.Render(t); } content += "]("; content += StringHelper.Unescape(token.Href); if (!string.IsNullOrEmpty(token.Title)) { content += " \""; content += StringHelper.Unescape(token.Title); content += "\""; } content += ")"; return content; }
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; }
public virtual StringBuffer Render(IMarkdownRenderer renderer, DfmXrefInlineToken token, MarkdownInlineContext context) { StringBuffer result = "<xref"; if (token.Href != null) { result += " href=\""; result += StringHelper.HtmlEncode(token.Href); result += "\""; } if (token.Title != null) { result += " title=\""; result += StringHelper.HtmlEncode(token.Title); result += "\""; } result += ">"; if (token.Name != null) { result += StringHelper.HtmlEncode(token.Name); } result += "</xref>"; return result; }
public virtual StringBuffer Render(IMarkdownRenderer renderer, MarkdownTextToken token, MarkdownInlineContext context) { //return Insert(token, $"{ExposeTokenName(token)}>{Escape(token.Content)}"); return(Insert(token, $"{Escape(token.Content)}")); }
public virtual StringBuffer Render(MarkdownEngine engine, GfmDelInlineToken token, MarkdownInlineContext context) { var result = (StringBuffer)"<del>"; result += engine.Mark(token.Content); result += "</del>"; return result; }
public virtual StringBuffer Render(IMarkdownRenderer engine, MarkdownEscapeInlineToken token, MarkdownInlineContext context) { return(token.Content); }
public virtual StringBuffer Render(IMarkdownRenderer engine, GfmDelInlineToken token, MarkdownInlineContext context) { var result = (StringBuffer)"<del>"; foreach (var item in token.Content) { result += engine.Render(item); } result += "</del>"; return(result); }
private StringBuffer RenderImageNormalLink(IMarkdownRenderer render, MarkdownImageInlineToken token, MarkdownInlineContext context) { StringBuffer content = StringBuffer.Empty; content += "!["; content += token.Text; content += "]("; content += StringHelper.EscapeMarkdown(token.Href); if (!string.IsNullOrEmpty(token.Title)) { content += " \""; content += StringHelper.EscapeMarkdown(token.Title); content += "\""; } content += ")"; return(content); }
public virtual StringBuffer Render(MarkdownEngine engine, MarkdownTextToken token, MarkdownInlineContext context) { return(token.Content); }
private StringBuffer RenderUrlLink(IMarkdownRenderer render, MarkdownLinkInlineToken token, MarkdownInlineContext context) { return token.Href; }
private StringBuffer RenderAutoLink(IMarkdownRenderer render, MarkdownLinkInlineToken token, MarkdownInlineContext context) { StringBuffer content = StringBuffer.Empty; content += "<"; content += StringHelper.EscapeMarkdownHref(token.Href); content += ">"; return(content); }
private StringBuffer RenderUrlLink(IMarkdownRenderer render, MarkdownLinkInlineToken token, MarkdownInlineContext context) { return(StringHelper.EscapeMarkdownHref(token.Href)); }
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); }
private StringBuffer RenderRefLink(IMarkdownRenderer render, IMarkdownToken token, MarkdownInlineContext context) { StringBuffer content = StringBuffer.Empty; if (token is MarkdownImageInlineToken) { var realToken = token as MarkdownImageInlineToken; content += "!["; if (render.Options.LegacyMode) { content += StringHelper.LegacyEscapeMarkdown(realToken.Text); } else { content += StringHelper.EscapeMarkdown(realToken.Text); } content += "]["; content += realToken.RefId; content += "]"; } else if (token is MarkdownLinkInlineToken) { var realToken = token as MarkdownLinkInlineToken; content += "["; foreach (var t in realToken.Content) { content += render.Render(t); } content += "]["; content += realToken.RefId; content += "]"; } else { throw new NotSupportedException("Reference link token should be either link token or image token"); } return(content); }
public virtual StringBuffer Render(IMarkdownRenderer render, MarkdownLinkInlineToken token, MarkdownInlineContext context) { StringBuffer content = StringBuffer.Empty; content += "["; foreach (var t in token.Content) { content += render.Render(t); } content += "]("; content += StringHelper.Unescape(token.Href); if (!string.IsNullOrEmpty(token.Title)) { content += " \""; content += StringHelper.Unescape(token.Title); content += "\""; } content += ")"; return(content); }
public virtual StringBuffer Render(IMarkdownRenderer renderer, MarkdownBrInlineToken token, MarkdownInlineContext context) { return(Insert(token, ExposeTokenName(token))); }
public virtual StringBuffer Render(IMarkdownRenderer render, MarkdownImageInlineToken token, MarkdownInlineContext context) { StringBuffer content = StringBuffer.Empty; content += "!["; content += token.Text; content += "]("; content += Regexes.Helper.MarkdownUnescape.Replace(StringHelper.Unescape(token.Href), m => "\\" + m.Value); if (!string.IsNullOrEmpty(token.Title)) { content += " \""; content += Regexes.Helper.MarkdownUnescape.Replace(StringHelper.Unescape(token.Title), m => "\\" + m.Value); content += "\""; } content += ")"; return(content); }
public virtual StringBuffer Render(MarkdownEngine engine, MarkdownTagInlineToken token, MarkdownInlineContext context) { if (engine.Options.Sanitize) { if (engine.Options.Sanitizer != null) { return(engine.Options.Sanitizer(token.Content)); } return(StringHelper.Escape(token.Content)); } return(token.Content); }
public virtual StringBuffer Render(IMarkdownRenderer render, MarkdownStrongInlineToken token, MarkdownInlineContext context) { StringBuffer content = StringBuffer.Empty; content += "**"; foreach (var t in token.Content) { content += render.Render(t); } content += "**"; return(content); }
public virtual StringBuffer Render(MarkdownEngine engine, MarkdownBrInlineToken token, MarkdownInlineContext context) { return(engine.Options.XHtml ? "<br/>" : "<br>"); }
public virtual StringBuffer Render(IMarkdownRenderer engine, MarkdownLinkInlineToken token, MarkdownInlineContext context) { if (engine.Options.Sanitize) { string prot = null; try { prot = Regex.Replace(StringHelper.DecodeURIComponent(StringHelper.Unescape(token.Href)), @"[^\w:]", string.Empty).ToLower(); } catch (Exception) { return string.Empty; } if (prot.IndexOf("javascript:") == 0 || prot.IndexOf("vbscript:") == 0) { return string.Empty; } } var result = (StringBuffer)"<a href=\"" + token.Href + "\""; if (!string.IsNullOrEmpty(token.Title)) { result = result + " title=\"" + token.Title + "\""; } result += ">"; foreach (var item in token.Content) { result += engine.Render(item); } result += "</a>"; return result; }
private StringBuffer RenderAutoLink(IMarkdownRenderer render, MarkdownLinkInlineToken token, MarkdownInlineContext context) { StringBuffer content = StringBuffer.Empty; content += "<"; content += token.Href; content += ">"; return content; }
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; }
public virtual StringBuffer Render(IMarkdownRenderer renderer, MarkdownImageInlineToken token, MarkdownInlineContext context) { return(Insert(token, $"{ExposeTokenName(token)}>{Escape(token.Href)}")); }
public virtual StringBuffer Render(MarkdownEngine engine, MarkdownEscapeInlineToken token, MarkdownInlineContext context) { return token.Content; }
public virtual StringBuffer Render(IMarkdownRenderer engine, MarkdownCodeInlineToken token, MarkdownInlineContext context) { return (StringBuffer)"<code>" + StringHelper.Escape(token.Content, true) + "</code>"; }
private StringBuffer RenderUrlLink(IMarkdownRenderer render, MarkdownLinkInlineToken token, MarkdownInlineContext context) { return(token.Href); }
public virtual StringBuffer Render(IMarkdownRenderer render, AzureIncludeInlineToken token, MarkdownInlineContext context) { return RenderAzureIncludeToken(render, token, context); }
public virtual StringBuffer Render(IMarkdownRenderer engine, MarkdownTagInlineToken token, MarkdownInlineContext context) { if (engine.Options.Sanitize) { if (engine.Options.Sanitizer != null) { return engine.Options.Sanitizer(token.RawMarkdown); } return StringHelper.Escape(token.RawMarkdown); } return token.RawMarkdown; }
public virtual StringBuffer Render(MarkdownEngine engine, MarkdownLinkInlineToken token, MarkdownInlineContext context) { if (engine.Options.Sanitize) { string prot = null; try { prot = Regex.Replace(StringHelper.DecodeURIComponent(StringHelper.Unescape(token.Href)), @"[^\w:]", string.Empty).ToLower(); } catch (Exception) { return string.Empty; } if (prot.IndexOf("javascript:") == 0 || prot.IndexOf("vbscript:") == 0) { return string.Empty; } } var result = (StringBuffer)"<a href=\"" + token.Href + "\""; if (!string.IsNullOrEmpty(token.Title)) { result = result + " title=\"" + token.Title + "\""; } result += ">"; if (token.ShouldApplyInlineRule) { engine.SwitchContext(MarkdownInlineContext.IsInLink, true); result += engine.Mark(token.Text); engine.SwitchContext(MarkdownInlineContext.IsInLink, false); } else { result += token.Text; } result += "</a>"; return result; }
public virtual StringBuffer Render(IMarkdownRenderer engine, MarkdownTextToken token, MarkdownInlineContext context) { return token.Content; }
public virtual StringBuffer Render(IMarkdownRenderer engine, MarkdownLinkInlineToken token, MarkdownInlineContext context) { if (engine.Options.Sanitize) { string prot = null; try { prot = Regex.Replace(StringHelper.DecodeURIComponent(StringHelper.Unescape(token.Href)), @"[^\w:]", string.Empty).ToLower(); } catch (Exception) { return(string.Empty); } if (prot.IndexOf("javascript:") == 0 || prot.IndexOf("vbscript:") == 0) { return(string.Empty); } } var result = (StringBuffer)"<a href=\"" + token.Href + "\""; if (!string.IsNullOrEmpty(token.Title)) { result = result + " title=\"" + token.Title + "\""; } result += ">"; foreach (var item in token.Content) { result += engine.Render(item); } result += "</a>"; return(result); }
public virtual StringBuffer Render(IMarkdownRenderer renderer, GfmDelInlineToken token, MarkdownInlineContext context) { var childContent = StringBuffer.Empty; foreach (var item in token.Content) { childContent += renderer.Render(item); } return(Insert(token, ExposeTokenName(token), childContent)); }
public virtual StringBuffer Render(IMarkdownRenderer render, MarkdownLinkInlineToken token, MarkdownInlineContext context) { switch (token.LinkType) { case MarkdownLinkType.AutoLink: return(RenderAutoLink(render, token, context)); case MarkdownLinkType.NormalLink: return(RenderLinkNormalLink(render, token, context)); case MarkdownLinkType.NumberLink: return(RenderNumberLink(render, token, context)); case MarkdownLinkType.RefLink: return(RenderRefLink(render, token, context)); case MarkdownLinkType.UrlLink: return(RenderUrlLink(render, token, context)); default: throw new NotSupportedException($"Link type: {token.LinkType} doesn't support in Link Render"); } }
public virtual StringBuffer Render(IMarkdownRenderer renderer, DfmIncludeInlineToken token, MarkdownInlineContext context) { return Insert(token, ExposeTokenNameInDfm(token)); }
public virtual StringBuffer Render(IMarkdownRenderer engine, MarkdownImageInlineToken token, MarkdownInlineContext context) { var result = (StringBuffer)"<img src=\"" + token.Href + "\" alt=\"" + token.Text + "\""; if (!string.IsNullOrEmpty(token.Title)) { result = result + " title=\"" + token.Title + "\""; } result += engine.Options.XHtml ? "/>" : ">"; return result; }
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 += StringHelper.EscapeMarkdownHref(token.Href); if (!string.IsNullOrEmpty(token.Title)) { content += " \""; if (render.Options.LegacyMode) { content += StringHelper.LegacyEscapeMarkdown(token.Title); } else { content += StringHelper.EscapeMarkdown(token.Title); } content += "\""; } content += ")"; return(content); }
public virtual StringBuffer Render(IMarkdownRenderer engine, GfmDelInlineToken token, MarkdownInlineContext context) { var result = (StringBuffer)"<del>"; foreach (var item in token.Content) { result += engine.Render(item); } result += "</del>"; return result; }
public virtual StringBuffer Render(MarkdownEngine engine, MarkdownLinkInlineToken token, MarkdownInlineContext context) { if (engine.Options.Sanitize) { string prot = null; try { prot = Regex.Replace(StringHelper.DecodeURIComponent(StringHelper.Unescape(token.Href)), @"[^\w:]", string.Empty).ToLower(); } catch (Exception) { return(string.Empty); } if (prot.IndexOf("javascript:") == 0 || prot.IndexOf("vbscript:") == 0) { return(string.Empty); } } var result = (StringBuffer)"<a href=\"" + token.Href + "\""; if (!string.IsNullOrEmpty(token.Title)) { result = result + " title=\"" + token.Title + "\""; } result += ">"; if (token.ShouldApplyInlineRule) { engine.SwitchContext(MarkdownInlineContext.IsInLink, true); result += engine.Mark(token.Text); engine.SwitchContext(MarkdownInlineContext.IsInLink, false); } else { result += token.Text; } result += "</a>"; return(result); }
public virtual StringBuffer Render(IMarkdownRenderer engine, MarkdownBrInlineToken token, MarkdownInlineContext context) { return engine.Options.XHtml ? "<br/>" : "<br>"; }
public virtual StringBuffer Render(MarkdownEngine engine, MarkdownImageInlineToken token, MarkdownInlineContext context) { var result = (StringBuffer)"<img src=\"" + token.Href + "\" alt=\"" + token.Text + "\""; if (!string.IsNullOrEmpty(token.Title)) { result = result + " title=\"" + token.Title + "\""; } result += engine.Options.XHtml ? "/>" : ">"; return(result); }
public virtual StringBuffer Render(IMarkdownRenderer render, DfmIncludeInlineToken token, MarkdownInlineContext context) { return string.IsNullOrEmpty(token.Title) ? $"[!INCLUDE [{token.Name}]({token.Src})]" : $"[!INCLUDE [{token.Name}]({token.Src} \"{token.Title}\")]"; }
public virtual StringBuffer Render(MarkdownEngine engine, MarkdownCodeInlineToken token, MarkdownInlineContext context) { return((StringBuffer)"<code>" + StringHelper.Escape(token.Content, true) + "</code>"); }
public virtual StringBuffer Render(IMarkdownRenderer renderer, DfmIncludeInlineToken token, MarkdownInlineContext context) { var resolved = _inlineInclusionHelper.Load(renderer, token.Src, token.Raw, context, ((DfmEngine)renderer.Engine).InternalMarkup); return resolved; }
public virtual StringBuffer Render(MarkdownEngine engine, GfmDelInlineToken token, MarkdownInlineContext context) { var result = (StringBuffer)"<del>"; result += engine.Mark(token.Content); result += "</del>"; return(result); }