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