internal void RenderImg(Markdown m, StringBuilder b, string alt_text) { HtmlTag tag = new HtmlTag("img"); // encode url StringBuilder sb = m.GetStringBuilder(); Utils.SmartHtmlEncodeAmpsAndAngles(sb, url); tag.attributes["src"] = sb.ToString(); // encode alt text if (!String.IsNullOrEmpty(alt_text)) { sb.Length = 0; Utils.SmartHtmlEncodeAmpsAndAngles(sb, alt_text); tag.attributes["alt"] = sb.ToString(); } // encode title if (!String.IsNullOrEmpty(title)) { sb.Length = 0; Utils.SmartHtmlEncodeAmpsAndAngles(sb, title); tag.attributes["title"] = sb.ToString(); } tag.closed = true; m.OnPrepareImage(tag, m.RenderingTitledImage); tag.RenderOpening(b); }
internal void RenderImg(Markdown m, StringBuilder b, string alt_text, List <string> specialAttributes) { HtmlTag tag = new HtmlTag("img"); // encode url StringBuilder sb = m.GetStringBuilder(); Utils.SmartHtmlEncodeAmpsAndAngles(sb, Url); tag.attributes["src"] = sb.ToString(); // encode alt text if (!String.IsNullOrEmpty(alt_text)) { sb.Length = 0; Utils.SmartHtmlEncodeAmpsAndAngles(sb, alt_text); tag.attributes["alt"] = sb.ToString(); } // encode title if (!String.IsNullOrEmpty(Title)) { sb.Length = 0; Utils.SmartHtmlEncodeAmpsAndAngles(sb, Title); tag.attributes["title"] = sb.ToString(); } if (specialAttributes.Any()) { LinkDefinition.HandleSpecialAttributes(specialAttributes, sb, tag); } tag.closed = true; m.OnPrepareImage(tag, m.RenderingTitledImage); tag.RenderOpening(b); }
internal void RenderLink(Markdown m, StringBuilder b, string link_text, List <string> specialAttributes) { if (this.Url.StartsWith("mailto:")) { b.Append("<a href=\""); Utils.HtmlRandomize(b, this.Url); b.Append('\"'); if (!String.IsNullOrEmpty(this.Title)) { b.Append(" title=\""); Utils.SmartHtmlEncodeAmpsAndAngles(b, this.Title); b.Append('\"'); } b.Append('>'); Utils.HtmlRandomize(b, link_text); b.Append("</a>"); } else { HtmlTag tag = new HtmlTag("a"); // encode url StringBuilder sb = m.GetStringBuilder(); Utils.SmartHtmlEncodeAmpsAndAngles(sb, this.Url); tag.attributes["href"] = sb.ToString(); // encode title if (!String.IsNullOrEmpty(this.Title)) { sb.Length = 0; Utils.SmartHtmlEncodeAmpsAndAngles(sb, this.Title); tag.attributes["title"] = sb.ToString(); } if (specialAttributes.Any()) { LinkDefinition.HandleSpecialAttributes(specialAttributes, sb, tag); } // Do user processing m.OnPrepareLink(tag); // Render the opening tag tag.RenderOpening(b); b.Append(link_text); // Link text already escaped by SpanFormatter b.Append("</a>"); } }
internal void RenderLink(Markdown m, StringBuilder b, string linkText) { if (URL.StartsWith("mailto:")) { b.Append("<a href=\""); Utils.HtmlRandomize(b, URL); b.Append('\"'); if (!string.IsNullOrEmpty(Title)) { b.Append(" title=\""); Utils.SmartHtmlEncodeAmpsAndAngles(b, Title); b.Append('\"'); } b.Append('>'); Utils.HtmlRandomize(b, linkText); b.Append("</a>"); } else { var tag = new HtmlTag("a"); // encode url var sb = m.GetStringBuilder(); Utils.SmartHtmlEncodeAmpsAndAngles(sb, URL); tag.Attributes["href"] = sb.ToString(); // encode title if (!string.IsNullOrEmpty(Title)) { sb.Length = 0; Utils.SmartHtmlEncodeAmpsAndAngles(sb, Title); tag.Attributes["title"] = sb.ToString(); } // Do user processing m.OnPrepareLink(tag); // Render the opening tag tag.RenderOpening(b); b.Append(linkText); // Link text already escaped by SpanFormatter b.Append("</a>"); } }
internal void RenderLink(Markdown m, StringBuilder b, string link_text) { if (url.StartsWith("mailto:")) { b.Append("<a href=\""); Utils.HtmlRandomize(b, url); b.Append('\"'); if (!String.IsNullOrEmpty(title)) { b.Append(" title=\""); Utils.SmartHtmlEncodeAmpsAndAngles(b, title); b.Append('\"'); } b.Append('>'); Utils.HtmlRandomize(b, link_text); b.Append("</a>"); } else { HtmlTag tag = new HtmlTag("a"); // encode url StringBuilder sb = m.GetStringBuilder(); Utils.SmartHtmlEncodeAmpsAndAngles(sb, url); tag.attributes["href"] = sb.ToString(); // encode title if (!String.IsNullOrEmpty(title )) { sb.Length = 0; Utils.SmartHtmlEncodeAmpsAndAngles(sb, title); tag.attributes["title"] = sb.ToString(); } // Do user processing m.OnPrepareLink(tag); // Render the opening tag tag.RenderOpening(b); b.Append(link_text); // Link text already escaped by SpanFormatter b.Append("</a>"); } }
internal void RenderVideo(Markdown m, StringBuilder b, string alt_text) { HtmlTag tag = new HtmlTag("video"); tag.attributes ["controls"] = "controls"; // encode url StringBuilder sb = m.GetStringBuilder(); Utils.SmartHtmlEncodeAmpsAndAngles(sb, url); HtmlTag source = new HtmlTag("source"); source.attributes["src"] = sb.ToString(); m.OnPrepareVideoSource(source); // encode alt text if (!String.IsNullOrEmpty(alt_text)) { sb.Length = 0; Utils.SmartHtmlEncodeAmpsAndAngles(sb, alt_text); tag.attributes["alt"] = sb.ToString(); } // encode title if (!String.IsNullOrEmpty(title)) { sb.Length = 0; Utils.SmartHtmlEncodeAmpsAndAngles(sb, title); tag.attributes["title"] = sb.ToString(); } tag.closed = true; tag.RenderOpening(b); source.RenderOpening (b); tag.RenderClosing (b); }
internal void RenderAudio(Markdown m, StringBuilder b, string alt_text) { HtmlTag tag = new HtmlTag("audio"); tag.attributes ["controls"] = "controls"; // encode url StringBuilder sb = m.GetStringBuilder(); Utils.SmartHtmlEncodeAmpsAndAngles(sb, url); tag.attributes["src"] = sb.ToString(); // encode alt text if (!String.IsNullOrEmpty(alt_text)) { sb.Length = 0; Utils.SmartHtmlEncodeAmpsAndAngles(sb, alt_text); tag.attributes["alt"] = sb.ToString(); } // encode title if (!String.IsNullOrEmpty(title)) { sb.Length = 0; Utils.SmartHtmlEncodeAmpsAndAngles(sb, title); tag.attributes["title"] = sb.ToString(); } tag.RenderOpening (b); tag.RenderClosing (b); }
internal void RenderLink(Markdown m, StringBuilder b, string link_text, List <string> specialAttributes) { if (this.Url.StartsWith("mailto:")) { b.Append("<a href=\""); Utils.HtmlRandomize(b, this.Url); b.Append('\"'); if (!String.IsNullOrEmpty(this.Title)) { b.Append(" title=\""); Utils.SmartHtmlEncodeAmpsAndAngles(b, this.Title); b.Append('\"'); } b.Append('>'); Utils.HtmlRandomize(b, link_text); b.Append("</a>"); } else { HtmlTag tag = new HtmlTag("a"); var url = this.Url; if (m.DocNetMode && m.ConvertLocalLinks) { // A few requirements before we can convert local links: // 1. Link contains .md // 2. Link is relative // 3. Link is included in the index var index = url.LastIndexOf(".md", StringComparison.OrdinalIgnoreCase); if (index >= 0) { var linkProcessor = m.LocalLinkProcessor; if (linkProcessor != null) { url = linkProcessor(url); } else { Uri uri; if (Uri.TryCreate(url, UriKind.Relative, out uri)) { url = String.Concat(url.Substring(0, index), ".htm", url.Substring(index + ".md".Length)); } } } } // encode url StringBuilder sb = m.GetStringBuilder(); Utils.SmartHtmlEncodeAmpsAndAngles(sb, url); tag.attributes["href"] = sb.ToString(); // encode title if (!String.IsNullOrEmpty(this.Title)) { sb.Length = 0; Utils.SmartHtmlEncodeAmpsAndAngles(sb, this.Title); tag.attributes["title"] = sb.ToString(); } if (specialAttributes.Any()) { LinkDefinition.HandleSpecialAttributes(specialAttributes, sb, tag); } // Do user processing m.OnPrepareLink(tag); // Render the opening tag tag.RenderOpening(b); b.Append(link_text); // Link text already escaped by SpanFormatter b.Append("</a>"); } }
internal void RenderImg(Markdown m, StringBuilder b, string alt_text, List<string> specialAttributes) { HtmlTag tag = new HtmlTag("img"); // encode url StringBuilder sb = m.GetStringBuilder(); Utils.SmartHtmlEncodeAmpsAndAngles(sb, Url); tag.attributes["src"] = sb.ToString(); // encode alt text if (!String.IsNullOrEmpty(alt_text)) { sb.Length = 0; Utils.SmartHtmlEncodeAmpsAndAngles(sb, alt_text); tag.attributes["alt"] = sb.ToString(); } // encode title if (!String.IsNullOrEmpty(Title)) { sb.Length = 0; Utils.SmartHtmlEncodeAmpsAndAngles(sb, Title); tag.attributes["title"] = sb.ToString(); } if(specialAttributes.Any()) { LinkDefinition.HandleSpecialAttributes(specialAttributes, sb, tag); } tag.closed = true; m.OnPrepareImage(tag, m.RenderingTitledImage); tag.RenderOpening(b); }