Exemple #1
0
 protected override void Write(SpeeDataRenderer renderer, CodeBlock obj)
 {
     renderer.WriteStartParagraph();
     //if (obj is FencedCodeBlock f)
     //    f.Info;
     renderer.WriteItems(obj, true);
     renderer.WriteEndParagraph();
 }
Exemple #2
0
            protected override void Write(SpeeDataRenderer renderer, LiteralInline obj)
            {
                if (obj.Content.IsEmpty)
                {
                    return;
                }

                renderer.WriteText(ref obj.Content);
            }
Exemple #3
0
 protected override void Write(SpeeDataRenderer renderer, HeadingBlock headingBlock)
 {
     renderer.WriteStartParagraph();
     renderer.WriteStartElement("Fontface");
     renderer.WriteAttribute("fontfamily", headingBlock.Level <= 1 ? "head1" : "head2");
     renderer.WriteStartElement("B");
     renderer.WriteItems(headingBlock);
     renderer.WriteEndElement();
     renderer.WriteEndElement();
     renderer.WriteEndParagraph();
 }
Exemple #4
0
 protected override void Write(SpeeDataRenderer renderer, LineBreakInline obj)
 {
     if (obj.IsHard)
     {
         renderer.WriteLineBreak();
     }
     else                 // Soft line break.
     {
         renderer.WriteText(" ");
     }
 }
Exemple #5
0
            }             // proc WriteSpan

            protected override void Write(SpeeDataRenderer renderer, EmphasisInline span)
            {
                if (WriteSpan(renderer, span))
                {
                    renderer.WriteItems(span);
                    renderer.WriteEndElement();
                }
                else
                {
                    renderer.WriteChildren(span);
                }
            }     // proc Write
Exemple #6
0
            private static bool WriteSpan(SpeeDataRenderer renderer, EmphasisInline span)
            {
                // Links:
                // - https://github.com/lunet-io/markdig/blob/master/src/Markdig.Tests/Specs/EmphasisExtraSpecs.md
                // - http://commonmark.org/help/
                switch (span.DelimiterChar)
                {
                case '*':
                case '_':
                    renderer.WriteStartElement(span.DelimiterCount == 2 ? "B" : "I");
                    return(true);

                case '~':
                    //if (span.IsDouble)
                    return(false);                            // StrikeThrough -> Durchgestrichen

                //else
                //{
                //	renderer.WriteStartElement("Sub"); // Subscript -> Tiefgestellt
                //	return true;
                //}
                case '^':
                    //if (span.IsDouble)
                    return(false);                                    // free

                //else
                //{
                //	renderer.WriteStartElement("Sup"); // Superscript -> Hochgestellt
                //	return true;
                //}
                case '+':
                    if (span.DelimiterCount == 2)
                    {
                        renderer.WriteStartElement("U");                                 // Underlined -> Unterstrichen
                        return(true);
                    }
                    else
                    {
                        return(false);                                // free
                    }

                case '=':                         // Marked
                    renderer.WriteStartElement("Color");
                    renderer.WriteAttribute("name", "marked");
                    return(true);

                default:
                    return(false);
                }
            }             // proc WriteSpan
Exemple #7
0
        }         // func CreatePipeline

        public static void ToXml(string markdown, XmlWriter xml, MarkdownPipeline pipeline)
        {
            if (markdown == null)
            {
                return;
            }
            if (xml == null)
            {
                throw new ArgumentNullException(nameof(xml));
            }

            pipeline = pipeline ?? DefaultPipeLine;

            var renderer = new SpeeDataRenderer(xml);

            pipeline.Setup(renderer);
            renderer.Render(Markdig.Markdown.Parse(markdown, pipeline));
        }         // proc ToXaml
Exemple #8
0
            protected override void Write(SpeeDataRenderer renderer, LinkInline link)
            {
                var url = link.GetDynamicUrl != null?link.GetDynamicUrl() ?? link.Url : link.Url;

                if (link.IsImage)
                {
                    //if (!Uri.IsWellFormedUriString(url, UriKind.RelativeOrAbsolute))
                    //	url = "#";

                    //renderer.WriteStartObject(typeof(Image));
                    //renderer.WriteStaticResourceMember(null, "markdig:Styles.ImageStyleKey");
                    //if (!String.IsNullOrEmpty(link.Title))
                    //	renderer.WriteMember(ToolTipService.ToolTipProperty, link.Title);
                    //renderer.WriteMember(Image.SourceProperty, new Uri(url, UriKind.RelativeOrAbsolute));
                    //renderer.WriteEndObject();
                }
                else
                {
                    renderer.WriteText(link.Title);
                }
            }
Exemple #9
0
            protected override void Write(SpeeDataRenderer renderer, ListBlock listBlock)
            {
                if (listBlock.IsOrdered)
                {
                    renderer.WriteStartElement("OL");

                    //if (listBlock.OrderedStart != null && (listBlock.DefaultOrderedStart != listBlock.OrderedStart))
                    //	renderer.WriteMember(List.StartIndexProperty, listBlock.OrderedStart);
                }
                else
                {
                    renderer.WriteStartElement("UL");
                }


                foreach (var cur in listBlock)
                {
                    renderer.WriteStartElement("LI");
                    renderer.WriteItems((ContainerBlock)cur);
                    renderer.WriteEndElement();
                }

                renderer.WriteEndElement();
            }
Exemple #10
0
 protected override void Write(SpeeDataRenderer renderer, ParagraphBlock paragraph)
 {
     renderer.WriteStartParagraph();
     renderer.WriteItems(paragraph);
     renderer.WriteEndParagraph();
 }
Exemple #11
0
 protected override void Write(SpeeDataRenderer renderer, QuoteBlock block)
 {
     renderer.WriteStartParagraph();
     renderer.WriteItems(block);
     renderer.WriteEndParagraph();
 }
Exemple #12
0
 protected override void Write(SpeeDataRenderer renderer, ThematicBreakBlock obj)
 {
     renderer.WriteStartElement("Paragraph");
     renderer.WriteEndElement();
 }
Exemple #13
0
 protected override void Write(SpeeDataRenderer renderer, AutolinkInline link)
 => renderer.WriteText(link.Url);
Exemple #14
0
 protected override void Write(SpeeDataRenderer renderer, CodeInline code)
 {
     renderer.WriteStartElement("Span");
     renderer.WriteText(code.Content);
     renderer.WriteEndElement();
 }
Exemple #15
0
 protected override void Write(SpeeDataRenderer renderer, DelimiterInline obj)
 {
     renderer.WriteText(obj.ToLiteral());
     renderer.WriteChildren(obj);
 }