mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 22:57:44 +00:00
LibMarkdown: Implement introspection of the document tree
This commit is contained in:
parent
aca01932bd
commit
24e7196158
23 changed files with 319 additions and 0 deletions
|
@ -12,6 +12,7 @@
|
|||
#include <LibMarkdown/List.h>
|
||||
#include <LibMarkdown/Paragraph.h>
|
||||
#include <LibMarkdown/Table.h>
|
||||
#include <LibMarkdown/Visitor.h>
|
||||
|
||||
namespace Markdown {
|
||||
|
||||
|
@ -50,6 +51,21 @@ String ContainerBlock::render_for_terminal(size_t view_width) const
|
|||
return builder.build();
|
||||
}
|
||||
|
||||
RecursionDecision ContainerBlock::walk(Visitor& visitor) const
|
||||
{
|
||||
RecursionDecision rd = visitor.visit(*this);
|
||||
if (rd != RecursionDecision::Recurse)
|
||||
return rd;
|
||||
|
||||
for (auto const& block : m_blocks) {
|
||||
rd = block.walk(visitor);
|
||||
if (rd == RecursionDecision::Break)
|
||||
return rd;
|
||||
}
|
||||
|
||||
return RecursionDecision::Continue;
|
||||
}
|
||||
|
||||
template<typename BlockType>
|
||||
static bool try_parse_block(LineIterator& lines, NonnullOwnPtrVector<Block>& blocks)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue