Markdown Rendering doesn't comply with CommonMark or GFM

Expected behaviour

<DIV CLASS="foo">

*em*

</DIV>

is expected to render to

<DIV CLASS="foo">
<p><em>Markdown</em></p>
</DIV>

Observed behaviour

<DIV CLASS="foo">

*em*

</DIV>

Renders to (whitespace edited for clarity)

<div>
  <div class="foo"></div>
</div>

<div>
  <p><em>em</em></p>
</div>

<div>
</div>

Rationale

From the Obsidian documentation

We strive for maximum capability without breaking any existing formats, therefore we use a slightly unorthodox combination of flavors of markdown. It is broadly CommonMark, with the addition of some functionality from GitHub Flavored Markdown (GFM) […]

According to both the CommonMark specs and the GFM specs embedded markdown within HTML tags in all caps should work as expected. In other words:

<DIV CLASS="foo">

*Markdown*

</DIV>

Should render to

<DIV CLASS="foo">
<p><em>Markdown</em></p>
</DIV>

If Obsidian is behaving as intended and this is not a bug, it may be worth documenting the differences to CommonMark and GFM in the documentation notes on formatting.

Environment

  • Operating system: Linux
  • Debug info:
    SYSTEM INFO:
    	Obsidian version: v0.13.14
    	Installer version: v0.12.19
    	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
    	Safe mode: on
    
    RECOMMENDATIONS:
    	none
    

We intentionally do not support intermingling markdown syntax within html blocks and blank lines in html blocks. This is the result of an optimization to handle very large files and to support synchronization between editing and reading mode.

I’ll try to add a note to the docs.

1 Like

:+1: Sounds good. Thank you.