Problem
For the following markdown code:
Marko outputs
$ python -m marko
Type in the markdown content to be converted. End with Ctrl+D
**a_{b}**
<p>**a_{b}**</p>
Instead, CommonMark's reference implementation gives
<p><strong>a_{b}</strong></p>
Analysis
I debugged this, comparing this case with the reference **a_b** which works as expected.
The issue seems to lie here
|
if not d_closer.can_open: |
|
delimiters.remove(d_closer) |
|
cur = _next_closer(delimiters, cur) |
In the failing case, the _ is not an opening delimiter, so it gets removed. However the _next_closer function still uses the old delimiter's index as its starting point, which means it never considers the second ** as a valid closer.
This results in the behaivour that if there is a non-opening emphasis delimiter between two others, the outer emphasis element is not created.
Problem
For the following markdown code:
Marko outputs
Instead, CommonMark's reference implementation gives
Analysis
I debugged this, comparing this case with the reference
**a_b**which works as expected.The issue seems to lie here
marko/marko/inline_parser.py
Lines 438 to 440 in 6113ad8
In the failing case, the
_is not an opening delimiter, so it gets removed. However the_next_closerfunction still uses the old delimiter's index as its starting point, which means it never considers the second**as a valid closer.This results in the behaivour that if there is a non-opening emphasis delimiter between two others, the outer emphasis element is not created.