1
0
mirror of https://github.com/venthur/blag.git synced 2025-11-26 05:02:58 +00:00

Re-formatted the code

This commit is contained in:
Bastian Venthur
2022-09-01 12:41:25 +02:00
parent 7b6b219cdf
commit 87d619cc1c
9 changed files with 167 additions and 135 deletions

View File

@@ -33,8 +33,11 @@ def markdown_factory() -> Markdown:
"""
md = Markdown(
extensions=[
'meta', 'fenced_code', 'codehilite', 'smarty',
MarkdownLinkExtension()
'meta',
'fenced_code',
'codehilite',
'smarty',
MarkdownLinkExtension(),
],
output_format='html',
)
@@ -91,9 +94,7 @@ def convert_markdown(
class MarkdownLinkTreeprocessor(Treeprocessor):
"""Converts relative links to .md files to .html
"""
"""Converts relative links to .md files to .html"""
def run(self, root: Element) -> Element:
for element in root.iter():
@@ -112,7 +113,7 @@ class MarkdownLinkTreeprocessor(Treeprocessor):
logger.debug(
f'{url}: {scheme=} {netloc=} {path=} {query=} {fragment=}'
)
if (scheme or netloc or not path):
if scheme or netloc or not path:
return url
if path.endswith('.md'):
path = path[:-3] + '.html'
@@ -122,10 +123,11 @@ class MarkdownLinkTreeprocessor(Treeprocessor):
class MarkdownLinkExtension(Extension):
"""markdown.extension that converts relative .md- to .html-links.
"""markdown.extension that converts relative .md- to .html-links."""
"""
def extendMarkdown(self, md: Markdown) -> None:
md.treeprocessors.register(
MarkdownLinkTreeprocessor(md), 'mdlink', 0,
MarkdownLinkTreeprocessor(md),
'mdlink',
0,
)