H2 header doesn't collapse a percent comment that contains an H1 header

note: I couldn’t search for prior topics with %%. No results came back.

Steps To Reproduce

  1. Create a markdown file with the following content:
## Header Level 2
Text.

%%
# Header 1 in percent comment
Text.
%%
  1. Open the markdown file in Obsidian.
  2. Collapse the level 2 header (## Header Level 2).

Did you follow the troubleshooting guide? Y

Expected Result

The level 1 header (# Header Level 1) should collapse.

Current Result

Header 1 doesn’t collapse in live preview or source.

In live preview:


In source:

Environment

SYSTEM INFO:
Obsidian version: v1.8.9
Installer version: v1.8.4
Operating system: Windows 11 Pro 10.0.26100
Login status: logged in
Language: en
Catalyst license: insider
Insider build toggle: off
Live preview: on
Base theme: adapt to system
Community theme: none
Snippets enabled: 0
Restricted mode: on

RECOMMENDATIONS:
none

Commented or not, I’m fairly certain that for one heading to collapse into another, it needs to be of a lower level.

e.g., this folds and hides everything fine:

## Header Level 2
Text.

%%
### Header 3 in percent comment
Text.
%%
1 Like

I’m unsure if it’s expected behavior. An html comment folds headers fine. I expected it to fold as if the comment didn’t render headers.

I don’t have any urgency for this to be implemented. I was trying to save a sample of markdown that had code samples in it without having it render normally. Thought I’d share because I found it out of the ordinary. Later found I could surround my markdown sample with quad backticks.