/// <summary> /// Parses a quote block. /// </summary> /// <param name="markdown"> The markdown text. </param> /// <param name="startOfLine"> The location of the start of the line. </param> /// <param name="maxEnd"> The location to stop parsing. </param> /// <param name="quoteDepth"> The current nesting level of quotes. </param> /// <param name="actualEnd"> Set to the end of the block when the return value is non-null. </param> /// <returns> A parsed quote block. </returns> internal static QuoteBlock Parse(string markdown, int startOfLine, int maxEnd, int quoteDepth, out int actualEnd) { var result = new QuoteBlock(); // Recursively call into the markdown block parser. result.Blocks = MarkdownDocument.Parse(markdown, startOfLine, maxEnd, quoteDepth: quoteDepth + 1, actualEnd: out actualEnd); return result; }
/// <summary> /// Parses a quote block. /// </summary> /// <param name="markdown"> The markdown text. </param> /// <param name="startOfLine"> The location of the start of the line. </param> /// <param name="maxEnd"> The location to stop parsing. </param> /// <param name="quoteDepth"> The current nesting level of quotes. </param> /// <param name="actualEnd"> Set to the end of the block when the return value is non-null. </param> /// <returns> A parsed quote block. </returns> internal static QuoteBlock Parse(string markdown, int startOfLine, int maxEnd, int quoteDepth, out int actualEnd) { var result = new QuoteBlock(); // Recursively call into the markdown block parser. result.Blocks = MarkdownDocument.Parse(markdown, startOfLine, maxEnd, quoteDepth: quoteDepth + 1, actualEnd: out actualEnd); return(result); }
/// <summary> /// Renders a quote element. /// </summary> /// <param name="element"></param> /// <param name="blockUIElementCollection"></param> private void RenderQuote(QuoteBlock element, UIElementCollection blockUIElementCollection, RenderContext context) { if (QuoteForeground != null) { context = context.Clone(); context.Foreground = QuoteForeground; } var stackPanel = new StackPanel(); RenderBlocks(element.Blocks, stackPanel.Children, context); var border = new Border(); border.Margin = QuoteMargin; border.Background = QuoteBackground; border.BorderBrush = QuoteBorderBrush ?? context.Foreground; border.BorderThickness = QuoteBorderThickness; border.Padding = QuotePadding; border.Child = stackPanel; blockUIElementCollection.Add(border); }
/// <summary> /// Renders a quote element. /// </summary> /// <param name="element"></param> /// <param name="currentBlocks"></param> private void RenderQuote(QuoteBlock element, BlockCollection currentBlocks) { // Make the new quote paragraph Paragraph quotePara = new Paragraph(); quotePara.Margin = new Thickness(element.QuoteIndent * 12, 12, 12, 12); quotePara.Foreground = new SolidColorBrush(Color.FromArgb(180, 255, 255, 255)); // Add it to the blocks currentBlocks.Add(quotePara); // Render the children into the para inline. bool trimTextStart = true; RenderInlineChildren(element, quotePara.Inlines, ref trimTextStart); }