Skip to content

Emphasis intersection bug? #475

@aidantwoods

Description

@aidantwoods

Given the following markdown:

**strong* still strong**

The online reference parser gives this output:

<p><em><em>strong</em> still strong</em>*</p>

However, using rule 15 (just below http://spec.commonmark.org/0.27/#can-open-emphasis)

  1. When two potential emphasis or strong emphasis spans overlap, so that the second begins before the first ends and ends after the first ends, the first takes precedence. Thus, for example, *foo _bar* baz_ is parsed as <em>foo _bar</em> baz_ rather than *foo <em>bar* baz</em>.

I think the output should be this

<p><strong>strong* still strong</strong></p>

Instead, the parser is behaving more like it would when faced with rule 16

  1. When there are two potential emphasis or strong emphasis spans with the same closing delimiter, the shorter one (the one that opens later) takes precedence. Thus, for example, **foo **bar baz** is parsed as **foo <strong>bar baz</strong> rather than <strong>foo **bar baz</strong>.

Even though these emphasis and strong emphasis spans do not have the same closing delimiter (so this rule should not apply).


Note that I am assuming that the phrase same closing delimiter (which is not formally defined) is referring to a delimiter run as categorised by its starting position in the string (this holds for the example given).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions