mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 06:57:46 +00:00
LibMarkdown: Refactor Document's parser into ContainerBlock
This will better allow us too do things like have Lists and blockquotes support multiple blocks.
This commit is contained in:
parent
4fa5748093
commit
cd560d3ae3
5 changed files with 143 additions and 71 deletions
34
Userland/Libraries/LibMarkdown/ContainerBlock.h
Normal file
34
Userland/Libraries/LibMarkdown/ContainerBlock.h
Normal file
|
@ -0,0 +1,34 @@
|
|||
/*
|
||||
* Copyright (c) 2021, Peter Elliott <pelliott@serenityos.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <AK/NonnullOwnPtrVector.h>
|
||||
#include <AK/OwnPtr.h>
|
||||
#include <AK/String.h>
|
||||
#include <LibMarkdown/Block.h>
|
||||
|
||||
namespace Markdown {
|
||||
|
||||
class ContainerBlock final : public Block {
|
||||
public:
|
||||
ContainerBlock(NonnullOwnPtrVector<Block> blocks)
|
||||
: m_blocks(move(blocks))
|
||||
{
|
||||
}
|
||||
|
||||
virtual ~ContainerBlock() override { }
|
||||
|
||||
virtual String render_to_html() const override;
|
||||
virtual String render_for_terminal(size_t view_width = 0) const override;
|
||||
|
||||
static OwnPtr<ContainerBlock> parse(Vector<StringView>::ConstIterator& lines);
|
||||
|
||||
private:
|
||||
NonnullOwnPtrVector<Block> m_blocks;
|
||||
};
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue