Steps to reproduce
Paste this into a note and open Reading view:
*a `*`*
*a `*` b*
[not a `link](/foo`)
[a `]` b](c)
Did you follow the troubleshooting guide?
Yes (reproduced in the sandbox vault, no community plugins).
Expected result
Code spans bind more tightly than emphasis and links, so a * or ] inside backticks is just code (CommonMark 0.31.2):
| Markdown | CommonMark HTML | Spec example |
|---|---|---|
*a `*`* |
<em>a <code>*</code></em> |
478 |
[not a `link](/foo`) |
[not a <code>link](/foo</code>) |
342 |
[a `]` b](c) |
a link a <code>]</code> b to c |
Actual result
| Markdown | Reading view HTML |
|---|---|
*a `*`* |
<em>a `</em>`* (the backticks are text) |
*a `*` b* |
<em>a `</em>` b* |
[not a `link](/foo`) |
<a href="/foo`">not a `link</a> |
[a `]` b](c) |
[a `]` b](c), plain text, no link and no code |
Emphasis and link brackets are matched before code spans, and the same happens with raw HTML and autolinks: *<img src="foo" title="*"/> (475) and **a<https://foo.bar/?q=**> (480) turn into emphasis that cuts through the tag or the URL.
Environment
SYSTEM INFO:
Obsidian version: 1.14.5
Installer version: 1.14.4
Operating system: Windows 11 Pro 10.0.26300
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: on
RECOMMENDATIONS:
none
Sandbox vault, no community plugins, default theme and settings.
Additional information
Measured on the CommonMark 0.31.2 spec examples in Reading view. Other examples with the same cause: 341, 419, 473-477, 479, 481, 521, 524-526, 534, 536-538, 564.
Related, same cause with math instead of code: Reading mode: asterisk or underscore within inline math are incorrectly interpreted as markdown markers.
This bites whenever inline code contains *, _ or ], which is common in notes about code (`a*b`, `arr[i]`).