JetBrains / markdown

Markdown parser written in kotlin
Apache License 2.0
706 stars 78 forks source link

Two adjacent links fail to render #42

Closed Leonya closed 3 years ago

Leonya commented 4 years ago

The following should be rendered as two adjacent links, but instead there's an error:

[Rust](https://jetbrains.team/team?team=Rust-MNVpW0Zos2C)[💬](https://jetbrains.team/m/Arseniy.Pendryak)

markdown-it parser has no problem with this.

ajalt commented 4 years ago

This is caused by the GFMFlavourDescriptor.

As another example, the following markdown:

<i>[1](http://a/b)</i>

incorrectly renders as

<i>[1](<a href="http://a/b)&lt;/i&gt;">http://a/b)&lt;/i&gt;</a>

rather than

<i><a href="http://a/b">1</a></i>

This is due to the GFMFlavourDescriptor incorrectly parsing the content of the link destination as a GFM_AUTOLINK:

Markdown:PARAGRAPH
  Markdown:HTML_TAG '<i>'
  Markdown:SHORT_REFERENCE_LINK
    Markdown:LINK_LABEL
      Markdown:[ '['
      Markdown:TEXT '1'
      Markdown:] ']'
  Markdown:( '('
  Markdown:GFM_AUTOLINK 'http://a/b)</i>'
valich commented 3 years ago

I've pushed yet another heuristic, which should fix abovementioned cases. The proper parsing of autolinks along with other inline structures is still not done, not sure it will arrive anytime soon. (though @FirstTimeInForever might help with that at some point of time)