From b9b627ca77048191577b41f40c352a9ce67ef61b Mon Sep 17 00:00:00 2001 From: altaf-creator Date: Tue, 9 Jun 2026 12:54:20 +0800 Subject: new font --- markdown_renderer.py | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) (limited to 'markdown_renderer.py') diff --git a/markdown_renderer.py b/markdown_renderer.py index d64fcf2..1e7c755 100644 --- a/markdown_renderer.py +++ b/markdown_renderer.py @@ -21,21 +21,29 @@ class DefaultClassExtension(markdown.extensions.Extension): md.treeprocessors.register(DefaultClassTreeprocessor(md), "link_class", 2) -def md_to_html(raw_content: str) -> str: +def md_to_html(raw_content: str, text_mode: bool = False) -> str: metadata, content = frontmatter.parse(raw_content) html_text = markdown.markdown( content, output_format="html", - extensions=["attr_list", "fenced_code", "tables", DefaultClassExtension(), "md_in_html"] + extensions=["attr_list", "fenced_code", "tables", DefaultClassExtension(), "md_in_html", "pymdownx.tilde", "footnotes"] ) - html_text = html_text.replace("

+-+-+-

", '
') - html_text = html_text.replace("

+-+-+-", '

') - html_text = html_text.replace("+-+-+-

", '
') + + section_class = "" + section_class_only = "" + + if text_mode: + section_class = ' class="text-section"' + section_class_only = ' text-section' + + html_text = html_text.replace("

+-+-+-

", f'
') + html_text = html_text.replace("

+-+-+-", f'

') + html_text = html_text.replace("+-+-+-

", f'
') html_text = html_text.replace("-+-+-+

", "
") html_text = html_text.replace("

-+-+-+", "

") - html_text = html_text.replace("

+=+=+=

", '
') - html_text = html_text.replace("

+=+=+=", '

') - html_text = html_text.replace("+=+=+=

", '
') + html_text = html_text.replace("

+=+=+=

", f'
') + html_text = html_text.replace("

+=+=+=", f'

') + html_text = html_text.replace("+=+=+=

", f'
') html_text = html_text.replace("

{{{

", '
') html_text = html_text.replace("

{{{", '

') html_text = html_text.replace("{{{

", '
') -- cgit v1.2.3