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 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 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>"); } }