Skip to content

Inline emphasis edge case differs from CommonMark spec #241

@ll3006

Description

@ll3006

Problem

For the following markdown code:

**a_{b}**

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions