Bug Report: Outline view breaks when a math block starts on the same line as preceding text

Bug Report: Outline view breaks when a math block starts on the same line as preceding text

Steps to reproduce

  1. Create a new note in Obsidian.

  2. Paste the following Markdown content into the note. The issue is triggered by the structure under heading # d:

    # a
    $$
    a
    $$
    
    # b
    $$
    b
    $$
    
    # c
    f $$
    f $$
    
    # d
    some text$$
    content
    $$
    
    # e
    This heading is not detected.
    
  3. Open the “Outline” view to observe the headings.

Did you follow the troubleshooting guide? [Y/N]

Y

(This bug is reproducible in the sandbox vault with no third-party plugins or custom CSS enabled.)

Expected result

The outline pane should display all five headings: a, b, c, d, and e.

Actual result

The outline stops parsing after heading d. Heading e and any subsequent headings do not appear in the outline view.

Environment


Additional information

The issue is triggered by any math block that starts on the same line as preceding text and whose closing $$ is at the beginning of a new line. The content inside the math block does not matter (it can be empty or have content).

The specific pattern that causes the bug is:

[some text]$$
...
$$

A simple workaround is to add a newline between the text and the opening $$. When this is done, the outline immediately parses all headings correctly.

This isn’t a bug. Blocks of any kind have to start on their own line. That’s their nature. They can’t share a line with other things.

So some text$$ is not the start of a math block, which means the $$ you think is the end of a math block is actually the start. And since the block has no end marker, the rest of the file is part of it. That’s why you don’t see what you expect in the outline.

1 Like

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.