Pi66

merodi
A markdown-based static site generator.
git clone https://git.pi66.xyz/merodi

← back to log

fix: preserve ${} in code blocks

author: pi66
date: 2026-07-14 19:51
hash: 2af75312de21922b8f7c7b171806c6e4d8a0ec60

Diffstat:

M

src/build.py
6 +++++++++++++++++++++++++-----
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
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)