-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Deployed 5e76a13 with MkDocs version: 1.6.0
- Loading branch information
0 parents
commit 812f6ed
Showing
83 changed files
with
14,551 additions
and
0 deletions.
There are no files selected for viewing
Empty file.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
from markdown_it.tree import SyntaxTreeNode | ||
from markdown_it import MarkdownIt | ||
|
||
import os | ||
import fnmatch | ||
import click | ||
|
||
@click.command() | ||
@click.argument('dir', required=True) | ||
def parse_markdown_files(dir): | ||
all_href = get_all_hrefs(dir) | ||
with open(f"{dir}/appendixes/appendix-links.md", "w") as appendix: | ||
appendix.write("""<!-- this file is generated by toolings --> | ||
# Appendix "All links" | ||
This is a collection of all the links from this website: | ||
""" | ||
) | ||
for e in all_href: | ||
appendix.write(f"- {e}\n") | ||
appendix.write("\n") | ||
|
||
def get_all_hrefs(dir): | ||
md = MarkdownIt("commonmark") | ||
all_href = [] | ||
for root, _, files in os.walk(dir): | ||
for filename in fnmatch.filter(files, '*.md'): | ||
if filename == "appendix-links.md": | ||
continue # skip appendix-links file itself | ||
with open(f"{root}/{filename}", "r") as f: | ||
tokens = md.parse(f.read()) | ||
node = SyntaxTreeNode(tokens) | ||
for n in node.walk(): | ||
if n.type == "link": | ||
all_href.append(n.attrs["href"]) | ||
all_href.sort() | ||
print(all_href) | ||
return all_href | ||
|
||
if __name__ == '__main__': | ||
parse_markdown_files() |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.