Beispiel #1
0
        protected override void Write(MamlRenderer renderer, ListBlock listBlock)
        {
            renderer.EnsureLine();

            if (listBlock.IsOrdered)
            {
                renderer.Push(MamlElements.list, new Dictionary <string, string> {
                    ["class"] = "ordered"
                });
            }
            else
            {
                renderer.Push(MamlElements.list, new Dictionary <string, string> {
                    ["class"] = "bullet"
                });
            }
            foreach (var item in listBlock)
            {
                var listItem = (ListItemBlock)item;

                renderer.EnsureLine();
                renderer.Push(MamlElements.listItem);
                renderer.WriteChildren(listItem);
                renderer.PopTo(MamlElements.listItem);
            }
            renderer.PopTo(MamlElements.list);
        }
Beispiel #2
0
        protected override void Write(MamlRenderer renderer, QuoteBlock obj)
        {
            renderer.EnsureLine();

            renderer.Push(MamlElements.quote);
            renderer.WriteChildren(obj);
            renderer.PopTo(MamlElements.quote);
        }
        protected override void Write(MamlRenderer renderer, EmphasisInline obj)
        {
            MamlElement mamlElement = null;

            switch (obj.DelimiterChar)
            {
            case '*':
            case '_':
                if (obj.IsDouble)
                {
                    mamlElement = MamlElements.legacyBold;
                }
                else
                {
                    mamlElement = MamlElements.legacyItalic;
                }
                break;

            case '~':
                if (obj.IsDouble)
                {
                    mamlElement = MamlElements.legacyStrikethrough;
                }
                else
                {
                    mamlElement = MamlElements.subscript;
                }

                break;

            case '^':
                mamlElement = MamlElements.superscript;
                break;

            case '+':
                // Inserted style
                mamlElement = MamlElements.legacyUnderline;
                break;

            case '=':
                // Marked style
                break;
            }

            if (null != mamlElement)
            {
                renderer.Push(mamlElement);
            }
            renderer.WriteChildren(obj);
            if (null != mamlElement)
            {
                renderer.PopTo(mamlElement);
            }
        }
Beispiel #4
0
        /// <inheritdoc/>
        protected override void Write(MamlRenderer renderer, LinkInline link)
        {
            var url = link.GetDynamicUrl != null?link.GetDynamicUrl() ?? link.Url : link.Url;

            if (link.IsImage)
            {
                RenderImage(renderer, link, url);
            }
            else // link is not an image
            {
                if (Uri.IsWellFormedUriString(url, UriKind.RelativeOrAbsolute))
                {
                    renderer.Push(MamlElements.externalLink);
                    renderer.Push(MamlElements.linkText);
                    renderer.WriteChildren(link);
                    renderer.PopTo(MamlElements.linkText);

                    renderer.Push(MamlElements.linkUri);
                    renderer.Write(url);
                    renderer.PopTo(MamlElements.linkUri);
                    renderer.PopTo(MamlElements.externalLink);
                }
                else // not a well formed Uri String - then it is probably a fragment reference
                {
                    // the challenge here is to find out where (in which file) our target is. The file might even not be defined in the moment
                    var(fileGuid, localUrl) = renderer.FindFragmentLink(url);
                    string totalAddress = string.Empty;
                    if (null != fileGuid && null != localUrl)
                    {
                        totalAddress = fileGuid + "#" + localUrl;
                    }

                    renderer.Push(MamlElements.link, new[] { new KeyValuePair <string, string>("xlink:href", totalAddress) });
                    renderer.WriteChildren(link);
                    renderer.PopTo(MamlElements.link);
                }
            }
        }
Beispiel #5
0
 protected override void Write(MamlRenderer renderer, Markdig.Extensions.Figures.Figure obj)
 {
     renderer.WriteChildren(obj);
 }
 protected override void Write(MamlRenderer renderer, DelimiterInline obj)
 {
     renderer.WriteEscape(obj.ToLiteral());
     renderer.WriteChildren(obj);
 }