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([NotNull] XamlRenderer renderer, ParagraphBlock obj) { if (!renderer.IsFirstInContainer) { renderer.EnsureLine(); } renderer.WriteLine("<Paragraph>"); renderer.WriteLeafInline(obj); renderer.EnsureLine(); renderer.WriteLine("</Paragraph>"); }
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] 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(XamlRenderer renderer, ParagraphBlock obj) { if (renderer == null) { throw new ArgumentNullException(nameof(renderer)); } if (obj == null) { throw new ArgumentNullException(nameof(obj)); } if (!renderer.IsFirstInContainer) { renderer.EnsureLine(); } renderer.WriteLine("<Paragraph>"); renderer.WriteLeafInline(obj); renderer.EnsureLine(); renderer.WriteLine("</Paragraph>"); }
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(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] 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, 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, 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, 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, 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>"); }