Skip to content

export-html template.html malformed by formatter causing export failure #43620

@yunlzhang

Description

@yunlzhang

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions