Comments inside multiline comments break

Steps to reproduce

Create a CommentTest.md note and paste the following:


**multi-line comment with multi line message:**

%% Text in line with comment start
line 1
line 2
line 3
line 4
Text in line with comment end %%

**inline comment inside multi-line comment:**

%%
line 1
line %% inline comment %% 2
line 3
%%

**multi-line comment inside multi-line comment:**

%%
line 1
line 2
line 3
start %% comment marker 
Multi line comment
end %% comment marker
line 4
%%

**inline & multi-line comment inside multi-line comment:**

%%
line 1
line %% inline comment %% 2
line 3
start %% comment marker 
Multi line comment
end %% comment marker
line 4
%%

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

Yes

Expected result

As implied by the syntax highlighting in reading / source mode (which shows the correct behaviour), the reading view, PDF exports etc. should display:

**multi-line comment with multi line message:**

**inline comment inside multi-line comment:**

inline comment 

**multi-line comment inside multi-line comment:**

comment marker 
Multi line comment
end 

**inline & multi-line comment inside multi-line comment:**

inline comment comment marker 
Multi line comment
end 

Actual result

The begging and ending comment markers %% get bungled and non comment text gets removed while commented text gets displayed.

Reading view displays:

multi-line comment with multi line message:

inline comment inside multi-line comment:

inline comment %% 2
line 3

line 1
line 2
line 3
start %% comment marker
Multi line comment
end %% comment marker
line 4

line 1
line 2
line 3
start %% comment marker
Multi line comment
end %% comment marker
line 4

This is also the case for PDF exports as seen below:

Environment

SYSTEM INFO:
Obsidian version: v1.8.4
Installer version: v1.8.4
Operating system: #202405300957~1736980680~22.04~44ea8a9 SMP PREEMPT_DYNAMIC Thu J 6.9.3-76060903-generic
Login status: not logged in
Language: en
Insider build toggle: off
Live preview: on
Base theme: light
Community theme: none
Snippets enabled: 0
Restricted mode: on

RECOMMENDATIONS:
none

Match the parser logic with the conditional hilighting logic of reading view.


Additional information