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); }
private StringBuffer RenderAutoLink(IMarkdownRenderer render, MarkdownLinkInlineToken token, MarkdownInlineContext context) { StringBuffer content = StringBuffer.Empty; content += "<"; content += token.Href; content += ">"; return(content); }
public virtual StringBuffer Render(IMarkdownRenderer renderer, MarkdownLinkInlineToken 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 renderer, MarkdownLinkInlineToken token, MarkdownInlineContext context) { var childContent = StringBuffer.Empty; foreach (var item in token.Content) { childContent += renderer.Render(item); } return(this.Insert("Link", childContent, Type.NonLeaf)); }
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(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); }
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 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 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, MarkdownLinkInlineToken token, MarkdownInlineContext context) { if (renderer.Options.Sanitize) { string prot = null; try { prot = Regex.Replace(StringHelper.DecodeURIComponent(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=\"" + StringHelper.Escape(token.Href) + "\""; if (!string.IsNullOrEmpty(token.Title)) { result = result + " title=\"" + StringHelper.Escape(token.Title) + "\""; } 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 += "</a>"; return(result); }
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 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(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; }
private StringBuffer RenderAutoLink(IMarkdownRenderer render, MarkdownLinkInlineToken token, MarkdownInlineContext context) { StringBuffer content = StringBuffer.Empty; content += "<"; content += token.Href; content += ">"; return 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; }
private StringBuffer RenderUrlLink(IMarkdownRenderer render, MarkdownLinkInlineToken token, MarkdownInlineContext context) { return token.Href; }
private StringBuffer RenderUrlLink(IMarkdownRenderer render, MarkdownLinkInlineToken token, MarkdownInlineContext context) { return(StringHelper.EscapeMarkdownHref(token.Href)); }
private StringBuffer RenderUrlLink(IMarkdownRenderer render, MarkdownLinkInlineToken token, MarkdownInlineContext context) { return(token.Href); }