Marked: Code blocks with email-like text are no longer parsed as code

Created on 15 Apr 2018  路  13Comments  路  Source: markedjs/marked

Marked version: 0.3.12 (OK) 0.3.14 (buggy)

`user@host`

used to render as <code> block:

user@host

but now it's rendered as an e-mail link with literal ` in it:

`user@host`

L1 - broken help wanted

Most helpful comment

Aw, that PR was not linked :(

I have done a totally different solution, I'm not sure what you were going for with that PR. I'll just submit it and then you'll decide what to pick and/or integrate one with the other!

All 13 comments

seems to work in the latest 0.3.19: demo

Sorry, I've oversimplified the example. Try:


 `/[email protected]`.

Yup `[email protected]` does it

Looking at the specs to try and figure out a test to create and they don't seem to call out this specific use case.

For CommonMark:

Autolinks are absolute URIs and email addresses inside < and >.

So, this would be something related to GitHub Flavored Markdown:

An extended email autolink will be recognised when an email address is recognised within any text node.

Looking at code spans (examples 322 to 327) I would suspect that the proper behavior would be something like:

Markdown:

`[email protected]`

Html:

<p><code>[email protected]</code></p>

@kornelski: Is that what you're looking for?

In my case <code> is more important than <a>, because I'm using a made-up e-mail address in documentation and don't want it linked. If you prefer links, then both tags together (<code><a>email</a></code>) would be a reasonable rendering IMHO.

IMO creating a link without <> surrounding it should only happen when the gfm option is true since this would not be compliant with commonmark

GFM complies with CommonMark; so, autolinking should be invoked by the <> combination. Given what I can discern from the code span area of CM and GFM, I would say the code span leaves everything inside alone. The linked PR runs a test that would result in that ignore.

in order to pass CommonMark Example #583 This autolinking without <> will have to be moved to gfm: true

Think this conversation might go beyond this issue...deeper issues with Marked at the moment...making a new issue:

To pass I think we actually need a way to specify just CommonMark - not GFM or Pedantic. We currently don't have anything like that. The CommonMark Autolinks remain in the CommonMark spec tests - where they are at present - of which 583 is already listed as failing but should pass.

According to gfm spec, autolinks have higher precedence than code spans.

Also, email addresses are recognized and autolinked by the InlineLexer.rules.gfm.url rule, which (re-)uses the InlineLexer.rules._email subrule. This comes from cm spec. This is wrong, since gfm defines extended autolinked email adresses quite differently.

I'm making a PR for this

this is fixed by #1337

Aw, that PR was not linked :(

I have done a totally different solution, I'm not sure what you were going for with that PR. I'll just submit it and then you'll decide what to pick and/or integrate one with the other!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

james4388 picture james4388  路  3Comments

bennycode picture bennycode  路  4Comments

elennaro picture elennaro  路  4Comments

eGavr picture eGavr  路  4Comments

learykara picture learykara  路  3Comments