public void Visit()

in sources/Google.Solutions.Mvvm/Controls/MarkdownViewer.cs [319:445]


            public void Visit(MarkdownDocument.Node node)
            {
                if (node is MarkdownDocument.HeadingNode heading)
                {
                    StartParagraph(
                        FontSizeForHeading(heading),
                        this.colorTable.TextIndex,
                        this.layoutTable.SpaceBeforeParagraph,
                        this.layoutTable.SpaceAfterParagraph);
                    this.writer.SetBold(true);
                    this.writer.Text(heading.Text);
                    this.writer.SetBold(false);
                    EndParagraph();
                }
                else if (node is MarkdownDocument.TextNode text)
                {
                    ContinueParagraph();
                    this.writer.Text(text.Text);
                }

                else if (node is MarkdownDocument.LinkNode link)
                {
                    ContinueParagraph();
                    this.writer.StartHyperlink(link.Href);
                    this.writer.SetUnderline(true);
                    this.writer.SetFontColor(this.colorTable.LinkIndex);
                    Visit(link.Children);
                    this.writer.SetFontColor();
                    this.writer.SetUnderline(false);
                    this.writer.EndHyperlink();
                }
                else if (node is MarkdownDocument.EmphasisNode emph)
                {
                    ContinueParagraph();
                    if (emph.IsCode)
                    {
                        this.writer.SetHighlightColor(this.colorTable.CodeIndex);
                        this.writer.SetFont(this.fontTable.CodeIndex);
                        this.writer.Text(emph.Text);
                        this.writer.SetFont();
                        this.writer.SetHighlightColor();
                    }
                    else if (emph.IsStrong)
                    {
                        this.writer.SetBold(true);
                        this.writer.Text(emph.Text);
                        this.writer.SetBold(false);
                    }
                    else
                    {
                        this.writer.SetItalic(true);
                        this.writer.Text(emph.Text);
                        this.writer.SetItalic(false);
                    }
                }
                else if (node is MarkdownDocument.ParagraphBreak)
                {
                    EndParagraph();
                }
                else if (node is MarkdownDocument.UnorderedListItemNode ul)
                {
                    using (var block = new NodeVisitor(
                        this.layoutTable,
                        this.fontTable,
                        this.colorTable,
                        this.writer,
                        this.indentationLevel + 1))
                    {
                        block.StartParagraph(
                            this.fontTable.FontSize,
                            this.colorTable.TextIndex,
                            this.layoutTable.SpaceBeforeListItem,
                            this.layoutTable.SpaceAfterListItem);
                        this.writer.UnorderedListItem(
                            FirstLineIndent,
                            (int)block.indentationLevel * BlockIndent,
                            this.fontTable.SymbolsIndex);
                        block.Visit(ul.Children);
                        block.EndParagraph();
                    }
                }
                else if (node is MarkdownDocument.OrderedListItemNode ol)
                {
                    using (var block = new NodeVisitor(
                        this.layoutTable,
                        this.fontTable,
                        this.colorTable,
                        this.writer,
                        this.indentationLevel + 1))
                    {
                        block.StartParagraph(
                            this.fontTable.FontSize,
                            this.colorTable.TextIndex,
                            this.layoutTable.SpaceBeforeListItem,
                            this.layoutTable.SpaceAfterListItem);
                        this.writer.OrderedListItem(
                            FirstLineIndent,
                            (int)block.indentationLevel * BlockIndent,
                            block.nextListItemNumber++);
                        block.Visit(ol.Children);
                        block.EndParagraph();
                    }
                }
                else if (node is MarkdownDocument.DocumentNode)
                {
                    this.writer.StartDocument();
                    this.writer.FontTable(this.fontTable.GetTable());
                    this.writer.ColorTable(this.colorTable.GetTable());
                    Visit(node.Children);

                    //
                    // Add an empty paragraph to prevent "hanging" list items.
                    //
                    StartParagraph();
                    EndParagraph();
                    this.writer.EndDocument();
                }
                else
                {
                    if (!(node is MarkdownDocument.OrderedListItemNode))
                    {
                        this.nextListItemNumber = 1; // Reset
                    }

                    Visit(node.Children);
                }
            }