Serenity Operating System
at master 44 lines 1.4 kB view raw
1/* 2 * Copyright (c) 2019-2020, Sergey Bugaev <bugaevc@serenityos.org> 3 * Copyright (c) 2022, the SerenityOS developers. 4 * 5 * SPDX-License-Identifier: BSD-2-Clause 6 */ 7 8#pragma once 9 10#include <AK/OwnPtr.h> 11#include <LibMarkdown/Block.h> 12#include <LibMarkdown/Heading.h> 13#include <LibMarkdown/LineIterator.h> 14#include <LibMarkdown/Text.h> 15 16namespace Markdown { 17 18class CodeBlock final : public Block { 19public: 20 CodeBlock(DeprecatedString const& language, DeprecatedString const& style, DeprecatedString const& code, Heading* current_section) 21 : m_code(move(code)) 22 , m_language(language) 23 , m_style(style) 24 , m_current_section(current_section) 25 { 26 } 27 virtual ~CodeBlock() override = default; 28 29 virtual DeprecatedString render_to_html(bool tight = false) const override; 30 virtual Vector<DeprecatedString> render_lines_for_terminal(size_t view_width = 0) const override; 31 virtual RecursionDecision walk(Visitor&) const override; 32 static OwnPtr<CodeBlock> parse(LineIterator& lines, Heading* current_section); 33 34private: 35 DeprecatedString m_code; 36 DeprecatedString m_language; 37 DeprecatedString m_style; 38 Heading* m_current_section; 39 40 static OwnPtr<CodeBlock> parse_backticks(LineIterator& lines, Heading* current_section); 41 static OwnPtr<CodeBlock> parse_indent(LineIterator& lines); 42}; 43 44}