2020-01-18 09:38:21 +01:00
|
|
|
/*
|
2020-01-24 16:45:29 +03:00
|
|
|
* Copyright (c) 2019-2020, Sergey Bugaev <bugaevc@serenityos.org>
|
2022-03-04 13:21:26 -07:00
|
|
|
* Copyright (c) 2022, the SerenityOS developers.
|
2020-01-18 09:38:21 +01:00
|
|
|
*
|
2021-04-22 01:24:48 -07:00
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
2020-01-18 09:38:21 +01:00
|
|
|
*/
|
|
|
|
|
|
2019-09-21 00:46:18 +03:00
|
|
|
#pragma once
|
|
|
|
|
|
2020-05-18 16:58:00 -04:00
|
|
|
#include <AK/OwnPtr.h>
|
2020-04-28 21:04:25 +02:00
|
|
|
#include <LibMarkdown/Block.h>
|
2021-09-26 20:14:58 -06:00
|
|
|
#include <LibMarkdown/ContainerBlock.h>
|
2021-09-19 11:14:18 -06:00
|
|
|
#include <LibMarkdown/LineIterator.h>
|
2019-09-21 00:46:18 +03:00
|
|
|
|
2020-04-28 21:04:25 +02:00
|
|
|
namespace Markdown {
|
|
|
|
|
|
|
|
|
|
class List final : public Block {
|
2019-09-21 00:46:18 +03:00
|
|
|
public:
|
2021-09-29 23:19:56 -06:00
|
|
|
List(Vector<OwnPtr<ContainerBlock>> items, bool is_ordered, bool is_tight, size_t start_number)
|
2021-09-26 20:14:58 -06:00
|
|
|
: m_items(move(items))
|
2020-05-18 16:58:00 -04:00
|
|
|
, m_is_ordered(is_ordered)
|
2021-09-28 01:12:00 -06:00
|
|
|
, m_is_tight(is_tight)
|
2021-09-29 23:19:56 -06:00
|
|
|
, m_start_number(start_number)
|
2020-05-18 16:58:00 -04:00
|
|
|
{
|
|
|
|
|
}
|
2022-03-04 13:21:26 -07:00
|
|
|
virtual ~List() override = default;
|
2019-09-21 00:46:18 +03:00
|
|
|
|
2023-12-16 17:49:34 +03:30
|
|
|
virtual ByteString render_to_html(bool tight = false) const override;
|
|
|
|
|
virtual Vector<ByteString> render_lines_for_terminal(size_t view_width = 0) const override;
|
2021-09-10 21:36:29 +02:00
|
|
|
virtual RecursionDecision walk(Visitor&) const override;
|
2020-05-18 16:58:00 -04:00
|
|
|
|
2021-09-19 11:14:18 -06:00
|
|
|
static OwnPtr<List> parse(LineIterator& lines);
|
2019-09-21 00:46:18 +03:00
|
|
|
|
|
|
|
|
private:
|
2021-09-26 20:14:58 -06:00
|
|
|
Vector<OwnPtr<ContainerBlock>> m_items;
|
2019-09-21 00:46:18 +03:00
|
|
|
bool m_is_ordered { false };
|
2021-09-28 01:12:00 -06:00
|
|
|
bool m_is_tight { false };
|
2021-09-29 23:19:56 -06:00
|
|
|
size_t m_start_number { 1 };
|
2019-09-21 00:46:18 +03:00
|
|
|
};
|
2020-04-28 21:04:25 +02:00
|
|
|
|
|
|
|
|
}
|