List.h 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  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/ContainerBlock.h>
  11. #include <LibMarkdown/LineIterator.h>
  12. namespace Markdown {
  13. class List final : public Block {
  14. public:
  15. List(Vector<OwnPtr<ContainerBlock>> items, bool is_ordered, bool is_tight, size_t start_number)
  16. : m_items(move(items))
  17. , m_is_ordered(is_ordered)
  18. , m_is_tight(is_tight)
  19. , m_start_number(start_number)
  20. {
  21. }
  22. virtual ~List() override = default;
  23. virtual ByteString render_to_html(bool tight = false) const override;
  24. virtual Vector<ByteString> render_lines_for_terminal(size_t view_width = 0) const override;
  25. virtual RecursionDecision walk(Visitor&) const override;
  26. static OwnPtr<List> parse(LineIterator& lines);
  27. private:
  28. Vector<OwnPtr<ContainerBlock>> m_items;
  29. bool m_is_ordered { false };
  30. bool m_is_tight { false };
  31. size_t m_start_number { 1 };
  32. };
  33. }