summaryrefslogtreecommitdiff
path: root/markdown_renderer.py
diff options
context:
space:
mode:
authoraltaf-creator <dev@altafcreator.com>2026-06-09 12:54:20 +0800
committeraltaf-creator <dev@altafcreator.com>2026-06-09 12:54:20 +0800
commitb9b627ca77048191577b41f40c352a9ce67ef61b (patch)
tree0718ad68a9c9c7db9542203dd02f7058e7d8b0e5 /markdown_renderer.py
parent43913c528cdedbbcd73bf41b7f11bb1215210188 (diff)
new font
Diffstat (limited to 'markdown_renderer.py')
-rw-r--r--markdown_renderer.py24
1 files changed, 16 insertions, 8 deletions
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("<p>+-+-+-</p>", '<section><div class="center-grid"><div class="div-sizing">')
- html_text = html_text.replace("<p>+-+-+-", '<section><div class="center-grid"><div class="div-sizing">')
- html_text = html_text.replace("+-+-+-</p>", '<section><div class="center-grid"><div class="div-sizing">')
+
+ section_class = ""
+ section_class_only = ""
+
+ if text_mode:
+ section_class = ' class="text-section"'
+ section_class_only = ' text-section'
+
+ html_text = html_text.replace("<p>+-+-+-</p>", f'<section{section_class}><div class="center-grid"><div class="div-sizing">')
+ html_text = html_text.replace("<p>+-+-+-", f'<section{section_class}><div class="center-grid"><div class="div-sizing">')
+ html_text = html_text.replace("+-+-+-</p>", f'<section{section_class}><div class="center-grid"><div class="div-sizing">')
html_text = html_text.replace("-+-+-+</p>", "</div></div></section>")
html_text = html_text.replace("<p>-+-+-+", "</div></div></section>")
- html_text = html_text.replace("<p>+=+=+=</p>", '<section class="normal-section"><div class="center-grid"><div class="div-sizing">')
- html_text = html_text.replace("<p>+=+=+=", '<section class="normal-section"><div class="center-grid"><div class="div-sizing">')
- html_text = html_text.replace("+=+=+=</p>", '<section class="normal-section"><div class="center-grid"><div class="div-sizing">')
+ html_text = html_text.replace("<p>+=+=+=</p>", f'<section class="normal-section{section_class_only}"><div class="center-grid"><div class="div-sizing">')
+ html_text = html_text.replace("<p>+=+=+=", f'<section class="normal-section{section_class_only}"><div class="center-grid"><div class="div-sizing">')
+ html_text = html_text.replace("+=+=+=</p>", f'<section class="normal-section{section_class_only}"><div class="center-grid"><div class="div-sizing">')
html_text = html_text.replace("<p>{{{</p>", '<div class="flex-container gap">')
html_text = html_text.replace("<p>{{{", '<div class="flex-container gap">')
html_text = html_text.replace("{{{</p>", '<div class="flex-container gap">')