mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 00:47:45 +00:00
Utilities: Allow link checking in markdown-check to fail during visit
With a special flag, we can now invalidate the links early on.
This commit is contained in:
parent
112642a262
commit
9902e71f99
1 changed files with 8 additions and 0 deletions
|
@ -71,6 +71,7 @@ public:
|
||||||
|
|
||||||
bool has_anchor(String const& anchor) const { return m_anchors.contains(anchor); }
|
bool has_anchor(String const& anchor) const { return m_anchors.contains(anchor); }
|
||||||
HashTable<String> const& anchors() const { return m_anchors; }
|
HashTable<String> const& anchors() const { return m_anchors; }
|
||||||
|
bool has_invalid_link() const { return m_has_invalid_link; }
|
||||||
Vector<FileLink> const& file_links() const { return m_file_links; }
|
Vector<FileLink> const& file_links() const { return m_file_links; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -81,6 +82,7 @@ private:
|
||||||
|
|
||||||
HashTable<String> m_anchors;
|
HashTable<String> m_anchors;
|
||||||
Vector<FileLink> m_file_links;
|
Vector<FileLink> m_file_links;
|
||||||
|
bool m_has_invalid_link { false };
|
||||||
};
|
};
|
||||||
|
|
||||||
MarkdownLinkage MarkdownLinkage::analyze(Markdown::Document const& document)
|
MarkdownLinkage MarkdownLinkage::analyze(Markdown::Document const& document)
|
||||||
|
@ -231,6 +233,12 @@ int main(int argc, char** argv)
|
||||||
outln("Checking links ...");
|
outln("Checking links ...");
|
||||||
bool any_problems = false;
|
bool any_problems = false;
|
||||||
for (auto const& file_item : files) {
|
for (auto const& file_item : files) {
|
||||||
|
if (file_item.value.has_invalid_link()) {
|
||||||
|
outln("File '{}' has invalid links.", file_item.key);
|
||||||
|
any_problems = true;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
auto file_lexical_path = LexicalPath(file_item.key);
|
auto file_lexical_path = LexicalPath(file_item.key);
|
||||||
auto file_dir = file_lexical_path.dirname();
|
auto file_dir = file_lexical_path.dirname();
|
||||||
for (auto const& file_link : file_item.value.file_links()) {
|
for (auto const& file_link : file_item.value.file_links()) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue