JetBrains / markdown

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

Autolinks with email addresses parse incorrectly #50

Open ajalt opened 4 years ago

ajalt commented 4 years ago

The following markdown:

<foo@bar.baz>

Renders incorrectly as:

<body><p>&lt;foo@bar.baz&gt;</p></body>

The CommonMark spec doesn't treat email addresses in autolinks specially. But this library has a special EMAIL_AUTOLINK token type that isn't parsed or rendered correctly:

Markdown:PARAGRAPH
  Markdown:< '<'
  Markdown:EMAIL_AUTOLINK 'foo@bar.baz'
  Markdown:> '>'

I would suggest removing that token type.

valich commented 4 years ago

@ajalt Hi, sorry for the lag. I read spec as there actually is a special notion of emails(link), it adds mailto: to the beginning. So, in between <> there should be either absolute url, or something url-ish.

Example of non-absolute non-url-ish thing: https://spec.commonmark.org/dingus/?text=%3CMAILTO%3AFOO%40BAR.BAZ%3E%0A

The case you posted, however, looks like a bug anyway, because we should parse email autolinks correctly.

katepol commented 3 years ago

perhaps there should be wrapping MarkdownElementType for EMAIL_AUTOLINK token, just as it is done for AUTOLINK