I wrote a Markdown implementation, and the emphasis (
*Italic*) should follow the CommonMark specification. But while implementing it, I came across some weird edge cases where the reference implementation seems to diverge from the spec. If I just understood something wrong, can you please help me understand?
When I type
*****Hello*world**** in the dingus, the result is
But I think it should be
Can someone explain why that is?
The spec contains this interesting rule:
The opening and closing delimiters must belong to separate delimiter runs.
If one of the delimiters can both open and close emphasis, then the sum of the lengths of the delimiter runs containing the opening and closing delimiters must not be a multiple of 3 unless both lengths are multiples of 3.
In the above example, there are 5 stars on the left and 4 on the right, so the number of stars in their delimiter runs is a multiple of 3. However, neither of them can both open and close emphasis (the stars on the left can only open emphasis, and the stars on the right can only close emphasis), so the last sentence of this rule should not apply.