flexmark-java icon indicating copy to clipboard operation
flexmark-java copied to clipboard

Emphasis around link doesn't get parsed

Open FilippoVigani opened this issue 2 years ago • 3 comments

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

  • [x] Parser
  • [ ] HtmlRenderer
  • [ ] Formatter
  • [ ] FlexmarkHtmlParser
  • [ ] DocxRenderer
  • [ ] PdfConverterExtension
  • [ ] extension(s)

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 avatar Feb 27 '23 10:02 FilippoVigani

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

FilippoVigani avatar Feb 27 '23 11:02 FilippoVigani

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.

FilippoVigani avatar Feb 27 '23 14:02 FilippoVigani

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

ghost avatar Jun 18 '23 21:06 ghost