thephpleague / html-to-markdown

Convert HTML to Markdown with PHP

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Consecutive emphasis produces incorrect markdown

markopy opened this issue · comments

If emphasis tags of the same type (em, i) or (strong, b) follow each other without space like this:

<em>foo</em><em>bar</em>

it produces the markdown

*foo**bar*

which is incorrect because it converts back to

<em>foo**bar</em>

per https://spec.commonmark.org/0.29/#example-411

The fix for this seems to be to merge consecutive emphasis tags if they will produce the same type of emphasis (* or **) in markdown. The correct output is simply:

*foobar*

This is fixed in version 5.0.