2021-09-19 11:04:24 -06:00
|
|
|
/*
|
|
|
|
|
* Copyright (c) 2021, Peter Elliott <pelliott@serenityos.org>
|
2022-03-04 13:21:26 -07:00
|
|
|
* Copyright (c) 2022, the SerenityOS developers.
|
2021-09-19 11:04:24 -06:00
|
|
|
*
|
|
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
2022-12-04 18:02:33 +00:00
|
|
|
#include <AK/DeprecatedString.h>
|
2021-09-19 11:04:24 -06:00
|
|
|
#include <AK/NonnullOwnPtrVector.h>
|
|
|
|
|
#include <AK/OwnPtr.h>
|
|
|
|
|
#include <LibMarkdown/Block.h>
|
2021-09-19 11:14:18 -06:00
|
|
|
#include <LibMarkdown/LineIterator.h>
|
2021-09-19 11:04:24 -06:00
|
|
|
|
|
|
|
|
namespace Markdown {
|
|
|
|
|
|
|
|
|
|
class ContainerBlock final : public Block {
|
|
|
|
|
public:
|
2021-09-28 01:12:00 -06:00
|
|
|
ContainerBlock(NonnullOwnPtrVector<Block> blocks, bool has_blank_lines, bool has_trailing_blank_lines)
|
2021-09-19 11:04:24 -06:00
|
|
|
: m_blocks(move(blocks))
|
2021-09-28 01:12:00 -06:00
|
|
|
, m_has_blank_lines(has_blank_lines)
|
|
|
|
|
, m_has_trailing_blank_lines(has_trailing_blank_lines)
|
2021-09-19 11:04:24 -06:00
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2022-03-04 13:21:26 -07:00
|
|
|
virtual ~ContainerBlock() override = default;
|
2021-09-19 11:04:24 -06:00
|
|
|
|
2022-12-04 18:02:33 +00:00
|
|
|
virtual DeprecatedString render_to_html(bool tight = false) const override;
|
2022-12-23 12:25:00 +03:00
|
|
|
virtual Vector<DeprecatedString> 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;
|
2021-09-19 11:04:24 -06:00
|
|
|
|
2021-09-19 11:14:18 -06:00
|
|
|
static OwnPtr<ContainerBlock> parse(LineIterator& lines);
|
2021-09-19 11:04:24 -06:00
|
|
|
|
2021-09-28 01:12:00 -06:00
|
|
|
bool has_blank_lines() const { return m_has_blank_lines; }
|
|
|
|
|
bool has_trailing_blank_lines() const { return m_has_trailing_blank_lines; }
|
|
|
|
|
|
|
|
|
|
NonnullOwnPtrVector<Block> const& blocks() const { return m_blocks; }
|
|
|
|
|
|
2021-09-19 11:04:24 -06:00
|
|
|
private:
|
|
|
|
|
NonnullOwnPtrVector<Block> m_blocks;
|
2021-09-28 01:12:00 -06:00
|
|
|
bool m_has_blank_lines;
|
|
|
|
|
bool m_has_trailing_blank_lines;
|
2021-09-19 11:04:24 -06:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
}
|