Beispiel #1
0
        protected override void Write([NotNull] XamlRenderer renderer, [NotNull] LinkInline obj)
        {
            var url = obj.GetDynamicUrl?.Invoke() ?? obj.Url;

            if (obj.IsImage)
            {
                renderer.Write("<Image");
                // Add image styling
                renderer.Write(" Style=\"{StaticResource {x:Static markdig:Styles.ImageStyleKey}}\"");
                renderer.WriteLine(">");
                renderer.WriteLine("<Image.Source>");
                renderer.Write("<BitmapImage");
                renderer.Write(" UriSource=\"").WriteEscapeUrl(url).Write("\"");
                renderer.WriteLine(" />");
                renderer.WriteLine("</Image.Source>");
                renderer.WriteLine("</Image>");
            }
            else
            {
                renderer.Write("<Hyperlink");
                renderer.Write(" Style=\"{StaticResource {x:Static markdig:Styles.HyperlinkStyleKey}}\"");
                renderer.Write(" Command=\"{x:Static markdig:Commands.Hyperlink}\"");
                renderer.Write(" CommandParameter=\"").WriteEscapeUrl(url).Write("\"");
                if (!string.IsNullOrEmpty(obj.Title))
                {
                    renderer.Write(" ToolTip=\"").Write(obj.Title).Write("\"");
                }
                renderer.WriteLine(">");
                renderer.WriteChildren(obj);
                renderer.EnsureLine();
                renderer.WriteLine("</Hyperlink>");
            }
        }
Beispiel #2
0
        protected override void Write([NotNull] XamlRenderer renderer, [NotNull] ListBlock listBlock)
        {
            renderer.EnsureLine();

            renderer.Write("<List");
            if (listBlock.IsOrdered)
            {
                renderer.Write(" MarkerStyle=\"Decimal\"");

                if (listBlock.OrderedStart != null && (listBlock.DefaultOrderedStart != listBlock.OrderedStart))
                {
                    renderer.Write(" StartIndex=\"").Write(listBlock.OrderedStart).Write("\"");
                }
            }
            else
            {
                renderer.Write(" MarkerStyle=\"Disc\"");
            }
            renderer.WriteLine(">");

            foreach (var item in listBlock)
            {
                var listItem = (ListItemBlock)item;

                renderer.EnsureLine();
                renderer.WriteLine("<ListItem>");
                renderer.WriteChildren(listItem);
                renderer.WriteLine("</ListItem>");
            }
            renderer.WriteLine("</List>");
        }
Beispiel #3
0
        protected override void Write([NotNull] XamlRenderer renderer, [NotNull] EmphasisInline obj)
        {
            var tag = GetTag(obj);

            renderer.Write("<").Write(tag);
            switch (obj.DelimiterChar)
            {
            case '*':
            case '_':
                break;

            case '~':
                renderer.Write(obj.IsDouble
                        ? " Style=\"{StaticResource {x:Static markdig:Styles.StrikeThroughStyleKey}}\""
                        : " Style=\"{StaticResource {x:Static markdig:Styles.SubscriptStyleKey}}\"");
                break;

            case '^':
                renderer.Write(" Style=\"{StaticResource {x:Static markdig:Styles.SuperscriptStyleKey}}\"");
                break;

            case '+':
                renderer.Write(" Style=\"{StaticResource {x:Static markdig:Styles.InsertedStyleKey}}\"");
                break;

            case '=':
                renderer.Write(" Style=\"{StaticResource {x:Static markdig:Styles.MarkedStyleKey}}\"");
                break;
            }
            renderer.Write(">");
            renderer.WriteChildren(obj);
            renderer.Write("</").Write(tag).Write(">");
        }
 protected override void Write([NotNull] XamlRenderer renderer, [NotNull] EmphasisInline obj)
 {
     var tag = GetTag(obj);
     renderer.Write("<").Write(tag).Write(">");
     renderer.WriteChildren(obj);
     renderer.Write("</").Write(tag).Write(">");
 }
Beispiel #5
0
        protected override void Write([NotNull] XamlRenderer renderer, QuoteBlock obj)
        {
            renderer.EnsureLine();

            renderer.Write("<Section");
            // Apply quote block styling
            renderer.Write(" Style=\"{StaticResource {x:Static markdig:Styles.QuoteBlockStyleKey}}\"");
            renderer.WriteLine(">");
            renderer.WriteChildren(obj);
            renderer.WriteLine("</Section>");
        }
Beispiel #6
0
        protected override void Write(XamlRenderer renderer, DelimiterInline obj)
        {
            if (renderer == null)
            {
                throw new ArgumentNullException(nameof(renderer));
            }
            if (obj == null)
            {
                throw new ArgumentNullException(nameof(obj));
            }

            renderer.WriteEscape(obj.ToLiteral());
            renderer.WriteChildren(obj);
        }
Beispiel #7
0
        protected override void Write(XamlRenderer renderer, EmphasisInline obj)
        {
            if (renderer == null)
            {
                throw new ArgumentNullException(nameof(renderer));
            }
            if (obj == null)
            {
                throw new ArgumentNullException(nameof(obj));
            }

            var tag = GetTag(obj);

            renderer.Write("<").Write(tag);
            switch (obj.DelimiterChar)
            {
            case '*':
            case '_':
                break;

            case '~':
                renderer.Write(obj.DelimiterCount == 2
                        ? " Style=\"{StaticResource {x:Static markdig:Styles.StrikeThroughStyleKey}}\""
                        : " Style=\"{StaticResource {x:Static markdig:Styles.SubscriptStyleKey}}\"");
                break;

            case '^':
                renderer.Write(" Style=\"{StaticResource {x:Static markdig:Styles.SuperscriptStyleKey}}\"");
                break;

            case '+':
                renderer.Write(" Style=\"{StaticResource {x:Static markdig:Styles.InsertedStyleKey}}\"");
                break;

            case '=':
                renderer.Write(" Style=\"{StaticResource {x:Static markdig:Styles.MarkedStyleKey}}\"");
                break;
            }
            renderer.Write(">");
            renderer.WriteChildren(obj);
            renderer.Write("</").Write(tag).Write(">");
        }
        protected override void Write(XamlRenderer renderer, QuoteBlock obj)
        {
            if (renderer == null)
            {
                throw new ArgumentNullException(nameof(renderer));
            }
            if (obj == null)
            {
                throw new ArgumentNullException(nameof(obj));
            }

            renderer.EnsureLine();

            renderer.Write("<Section");
            // Apply quote block styling
            renderer.Write(" Style=\"{StaticResource {x:Static markdig:Styles.QuoteBlockStyleKey}}\"");
            renderer.WriteLine(">");
            renderer.WriteChildren(obj);
            renderer.WriteLine("</Section>");
        }
Beispiel #9
0
        protected override void Write(XamlRenderer renderer, ListBlock listBlock)
        {
            if (renderer == null)
            {
                throw new ArgumentNullException(nameof(renderer));
            }
            if (listBlock == null)
            {
                throw new ArgumentNullException(nameof(listBlock));
            }

            renderer.EnsureLine();

            renderer.Write("<List");
            if (listBlock.IsOrdered)
            {
                renderer.Write(" MarkerStyle=\"Decimal\"");

                if (listBlock.OrderedStart != null && (listBlock.DefaultOrderedStart != listBlock.OrderedStart))
                {
                    renderer.Write(" StartIndex=\"").Write(listBlock.OrderedStart).Write("\"");
                }
            }
            else
            {
                renderer.Write(" MarkerStyle=\"Disc\"");
            }
            renderer.WriteLine(">");

            foreach (var item in listBlock)
            {
                var listItem = (ListItemBlock)item;

                renderer.EnsureLine();
                renderer.WriteLine("<ListItem>");
                renderer.WriteChildren(listItem);
                renderer.WriteLine("</ListItem>");
            }
            renderer.WriteLine("</List>");
        }
 protected override void Write([NotNull] XamlRenderer renderer, [NotNull] DelimiterInline obj)
 {
     renderer.WriteEscape(obj.ToLiteral());
     renderer.WriteChildren(obj);
 }