コード例 #1
0
        protected override void Write(VT100Renderer renderer, FencedCodeBlock obj)
        {
            if (obj?.Lines.Lines != null)
            {
                foreach (StringLine codeLine in obj.Lines.Lines)
                {
                    if (!string.IsNullOrWhiteSpace(codeLine.ToString()))
                    {
                        // If the code block is of type YAML, then tab to right to improve readability.
                        // This specifically helps for parameters help content.
                        if (string.Equals(obj.Info, "yaml", StringComparison.OrdinalIgnoreCase))
                        {
                            renderer.Write("\t").WriteLine(codeLine.ToString());
                        }
                        else
                        {
                            renderer.WriteLine(renderer.EscapeSequences.FormatCode(codeLine.ToString(), isInline: false));
                        }
                    }
                }

                // Add a blank line after the code block for better readability.
                renderer.WriteLine();
            }
        }
コード例 #2
0
        protected override void Write(VT100Renderer renderer, ParagraphBlock obj)
        {
            // Call the renderer for children, leaf inline or line breaks.
            renderer.WriteChildren(obj.Inline);

            // Add new line at the end of the paragraph.
            renderer.WriteLine();
        }
コード例 #3
0
        protected override void Write(VT100Renderer renderer, QuoteBlock obj)
        {
            // Iterate through each item and add the quote character before the content.
            foreach (var item in obj)
            {
                renderer.Write(obj.QuoteChar).Write(" ").Write(item);
            }

            // Add blank line after the quote block.
            renderer.WriteLine();
        }
コード例 #4
0
 protected override void Write(VT100Renderer renderer, LineBreakInline obj)
 {
     // If it is a hard line break add new line at the end.
     // Else, add a space for after the last character to improve readability.
     if (obj.IsHard)
     {
         renderer.WriteLine();
     }
     else
     {
         renderer.Write(" ");
     }
 }
コード例 #5
0
 protected override void Write(VT100Renderer renderer, LeafInline obj)
 {
     // If the next sibling is null, then this is the last line in the paragraph.
     // Add new line character at the end.
     // Else just write without newline at the end.
     if (obj.NextSibling == null)
     {
         renderer.WriteLine(obj.ToString());
     }
     else
     {
         renderer.Write(obj.ToString());
     }
 }
コード例 #6
0
        protected override void Write(VT100Renderer renderer, ListBlock obj)
        {
            // start index of a numbered block.
            int index = 1;

            foreach (var item in obj)
            {
                if (item is ListItemBlock listItem)
                {
                    if (obj.IsOrdered)
                    {
                        RenderNumberedList(renderer, listItem, index++);
                    }
                    else
                    {
                        renderer.Write(listItem);
                    }
                }
            }

            renderer.WriteLine();
        }
コード例 #7
0
        protected override void Write(VT100Renderer renderer, HeadingBlock obj)
        {
            // Format header and then add blank line to improve readability.
            switch (obj.Level)
            {
            case 1:
                renderer.WriteLine(renderer.EscapeSequences.FormatHeader1(obj.Inline.FirstChild.ToString()));
                renderer.WriteLine();
                break;

            case 2:
                renderer.WriteLine(renderer.EscapeSequences.FormatHeader2(obj.Inline.FirstChild.ToString()));
                renderer.WriteLine();
                break;

            case 3:
                renderer.WriteLine(renderer.EscapeSequences.FormatHeader3(obj.Inline.FirstChild.ToString()));
                renderer.WriteLine();
                break;

            case 4:
                renderer.WriteLine(renderer.EscapeSequences.FormatHeader4(obj.Inline.FirstChild.ToString()));
                renderer.WriteLine();
                break;

            case 5:
                renderer.WriteLine(renderer.EscapeSequences.FormatHeader5(obj.Inline.FirstChild.ToString()));
                renderer.WriteLine();
                break;

            case 6:
                renderer.WriteLine(renderer.EscapeSequences.FormatHeader6(obj.Inline.FirstChild.ToString()));
                renderer.WriteLine();
                break;
            }
        }
コード例 #8
0
        protected override void Write(VT100Renderer renderer, HeadingBlock obj)
        {
            string headerText = obj?.Inline?.FirstChild?.ToString();

            if (!string.IsNullOrEmpty(headerText))
            {
                // Format header and then add blank line to improve readability.
                switch (obj.Level)
                {
                case 1:
                    renderer.WriteLine(renderer.EscapeSequences.FormatHeader1(headerText));
                    renderer.WriteLine();
                    break;

                case 2:
                    renderer.WriteLine(renderer.EscapeSequences.FormatHeader2(headerText));
                    renderer.WriteLine();
                    break;

                case 3:
                    renderer.WriteLine(renderer.EscapeSequences.FormatHeader3(headerText));
                    renderer.WriteLine();
                    break;

                case 4:
                    renderer.WriteLine(renderer.EscapeSequences.FormatHeader4(headerText));
                    renderer.WriteLine();
                    break;

                case 5:
                    renderer.WriteLine(renderer.EscapeSequences.FormatHeader5(headerText));
                    renderer.WriteLine();
                    break;

                case 6:
                    renderer.WriteLine(renderer.EscapeSequences.FormatHeader6(headerText));
                    renderer.WriteLine();
                    break;
                }
            }
        }