List.h 813 B

123456789101112131415161718192021222324252627282930313233343536
  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 <AK/Vector.h>
  9. #include <LibMarkdown/Block.h>
  10. #include <LibMarkdown/Text.h>
  11. namespace Markdown {
  12. class List final : public Block {
  13. public:
  14. List(Vector<Text>&& text, bool is_ordered)
  15. : m_items(move(text))
  16. , m_is_ordered(is_ordered)
  17. {
  18. }
  19. virtual ~List() 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<List> parse(Vector<StringView>::ConstIterator& lines);
  23. private:
  24. // TODO: List items should be considered blocks of their own kind.
  25. Vector<Text> m_items;
  26. bool m_is_ordered { false };
  27. };
  28. }