CodeBlock.h 788 B

1234567891011121314151617181920212223242526272829303132333435
  1. /*
  2. * Copyright (c) 2019-2020, Sergey Bugaev <bugaevc@serenityos.org>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #pragma once
  7. #include <AK/OwnPtr.h>
  8. #include <LibMarkdown/Block.h>
  9. #include <LibMarkdown/Text.h>
  10. namespace Markdown {
  11. class CodeBlock final : public Block {
  12. public:
  13. CodeBlock(String const& language, String const& style, String const& code)
  14. : m_code(move(code))
  15. , m_language(language)
  16. , m_style(style)
  17. {
  18. }
  19. virtual ~CodeBlock() override { }
  20. virtual String render_to_html() const override;
  21. virtual String render_for_terminal(size_t view_width = 0) const override;
  22. static OwnPtr<CodeBlock> parse(Vector<StringView>::ConstIterator& lines);
  23. private:
  24. String m_code;
  25. String m_language;
  26. String m_style;
  27. };
  28. }