Skip to content

\{\{ in KateX is mistakenly interpreted as a JS code. #2381

@geraw

Description

@geraw

Describe the bug

Inside LaTeX math expressions in Slidev ($...$ or $$...$$), any occurrence of \{\{ is incorrectly treated by Vue's template compiler as the beginning of a mustache interpolation block ({{ ... }}).
As a result, the math formula breaks, parts of it disappear, or Slidev shows a compile error.

In LaTeX, \{\{ is a valid way to typeset literal braces or appears inside certain macro uses, so it should be passed through to KaTeX/MathJax unchanged.
Instead, Slidev/Vite parses it too early as a Vue template expression.

Expected behavior

\{\{ inside math mode should not be interpreted as Vue {{ ... }} interpolation and should be forwarded verbatim to the math engine.


Minimal reproduction

  1. Create a new Slidev project (npm create slidev@latest or https://sli.dev/new)

  2. Add a slide with the following content:

    $$
    f(x) = \{\{ x \}\}
    $$
  3. Run npm run dev

  4. The slide fails to render because Vue treats {{ x }} as a mustache expression instead of literal math.


Environment

  • Slidev version: v52.4.0
  • Browser: Chrome
  • OS: Windows 10

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions