protected override MarkdownNode VisitFormatting(FormattingNode formatting)
    {
        var(tagOpen, tagClose) = formatting.Kind switch
        {
            FormattingKind.Bold => (
                "<strong>",
                "</strong>"
                ),

            FormattingKind.Italic => (
                "<em>",
                "</em>"
                ),

            FormattingKind.Underline => (
                "<u>",
                "</u>"
                ),

            FormattingKind.Strikethrough => (
                "<s>",
                "</s>"
                ),

            FormattingKind.Spoiler => (
                "<span class=\"chatlog__markdown-spoiler chatlog__markdown-spoiler--hidden\" onclick=\"showSpoiler(event, this)\">",
                "</span>"
                ),

            FormattingKind.Quote => (
                "<div class=\"chatlog__markdown-quote\"><div class=\"chatlog__markdown-quote-border\"></div><div class=\"chatlog__markdown-quote-content\">",
                "</div></div>"
                ),

            _ => throw new InvalidOperationException($"Unknown formatting kind '{formatting.Kind}'.")
        };

        _buffer.Append(tagOpen);
        var result = base.VisitFormatting(formatting);

        _buffer.Append(tagClose);

        return(result);
    }
Example #2
0
    protected override MarkdownNode VisitFormatting(FormattingNode formatting)
    {
        var(tagOpen, tagClose) = formatting.Kind switch
        {
            FormattingKind.Bold => ("<strong>", "</strong>"),
            FormattingKind.Italic => ("<em>", "</em>"),
            FormattingKind.Underline => ("<u>", "</u>"),
            FormattingKind.Strikethrough => ("<s>", "</s>"),
            FormattingKind.Spoiler => (
                "<span class=\"spoiler-text spoiler-text--hidden\" onclick=\"showSpoiler(event, this)\">", "</span>"),
            FormattingKind.Quote => ("<div class=\"quote\">", "</div>"),
            _ => throw new ArgumentOutOfRangeException(nameof(formatting.Kind))
        };

        _buffer.Append(tagOpen);
        var result = base.VisitFormatting(formatting);

        _buffer.Append(tagClose);

        return(result);
    }
 protected virtual MarkdownNode VisitFormatting(FormattingNode formatting)
 {
     Visit(formatting.Children);
     return(formatting);
 }