protected override void Write(RenderFragmentMarkdownRenderer renderer, EmphasisInline obj) { renderer.WriteElementStart(obj.DelimiterCount == 2 ? "strong" : "em") .WriteAttributes(obj.TryGetAttributes()) .WriteChildren(obj); renderer.WriteElementEnd(); }
protected override void Write(RenderFragmentMarkdownRenderer renderer, QuoteBlock obj) { renderer.WriteElementStart("blockquote") .WriteAttributes(obj.TryGetAttributes()); var oldImplicitParagraph = renderer.ImplicitParagraph; renderer.ImplicitParagraph = false; renderer.WriteChildren(obj); renderer.ImplicitParagraph = oldImplicitParagraph; renderer.WriteElementEnd(); }
protected override void Write(RenderFragmentMarkdownRenderer renderer, ListBlock obj) { renderer.WriteElementStart(obj.IsOrdered ? "ol" : "ul") .WriteAttributes(obj.TryGetAttributes()); foreach (ListItemBlock item in obj) { var oldImplicitParagraph = renderer.ImplicitParagraph; renderer.ImplicitParagraph = !obj.IsLoose; renderer.WriteElementStart("li").WriteAttributes(item.TryGetAttributes()); renderer.WriteChildren(item); renderer.WriteElementEnd(); renderer.ImplicitParagraph = oldImplicitParagraph; } }
protected override void Write(RenderFragmentMarkdownRenderer renderer, LinkInline obj) { string url = obj.GetDynamicUrl?.Invoke() ?? obj.Url; renderer.WriteElementStart(obj.IsImage ? "img" : "a") .WriteAttribute(obj.IsImage ? "src" : "href", url); if (obj.IsImage) { renderer.WriteAttribute("alt", "** Image **"); // Don't wanna bother implementing this yet. It would require creating a nested HTML renderer + StringWriter. } if (!string.IsNullOrEmpty(obj.Title)) { renderer.WriteAttribute("title", obj.Title); } if (!obj.IsImage) { renderer.WriteChildren(obj); } renderer.WriteElementEnd(); }
protected override void Write(RenderFragmentMarkdownRenderer renderer, HtmlInline obj) => throw new NotImplementedException();
protected override void Write(RenderFragmentMarkdownRenderer renderer, LiteralInline obj) => renderer.WriteText(obj.Content.ToString());
protected override void Write(RenderFragmentMarkdownRenderer renderer, LineBreakInline obj) => renderer.WriteElementStart("br") .WriteElementEnd();
protected override void Write(RenderFragmentMarkdownRenderer renderer, HtmlEntityInline obj) => renderer.WriteText(obj.Transcoded.ToString());
protected override void Write(RenderFragmentMarkdownRenderer renderer, DelimiterInline obj) => renderer.WriteText(obj.ToLiteral()).WriteChildren(obj);
protected override void Write(RenderFragmentMarkdownRenderer renderer, CodeInline obj) => renderer.WriteElementStart("code") .WriteAttributes(obj.TryGetAttributes()) .WriteText(obj.Content) .WriteElementEnd();
protected override void Write(RenderFragmentMarkdownRenderer renderer, AutolinkInline obj) => renderer.WriteElementStart("a") .WriteAttribute("href", obj.IsEmail ? "mailto:" + obj.Url : obj.Url) .WriteAttributes(obj.TryGetAttributes()) .WriteText(obj.Url) .WriteElementEnd();
protected override void Write(RenderFragmentMarkdownRenderer renderer, ThematicBreakBlock obj) => renderer.WriteElementStart("hr").WriteElementEnd();
protected override void Write(RenderFragmentMarkdownRenderer renderer, ParagraphBlock obj) => renderer.WriteElementStart("p") .WriteAttributes(obj.TryGetAttributes()) .WriteLeafInline(obj) .WriteElementEnd();
protected override void Write(RenderFragmentMarkdownRenderer renderer, HeadingBlock obj) => renderer.WriteElementStart(obj.Level > 0 && obj.Level <= 6 ? KnownHeadingTags[obj.Level - 1] : "h" + obj.Level.ToString(CultureInfo.InvariantCulture)) .WriteAttributes(obj.TryGetAttributes()) .WriteLeafInline(obj) .WriteElementEnd();
protected override void Write(RenderFragmentMarkdownRenderer renderer, CodeBlock obj) => renderer.WriteElementStart("div") .WriteAttributes(obj.TryGetAttributes()) .WriteLeafLines(obj) .WriteElementEnd();