CodeBlock.h 941 B

1234567891011121314151617181920212223242526272829303132333435363738
  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. #pragma once
  8. #include <AK/OwnPtr.h>
  9. #include <LibMarkdown/Block.h>
  10. #include <LibMarkdown/LineIterator.h>
  11. #include <LibMarkdown/Text.h>
  12. namespace Markdown {
  13. class CodeBlock final : public Block {
  14. public:
  15. CodeBlock(String const& language, String const& style, String const& code)
  16. : m_code(move(code))
  17. , m_language(language)
  18. , m_style(style)
  19. {
  20. }
  21. virtual ~CodeBlock() override = default;
  22. virtual String render_to_html(bool tight = false) const override;
  23. virtual String render_for_terminal(size_t view_width = 0) const override;
  24. virtual RecursionDecision walk(Visitor&) const override;
  25. static OwnPtr<CodeBlock> parse(LineIterator& lines);
  26. private:
  27. String m_code;
  28. String m_language;
  29. String m_style;
  30. };
  31. }