#19816·jupyterlab

Markdown with `=` line in LaTeX block breaks TOC and syntax highlighting

Author: c4rloCreated Sep 25, 2026Updated Sep 28, 2026
Labelsbugstatus:Needs Triage

Description

When a Markdown file or cell has a $$-delimited LaTeX block with a line containing only =, such as:

$$
\text{This}
=
\text{broken.}
$$

The line above the = gets misinterpreted as a Markdown heading (the spec calls it a setext heading), despite being inside the LaTeX block.

This happens in two separate places, causing two distinct issues, both shown in the below screenshot:

Image

Issues:

  1. The Table of Contents shows a bogus $$ \text{This} heading.
  2. The editor messes up the highlighting in that LaTeX block.

Reproduce

  1. Create a Markdown file with content as above.
  2. Open Table of Contents.
  3. Notice a heading called $$ \text{This} shows up in the TOC.
  4. Notice bad syntax highlighting in the editor.

Variations of this bug

  1. Markdown inside notebook instead of Markdown file: same issue occurs.
  2. More than one =, or - instead of =: same issue occurs, representing different ways of creating a "setext" heading.

Expected behavior

  • $$ \text{This} does not show up in the TOC.
  • Editor correctly highlights LaTeX block.