Hey folks,
I’ve read through CommonMark Spec but would love to get a bit of clarification on some edge-case behaviour.
a **\*** b
parses as I’d expect:
<text>a </text>
<strong>
<text>*</text>
</strong>
<text> b</text>
But as soon as either space is removed (a**\*** b
) it no longer parses the emphasis, but still as separate blocks:
<text>a</text>
<text>**</text>
<text>*</text>
<text>**</text>
<text> b</text>
Dingus demo
What part of the spec causes this to no longer be treated as correct emphasis?
And relatedly, is there a way to use Markdown syntax (without falling back to just using HTML <strong>
) to apply strong emphasis to an asterisk (interestingly a__\*__ b
behaves the same way, not producing emphasis)?
jgm
April 19, 2022, 7:58pm
2
This is because of flankingness. When you remove the space, the
first **
becomes right-flanking and hence cannot start
emphasis.
Unfortunately the current rules don’t really allow you to express
what you’re going for, without resorting to raw HTML.
jgm
April 19, 2022, 7:59pm
3
A workaround could be using a numerical entity instead of a
.
This would change the flankingness so that **
is both left
and right flanking.
vas
April 19, 2022, 8:22pm
4
See also this recent GitHub issue submitted against the CommonMark spec: Invalid em + strong rendering in JavaScript implementation
Ty for the pointers both!
I wonder if this is worth adding an example/note to the spec for, as it seems like a complex edge-case and feels very similar to Example 415 .
Almost, but with obvious side effects:
a[**\***]()b
a[**\***][]b
a[**\***]b
[**\***]: <>