Added custom url builder for wikilink extension
This commit is contained in:
parent
8cbc3e60eb
commit
e337b5675f
|
|
@ -1,3 +1,4 @@
|
||||||
www/
|
www/
|
||||||
__pycache__/
|
__pycache__/
|
||||||
prependnewline.py
|
prependnewline.py
|
||||||
|
*.tar
|
||||||
|
|
|
||||||
|
|
@ -5,10 +5,14 @@ from markdown.extensions.wikilinks import WikiLinkExtension
|
||||||
SOURCE_DIR = Path("docs") # input folder
|
SOURCE_DIR = Path("docs") # input folder
|
||||||
OUTPUT_DIR = Path("www") # output 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):
|
def convert_markdown_to_html(md_path: Path, html_path: Path):
|
||||||
html_path.parent.mkdir(parents=True, exist_ok=True)
|
html_path.parent.mkdir(parents=True, exist_ok=True)
|
||||||
html = markdown.markdown(md_path.read_text(encoding="utf-8"), extensions=[
|
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',
|
'tables',
|
||||||
'fenced_code',
|
'fenced_code',
|
||||||
'sane_lists',
|
'sane_lists',
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue