Added custom url builder for wikilink extension
This commit is contained in:
parent
8cbc3e60eb
commit
e337b5675f
|
|
@ -1,3 +1,4 @@
|
|||
www/
|
||||
__pycache__/
|
||||
prependnewline.py
|
||||
*.tar
|
||||
|
|
|
|||
|
|
@ -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',
|
||||
|
|
|
|||
Loading…
Reference in New Issue