mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 01:07:36 +00:00
Utilities: Add basic Package manager skeleton utility
This commit is contained in:
parent
22737b70bc
commit
ccaa423372
9 changed files with 473 additions and 0 deletions
41
Userland/Utilities/pkg/MarkdownTableFinder.h
Normal file
41
Userland/Utilities/pkg/MarkdownTableFinder.h
Normal file
|
@ -0,0 +1,41 @@
|
|||
/*
|
||||
* Copyright (c) 2023, Liav A. <liavalb@hotmail.co.il>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <AK/String.h>
|
||||
#include <AK/StringView.h>
|
||||
#include <AK/Types.h>
|
||||
#include <LibMarkdown/Document.h>
|
||||
#include <LibMarkdown/Visitor.h>
|
||||
|
||||
class MarkdownTableFinder final : Markdown::Visitor {
|
||||
public:
|
||||
~MarkdownTableFinder() = default;
|
||||
|
||||
static MarkdownTableFinder analyze(Markdown::Document const& document)
|
||||
{
|
||||
MarkdownTableFinder finder;
|
||||
document.walk(finder);
|
||||
return finder;
|
||||
}
|
||||
|
||||
size_t table_count() const { return m_tables.size(); }
|
||||
Vector<Markdown::Table const*> const& tables() const { return m_tables; }
|
||||
|
||||
private:
|
||||
MarkdownTableFinder() { }
|
||||
|
||||
virtual RecursionDecision visit(Markdown::Table const& table) override
|
||||
{
|
||||
if (m_tables.size() >= 1)
|
||||
return RecursionDecision::Break;
|
||||
m_tables.append(&table);
|
||||
return RecursionDecision::Recurse;
|
||||
}
|
||||
|
||||
Vector<Markdown::Table const*> m_tables;
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue