List.h 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  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/ContainerBlock.h>
  10. #include <LibMarkdown/LineIterator.h>
  11. namespace Markdown {
  12. class List final : public Block {
  13. public:
  14. List(Vector<OwnPtr<ContainerBlock>> items, bool is_ordered, bool is_tight, size_t start_number)
  15. : m_items(move(items))
  16. , m_is_ordered(is_ordered)
  17. , m_is_tight(is_tight)
  18. , m_start_number(start_number)
  19. {
  20. }
  21. virtual ~List() override { }
  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<List> parse(LineIterator& lines);
  26. private:
  27. Vector<OwnPtr<ContainerBlock>> m_items;
  28. bool m_is_ordered { false };
  29. bool m_is_tight { false };
  30. size_t m_start_number { 1 };
  31. };
  32. }