merodi
A markdown-based static site generator.
git clone https://git.pi66.xyz/merodi
About | Files | Commits | Refs | License
fix: preserve ${} in code blocks
Author: pi66
Date: 2026-07-14 19:51
commit: 2af75312
Stat
| M | src/build.py | 6 | +5 | -1 |
Diff
diff --git a/src/build.py b/src/build.py
index 11cb50e..ad59d24 100644
--- a/src/build.py
+++ b/src/build.py
@@ -97,7 +97,11 @@ def escape_code_blocks(html_content: str) -> str:
literally contains Jinja syntax (e.g. docs showing `{% raw %}`).
{ renders back to '{' in the browser, so output is unaffected. """
def neutralize(m):
- return m.group(0).replace("{", "{")
+ block = m.group(0)
+ block = block.replace("${", "__JINJA_OPEN__")
+ block = block.replace("{", "{")
+ block = block.replace("__JINJA_OPEN__", "{")
+ return block
html_content = re.sub(r'<pre\b[\s\S]*?</pre>', neutralize, html_content)
html_content = re.sub(r'<code\b[\s\S]*?</code>', neutralize, html_content)