block from the HTML.
The exported file loads the story directly from embedded JSON, so the
modal is never needed and just adds visual noise on first paint.
"""
html = re.sub(
r'\s*
.*?
\s*(?=\n?\s*)'
)
escaped_json = json_str.replace("", "<\\/script>")
if re.search(pattern, html, flags=re.DOTALL):
def _replace(m):
return f"{m.group(1)}\n{escaped_json}\n{m.group(3)}"
return re.sub(pattern, _replace, html, flags=re.DOTALL)
else:
# Fallback: inject before