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.21k stars 260 forks source link

The parser fails to parse marks inside <ul><li> and <row><table><tr><td> if not preceeded by a blank line #597

Open PrometeusGod opened 8 months ago

PrometeusGod commented 8 months ago

bug description With a hybrid HTML/MD input The parser fails to parse marks inside

<ul><li> 

and inside

<row><table><tr><td>

Where the bug is located:

Sample code which exhibits the issue.

 Parser parser = Parser.builder().build();
        HtmlRenderer renderer = HtmlRenderer.builder().build();
        String output = """
                <ul><li>**BulletPoint**[link](/url)</li></ul>
                <row gap="tiny"><table><tr><td>**Table** [link](/url) </td></tr> </table></row>
                """;
        Node document = parser.parse(output);
        out.println(renderer.render(document));
  1. Input text used

                <ul><li>**BulletPoint**[link](/url)</li></ul>
                <row gap="tiny"><table><tr><td>**Table** [link](/url) </td></tr> </table></row>
  2. Options used to configure the parser, renderer, formatter, etc.

No options/default Parser parser = Parser.builder().build(); HtmlRenderer renderer = HtmlRenderer.builder().build();

Expected behavior

Table link

Resulting Output :

**Table** [link](/url)

Note:

Having a blank line right before the mark makes it parsable but adds an unwanted paragraph around the line, which is a problem for multiple bulletpoints and inside tables

 <ul><li>

 **BulletPoint**[link](/url)</li></ul><row gap="tiny"><table><tr><td>**Table**[link](/url)</td></tr></table></row>

Resulting Output :

Tablelink