Added custom url builder for wikilink extension

This commit is contained in:
Kyler Olsen 2025-10-26 23:55:34 -06:00
parent 8cbc3e60eb
commit e337b5675f
2 changed files with 6 additions and 1 deletions

1
.gitignore vendored
View File

@ -1,3 +1,4 @@
www/
__pycache__/
prependnewline.py
*.tar

View File

@ -5,10 +5,14 @@ from markdown.extensions.wikilinks import WikiLinkExtension
SOURCE_DIR = Path("docs") # input folder
OUTPUT_DIR = Path("www") # output folder
def my_url_builder(label, base, end):
url = (base + label + end).lower().replace(' ', '_')
return url
def convert_markdown_to_html(md_path: Path, html_path: Path):
html_path.parent.mkdir(parents=True, exist_ok=True)
html = markdown.markdown(md_path.read_text(encoding="utf-8"), extensions=[
WikiLinkExtension(base_url='./', end_url='.html'),
WikiLinkExtension(base_url='./', end_url='.html', build_url=my_url_builder),
'tables',
'fenced_code',
'sane_lists',