コード例 #1
0
 protected override void Write(RenderFragmentMarkdownRenderer renderer, EmphasisInline obj)
 {
     renderer.WriteElementStart(obj.DelimiterCount == 2 ? "strong" : "em")
     .WriteAttributes(obj.TryGetAttributes())
     .WriteChildren(obj);
     renderer.WriteElementEnd();
 }
コード例 #2
0
        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();
        }
コード例 #3
0
        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;
            }
        }
コード例 #4
0
        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();
        }
コード例 #5
0
 protected override void Write(RenderFragmentMarkdownRenderer renderer, HtmlInline obj)
 => throw new NotImplementedException();
コード例 #6
0
 protected override void Write(RenderFragmentMarkdownRenderer renderer, LiteralInline obj)
 => renderer.WriteText(obj.Content.ToString());
コード例 #7
0
 protected override void Write(RenderFragmentMarkdownRenderer renderer, LineBreakInline obj)
 => renderer.WriteElementStart("br")
 .WriteElementEnd();
コード例 #8
0
 protected override void Write(RenderFragmentMarkdownRenderer renderer, HtmlEntityInline obj)
 => renderer.WriteText(obj.Transcoded.ToString());
コード例 #9
0
 protected override void Write(RenderFragmentMarkdownRenderer renderer, DelimiterInline obj)
 => renderer.WriteText(obj.ToLiteral()).WriteChildren(obj);
コード例 #10
0
 protected override void Write(RenderFragmentMarkdownRenderer renderer, CodeInline obj)
 => renderer.WriteElementStart("code")
 .WriteAttributes(obj.TryGetAttributes())
 .WriteText(obj.Content)
 .WriteElementEnd();
コード例 #11
0
 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();
コード例 #12
0
 protected override void Write(RenderFragmentMarkdownRenderer renderer, ThematicBreakBlock obj)
 => renderer.WriteElementStart("hr").WriteElementEnd();
コード例 #13
0
 protected override void Write(RenderFragmentMarkdownRenderer renderer, ParagraphBlock obj)
 => renderer.WriteElementStart("p")
 .WriteAttributes(obj.TryGetAttributes())
 .WriteLeafInline(obj)
 .WriteElementEnd();
コード例 #14
0
 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();
コード例 #15
0
 protected override void Write(RenderFragmentMarkdownRenderer renderer, CodeBlock obj)
 => renderer.WriteElementStart("div")
 .WriteAttributes(obj.TryGetAttributes())
 .WriteLeafLines(obj)
 .WriteElementEnd();