Editor: Codeblock following list - Subsequent text incorrectly interpreted as code

This is a consolidated BR.

There are several bug reports. The recurrent pattern is a (nested) lists and subsequent code block (WITH syntax highlighting). The text after the codeblock is incorrectly interpreted as code.

Some examples (whitespaces are important):

Example 1

text
  - level1
	  - level2

```c
void main()
```

not code!

Example 2

10. aaa
	1. bbb

```python
xyz
```

note code!

Example 3

-   cat1
	- cat2

```c
void
```

not code

Example 4

Steps to reproduce

Write/paste this piece of text on any page, anywhere:

bla

  • bla
    • bla
- any string
- "anything"

Content of the code block does not matter. Content before the code block matters, though: remove any line and bug is gone. On some pages bug exists even with the first line removed.

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

Yes.

Expected result

Properly highlighted code block that ends at the closing ``` line.

Actual result

This piece of text causes the rest of the page to be considered continuation of the YAML code block. The closing ``` sequence is not recognized. Even adding additional ``` below does not help.

There is also a highlighting problem that appears on absolutely every YAML code block. in YAML, string values can be quoted (“”) or not, they have the same meaning and should be highlighted similarly. Only quoted strings are highlighted in Obsidian. This is rare to quote them, and such content looks bad: everything is white, no difference between keys and values.

Environment

SYSTEM INFO:
Obsidian version: v1.9.14
Installer version: v1.9.14
Operating system: #163-Ubuntu SMP Thu Aug 7 16:37:18 UTC 2025 5.15.0-153-generic
Login status: not logged in
Language: en
Insider build toggle: off
Live preview: on
Base theme: adapt to system
Community theme: none
Snippets enabled: 0
Restricted mode: off
Plugins installed: 1
Plugins enabled: 1
1: Tasks v7.21.0


Additional information

Highlighting of a YAML code block with unquoted strings

This site actually also accepts text in Obsidian format, and here everything works and looks fine.

doe: a deer, a female deer
ray: a drop of golden sun
calling-birds:
- huey
- dewey
xmas-fifth-day:
  calling-birds: four
start_time: 01:30:00
end_time:   01:50:00

This piece of YAML is validated.

Hi.

Is the screenshot from editing mode? What do you see in reading mode?

Yes, screenshot was done in editing view, and it turns out in reading view both problems disappear.
It’s still a problem.
Actually I never use reading view, Obsidian is good at presenting content and allowing editing it at the same time, and blocks of code in other languages look very well in editing mode.

Added "Live Preview: " to title.

Steps to reproduce

Put the markdown in the following pastebin to a new file:
https://pastebin.com/QNDqgY5k

Expected result

In live preview, all text inside code blocks are rendered as code, all text outside code blocks are rendered as markdown text.

Actual result

In live preview, after the second code block, all text, even after ```s, are treated as code.

Environment

  • Operating system: Linux (openSUSE Tumbleweed), Obsidian installed via AppImage
  • Debug info:
    SYSTEM INFO:
    Obsidian version: v1.0.0
    Installer version: v0.15.9
    Operating system: #1 SMP PREEMPT_DYNAMIC Thu Sep 8 10:26:47 UTC 2022 (0330383) 5.19.8-1-default
    Login status: logged in
    Catalyst license: none
    Insider build toggle: off
    Live preview: on
    Legacy editor: off
    Base theme: dark
    Community theme: none
    Snippets enabled: 0
    Restricted mode: on

RECOMMENDATIONS:
none


Additional information

  • This bug only occur in live preview
  • This bug only occur on codeblocks after the specific bullet list layout. In the example, it doesn’t occur after the 1st codeblock, only the 2nd
  • This bug only occur when the language alias of the codeblock is one letter, so it occurs with C, D, R… but not Python(py), Javascript(js)…
  • This bug only occur after upgrading to v1.0

thanks

This seems to happen for me as well when the code-block contains auto-parsed links. For example [email protected]

I was about to open an issue for this and found this bug already reported (no duplicates whew :slight_smile:)
You can find the GIF showing the bug attached
obsidian-issue

As you can see the issue disappears in View mode and only occurs in the Live preview mode. I was hoping to get into the code base myself and found out that Obsidian is not open-source :frowning:

Steps to reproduce

Type this into a note

https://dr-droplr.s3.amazonaws.com/test.md

Expected result

The last line should be outside the codeblock and rendered in the normal display font

Actual result

The last line is inside the codeblock and rendered in a monospaced font.

Environment

  • Operating system: OSX 12.5
  • Debug info:

SYSTEM INFO:
Obsidian version: v0.15.9
Installer version: v0.15.9
Operating system: Darwin Kernel Version 21.6.0: Sat Jun 18 17:07:22 PDT 2022; root:xnu-8020.140.41~1/RELEASE_ARM64_T6000 21.6.0
Login status: logged in
Catalyst license: none
Insider build toggle: off
Live preview: on
Legacy editor: off
Base theme: dark
Community theme: none
Snippets enabled: 0
Restricted mode: on

RECOMMENDATIONS:
none


Additional information

thanks

Steps to reproduce

  1. Create a new note.

  2. Paste the following:

  3. aaa

    1. bbb
xyz

Interpretation

The Average Directional Index (ADX) is used to measure the strength or weakness of a trend, not the actual direction. Directional movement is defined by +DI and -DI.

  1. You will see beginning from “# Interpretation” the format of everything is corrupted.

Expected result

Normal formatting.

Actual result

Environment

  • Operating system: macOS 12.6.3 (21G419)
  • Debug info:

SYSTEM INFO:
Obsidian version: v1.1.9
Installer version: v1.1.9
Operating system: Darwin Kernel Version 21.6.0: Mon Dec 19 20:44:01 PST 2022; root:xnu-8020.240.18~2/RELEASE_X86_64 21.6.0
Login status: not logged in
Insider build toggle: off
Live preview: on
Legacy editor: off
Base theme: dark
Community theme: none
Snippets enabled: 0
Restricted mode: on

RECOMMENDATIONS:
none


Additional information

Thanks. The editor doesn’t interpret correctly a list beginning with 01.

Not only that.

If 01. aaa is replaced with 10. aaa or 11. aaa, or 21. aaa, the bug remains. As a matter of fact, it seems to me that as long as the list number is greater than 9, the problem arises.

For example,

Steps to reproduce

  1. Create a list with two-digit index
  2. Create a sublist (indexed or not)
  3. Create a codeblock and chose the format language
  4. Write any text under the codeblock

Did you follow the troubleshooting guide? Y

Expected result

The text under the code block should not be formatted as a code.

Actual result

The text under the code block is formatted as the chosen code.

Environment

SYSTEM INFO:
Obsidian version: v1.6.7
Installer version: v1.6.7
Operating system: #40~22.04.3-Ubuntu SMP PREEMPT_DYNAMIC Tue Jul 30 17:30:19 UTC 2 6.8.0-40-generic
Login status: logged in
Catalyst license: none
Insider build toggle: off
Live preview: on
Base theme: adapt to system
Community theme: none
Snippets enabled: 0
Restricted mode: off
Plugins installed: 1
Plugins enabled: 1
1: Remotely Save v0.5.18


Additional information

For example (I’m using ' symbol on purpose):

99. test
	1. another test
'''cpp
int a = 3;
'''
example text

 (const volatile)

I see as

Is there an answer for my problem?

thanks

Steps to reproduce

  1. Open a new blank document
  2. Make a bullet point note
  3. Below that make a sub-point
  4. Below that make a multi-line code snippet with some specified language
  5. Write something after that code snippet

Expected result

Text should be normal

Actual result

Text after the code snippet behaves like it is inside code snippet

Environment

  • Operating system: Linux - Manjaro
  • Debug info:
    SYSTEM INFO:
    Obsidian version: v0.13.23
    Installer version: v0.13.23
    Operating system: #1 SMP PREEMPT Thu Jan 20 13:58:19 UTC 2022 5.15.16-1-MANJARO
    Login status: not logged in
    Insider build toggle: off
    Live preview: on
    Legacy editor: off
    Base theme: dark
    Community theme: none
    Snippets enabled: 0
    Safe mode: on

RECOMMENDATIONS:
none


Additional information

source file:
Iterables & Iterators.md (1.7 KB)

I can’t reproduce. what is the exact source of your document. Attach the file here.