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>"); }
protected override void Write(XamlRenderer renderer, AutolinkInline obj) { if (renderer == null) { throw new ArgumentNullException(nameof(renderer)); } if (obj == null) { throw new ArgumentNullException(nameof(obj)); } var url = obj.Url; if (obj.IsEmail) { url = "mailto:" + url; } 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("\""); renderer.Write(">"); renderer.WriteEscapeUrl(obj.Url); renderer.WriteLine("</Hyperlink>"); }
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(">"); }
protected override void Write([NotNull] XamlRenderer renderer, [NotNull] CodeInline obj) { renderer.Write("<Run"); // Apply code styling (see also CodeBlockRenderer) renderer.Write(" Style=\"{StaticResource {x:Static markdig:Styles.CodeStyleKey}}\""); renderer.Write(" Text=\"").WriteEscape(obj.Content).Write("\""); renderer.Write(" />"); }
protected override void Write([NotNull] XamlRenderer renderer, [NotNull] AutolinkInline obj) { renderer.Write("<Hyperlink"); renderer.Write(" Command=\"{x:Static markdig:Commands.Hyperlink}\""); renderer.Write(" CommandParameter=\"").WriteEscapeUrl(obj.Url).Write("\""); renderer.Write(">"); renderer.WriteEscapeUrl(obj.Url); renderer.WriteLine("</Hyperlink>"); }
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>"); } }
protected override void Write([NotNull] XamlRenderer renderer, [NotNull] LiteralInline obj) { if (obj.Content.IsEmpty) { return; } renderer.Write("<Run"); renderer.Write(" Text=\"").WriteEscape(ref obj.Content).Write("\""); renderer.Write(" />"); }
protected override void Write([NotNull] XamlRenderer renderer, ThematicBreakBlock obj) { renderer.EnsureLine(); renderer.WriteLine("<Paragraph>"); renderer.Write("<Line X2=\"1\""); // Apply styling renderer.Write(" Style=\"{StaticResource {x:Static markdig:Styles.ThematicBreakStyleKey}}\""); renderer.WriteLine(" />"); renderer.WriteLine("</Paragraph>"); }
protected override void Write([NotNull] XamlRenderer renderer, [NotNull] CodeBlock obj) { renderer.EnsureLine(); renderer.Write("<Paragraph xml:space=\"preserve\""); // Apply code block styling renderer.Write(" Style=\"{StaticResource {x:Static markdig:Styles.CodeBlockStyleKey}}\""); renderer.WriteLine(">"); renderer.WriteLeafRawLines(obj, true, true); renderer.WriteLine("</Paragraph>"); }
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>"); }
protected override void Write([NotNull] XamlRenderer renderer, [NotNull] HeadingBlock obj) { renderer.Write("<Paragraph"); if (obj.Level > 0 && obj.Level <= 6) { // Apply style depending on heading level renderer.Write($" Style=\"{{StaticResource {{x:Static markdig:Styles.Heading{obj.Level}StyleKey}}}}\""); } renderer.WriteLine(">"); renderer.WriteLeafInline(obj); renderer.EnsureLine(); renderer.WriteLine("</Paragraph>"); }
protected override void Write(XamlRenderer renderer, CodeInline obj) { if (renderer == null) { throw new ArgumentNullException(nameof(renderer)); } if (obj == null) { throw new ArgumentNullException(nameof(obj)); } renderer.Write("<Run"); // Apply code styling (see also CodeBlockRenderer) renderer.Write(" Style=\"{StaticResource {x:Static markdig:Styles.CodeStyleKey}}\""); renderer.Write(" Text=\"").WriteEscape(obj.Content).Write("\""); renderer.Write(" />"); }
protected override void Write([NotNull] XamlRenderer renderer, [NotNull] AutolinkInline obj) { var url = obj.Url; if (obj.IsEmail) { url = "mailto:" + url; } 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("\""); renderer.Write(">"); renderer.WriteEscapeUrl(obj.Url); renderer.WriteLine("</Hyperlink>"); }
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(XamlRenderer renderer, ThematicBreakBlock obj) { if (renderer == null) { throw new ArgumentNullException(nameof(renderer)); } if (obj == null) { throw new ArgumentNullException(nameof(obj)); } renderer.EnsureLine(); renderer.WriteLine("<Paragraph>"); renderer.Write("<Line X2=\"1\""); // Apply styling renderer.Write(" Style=\"{StaticResource {x:Static markdig:Styles.ThematicBreakStyleKey}}\""); renderer.WriteLine(" />"); renderer.WriteLine("</Paragraph>"); }
protected override void Write(XamlRenderer renderer, CodeBlock obj) { if (renderer == null) { throw new ArgumentNullException(nameof(renderer)); } if (obj == null) { throw new ArgumentNullException(nameof(obj)); } renderer.EnsureLine(); renderer.Write("<Paragraph xml:space=\"preserve\""); // Apply code block styling renderer.Write(" Style=\"{StaticResource {x:Static markdig:Styles.CodeBlockStyleKey}}\""); renderer.WriteLine(">"); renderer.WriteLeafRawLines(obj, true, true); renderer.WriteLine("</Paragraph>"); }
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>"); }
protected override void Write(XamlRenderer renderer, LiteralInline obj) { if (renderer == null) { throw new ArgumentNullException(nameof(renderer)); } if (obj == null) { throw new ArgumentNullException(nameof(obj)); } if (obj.Content.IsEmpty) { return; } renderer.Write("<Run"); renderer.Write(" Text=\"").WriteEscape(ref obj.Content).Write("\""); renderer.Write(" />"); }
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(XamlRenderer renderer, HeadingBlock obj) { if (renderer == null) { throw new ArgumentNullException(nameof(renderer)); } if (obj == null) { throw new ArgumentNullException(nameof(obj)); } renderer.Write("<Paragraph"); if (obj.Level > 0 && obj.Level <= 6) { // Apply style depending on heading level renderer.Write($" Style=\"{{StaticResource {{x:Static markdig:Styles.Heading{obj.Level}StyleKey}}}}\""); } renderer.WriteLine(">"); renderer.WriteLeafInline(obj); renderer.EnsureLine(); renderer.WriteLine("</Paragraph>"); }
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(">"); }