#20816: fix(export-session): prevent Prettier from corrupting template placeholders
size: XS
## Problem
The `/export-session` command generates HTML files with broken `<script>` tags. Instead of containing the actual JavaScript libraries (marked.js, highlight.js), the exported files contain literal placeholder text:
```html
<script>
{
{
MARKED_JS;
}
}
</script>
```
## Root Cause
Prettier reformatted the template placeholders `{{MARKED_JS}}`, `{{HIGHLIGHT_JS}}`, and `{{JS}}` inside `<script>` tags, interpreting them as JavaScript object literals. It added whitespace and semicolons, breaking the string replacement in `generateHtml()`:
```typescript
.replace("{{MARKED_JS}}", markedJs) // Looking for '{{MARKED_JS}}'
// But template contains '{ { MARKED_JS; } }'
```
## Fix
Add `<!-- prettier-ignore -->` comments before each script tag to preserve the exact placeholder syntax:
```html
<!-- prettier-ignore -->
<script>{{MARKED_JS}}</script>
```
## Testing
Tested locally - exported HTML now contains the actual library code and renders correctly.
<!-- greptile_comment -->
<h3>Greptile Summary</h3>
Fixed `/export-session` command generating broken HTML files by adding `<!-- prettier-ignore -->` comments before script tags containing template placeholders (`{{MARKED_JS}}`, `{{HIGHLIGHT_JS}}`, `{{JS}}`).
- Prettier was reformatting these placeholders as JavaScript object literals, adding whitespace and semicolons
- This broke the string replacement in `generateHtml()` at `src/auto-reply/reply/commands-export-session.ts:96-97`
- The fix preserves exact placeholder syntax so template replacement works correctly
- CHANGELOG entry properly documents the fix
<h3>Confidence Score: 5/5</h3>
- This PR is safe to merge with minimal risk
- The fix is focused, well-tested, and addresses a clear formatting bug with a standard Prettier directive. The changes are minimal (adding three `<!-- prettier-ignore -->` comments), the root cause is well-documented, and the solution is the idiomatic approach for preventing Prettier from reformatting specific code blocks
- No files require special attention
<sub>Last reviewed commit: a20271c</sub>
<!-- greptile_other_comments_section -->
<!-- /greptile_comment -->
Most Similar PRs
#22776: fix: restore export-session HTML template placeholders broken by Pr...
by miloudbelarebia · 2026-02-21
90.8%
#22309: fix(export-session): render system prompt section and payload corre...
by AIflow-Labs · 2026-02-21
84.7%
#22695: fix(export): restore HTML template placeholders broken by formatter...
by lailoo · 2026-02-21
78.7%
#20419: fix(webchat): explicitly pass gfm and breaks options to marked.parse()
by Limitless2023 · 2026-02-18
72.8%
#20423: fix(web-fetch): cap htmlToMarkdown input size to prevent catastroph...
by Limitless2023 · 2026-02-18
72.2%
#2716: Fix #2678: markdown horizontal rules not rendering in web chat
by Ambar-13 · 2026-01-27
71.3%
#4249: fix(telegram): properly nest link tags inside bold/italic formatting
by pradeeppeddineni · 2026-01-29
71.1%
#20795: fix(markdown): prevent triple newlines after blockquotes
by novalis133 · 2026-02-19
70.9%
#6596: Fix pre-existing formatting issues causing CI failures
by ryancnelson · 2026-02-01
70.4%
#16019: fix(plugins): add postinstall patch for ESM-only package exports
by dashed · 2026-02-14
70.4%