Add function to escape Jinja2 syntax in text content

This commit is contained in:
2025-05-30 21:13:53 -04:00
parent d026b17a68
commit 7104f0789f
2 changed files with 19 additions and 1 deletions
+19
View File
@@ -1809,6 +1809,25 @@ def commentary(request: Request, book: str, chapter: int):
)
def escape_jinja2_syntax(text):
"""Escape Jinja2 syntax in text to prevent template parsing errors"""
if not text:
return text
# Escape Jinja2 block tags
text = text.replace('{%', '{%')
text = text.replace('%}', '%}')
# Escape Jinja2 variable tags
text = text.replace('{{', '{{')
text = text.replace('}}', '}}')
# Escape Jinja2 comment tags
text = text.replace('{#', '{#')
text = text.replace('#}', '#}')
return text
def generate_commentary(book, chapter, verse):
"""Generate AI-powered commentary for a specific verse"""
# Enhanced commentary database for major chapters
-1
View File
@@ -192,7 +192,6 @@
}
}
{% block head %}
<style>
.chapter-container {
position: relative;