/// <summary> /// Renders a quote element. /// </summary> protected override void RenderQuote(QuoteBlock element, IRenderContext context) { if (!(context is BlockCollectionRenderContext localContext)) { throw new RenderContextIncorrectException(); } var blockCollection = localContext.BlockCollection; var section = new Section { Margin = QuoteMargin, Background = QuoteBackground, BorderThickness = QuoteBorderThickness, Padding = QuotePadding, }; var childContext = new BlockCollectionRenderContext(section.Blocks, context) { Parent = section }; if (QuoteForeground != null && !localContext.OverrideForeground) { childContext.Foreground = QuoteForeground; } RenderBlocks(element.Blocks, childContext); section.BorderBrush = childContext.OverrideForeground ? childContext.Foreground : QuoteBorderBrush ?? childContext.Foreground; blockCollection.Add(section); }
/// <summary> /// Renders a list element. /// </summary> protected override void RenderListElement(ListBlock element, IRenderContext context) { if (!(context is BlockCollectionRenderContext localContext)) { throw new RenderContextIncorrectException(); } var blockCollection = localContext.BlockCollection; var list = new List { MarkerOffset = ListBulletSpacing, Margin = ListMargin, Foreground = localContext.Foreground }; list.MarkerStyle = element.Style switch { ListStyle.Bulleted => TextMarkerStyle.Disc, ListStyle.Numbered => TextMarkerStyle.Decimal, _ => TextMarkerStyle.Disc }; for (int rowIndex = 0; rowIndex < element.Items.Count; rowIndex++) { var listItemblock = element.Items[rowIndex]; var content = new ListItem(); var childContext = new BlockCollectionRenderContext(content.Blocks, localContext); RenderBlocks(listItemblock.Blocks, childContext); list.ListItems.Add(content); } blockCollection.Add(list); }