vsch / flexmark-java

CommonMark/Markdown Java parser with source level AST. CommonMark 0.28, emulation of: pegdown, kramdown, markdown.pl, MultiMarkdown. With HTML to MD, MD to PDF, MD to DOCX conversion modules.
BSD 2-Clause "Simplified" License
2.26k stars 269 forks source link

Emphasis around link doesn't get parsed #556

Open FilippoVigani opened 1 year ago

FilippoVigani commented 1 year ago

I'm having an issue trying to parse a markdown which has some emphasis around a link.

To Reproduce

Here is an **$[example](https://www.example.com)**

I'm setting the options with setFrom(ParserEmulationProfile.MARKDOWN), and have a few extensions:

TablesExtension.create(),
                StrikethroughExtension.create(),
                AttributesExtension.create(),
                FootnoteExtension.create(),
                WikiLinkExtension.create(),
                GitLabExtension.create(),

Expected behavior

I would expect the document to parse to an AST with Document->Paragraph->"Here is an "Emphasis->Link

Resulting Output

However the Emphasis is omitted and I can only find the link inside the paragraph, and the asterisks are left as plain text.

Is there any settings I'm missing or is this expected behavior? Is there any way to parse the emphasis regardless if it wraps a link?

FilippoVigani commented 1 year ago

It turns out I had a custom extension that removed the emphasis node. Closing.

FilippoVigani commented 1 year ago

Actually, I noticed that if a space is included between the link and the asterisks, the issue persists:

Here is an ** $[example](https://www.example.com) **.

This will keep the asterisks instead of wrapping with an emphasis node.

ghost commented 1 year ago

Works as designed. Changing this behaviour would adversely affect existing documents. The Markdown specification suggests that only stars directly touching text are interpreted as a style (emphasis, bold, or bold emphasis) for the text that they touch.

stars