Bug Description
Exported session HTML files fail to open. Browser console shows:
Uncaught ReferenceError: MARKED_JS is not defined
Uncaught ReferenceError: HIGHLIGHT_JS is not defined
Uncaught ReferenceError: JS is not defined
Root Cause
Placeholders in dist/export-html/template.html are incorrectly split into multi-line format by code formatters (e.g., prettier):
Expected format:
<script>{{MARKED_JS}}</script>
Actual format:
<script>
{
{
MARKED_JS;
}
}
</script>
The code uses .replace("{{MARKED_JS}}", markedJs) for substitution, but since the placeholder is split across lines, the replacement fails, resulting in undefined JavaScript variables in the generated HTML.
Affected Placeholders
{{MARKED_JS}}
{{HIGHLIGHT_JS}}
{{JS}}
Suggested Fixes
- Protect placeholders with HTML comments to prevent formatting
- Add formatting ignore rules for
.html files in the build process
- Use regex replacement in code to tolerate whitespace
Workaround
Manually edit dist/export-html/template.html and restore single-line placeholder format.
Environment
- OpenClaw version: latest (2026-03-11)
- Node: v22.12.0
- OS: macOS (arm64)
Bug Description
Exported session HTML files fail to open. Browser console shows:
Root Cause
Placeholders in
dist/export-html/template.htmlare incorrectly split into multi-line format by code formatters (e.g., prettier):Expected format:
Actual format:
The code uses
.replace("{{MARKED_JS}}", markedJs)for substitution, but since the placeholder is split across lines, the replacement fails, resulting in undefined JavaScript variables in the generated HTML.Affected Placeholders
{{MARKED_JS}}{{HIGHLIGHT_JS}}{{JS}}Suggested Fixes
.htmlfiles in the build processWorkaround
Manually edit
dist/export-html/template.htmland restore single-line placeholder format.Environment