Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Emphasized URL with underscores #872

Closed
p3k opened this issue Mar 17, 2017 · 6 comments
Closed

Emphasized URL with underscores #872

p3k opened this issue Mar 17, 2017 · 6 comments

Comments

@p3k
Copy link

p3k commented Mar 17, 2017

After upgrading marked from 0.3.3 to 0.3.4 I noticed a different output for the following call:

echo "_https://reddit.com/r/science/comments/5yde1e/its_official_time_crystals_are_a_new_state_of/_" | marked

This is was I got so far in marked 0.3.3 – which is also what I would expect:

https://reddit.com/r/science/comments/5yde1e/its_official_time_crystals_are_a_new_state_of/

<p><em><a href="https://reddit.com/r/science/comments/5yde1e/its_official_time_crystals_are_a_new_state_of/">https://reddit.com/r/science/comments/5yde1e/its_official_time_crystals_are_a_new_state_of/</a></em></p>

However, in marked 0.3.4 and greater the output becomes this:

_https://reddit.com/r/science/comments/5yde1e/its_official_time_crystals_are_a_new_state_of/_

<p>_<a href="https://reddit.com/r/science/comments/5yde1e/its_official_time_crystals_are_a_new_state_of/_">https://reddit.com/r/science/comments/5yde1e/its_official_time_crystals_are_a_new_state_of/_</a></p>

Please also note that Github’s markdown implementation behaves like 0.3.3:

https://reddit.com/r/science/comments/5yde1e/its_official_time_crystals_are_a_new_state_of/

p3k added a commit to antville/antville that referenced this issue Mar 17, 2017
note: marked is sticky @0.3.3 because of issue #872 – markedjs/marked#872
@phiggins42
Copy link

came to file this same bug/regression. current test was @ 0.3.6 ... will move back to 0.3.3 it seems.

@joshbruce
Copy link
Member

#984

@Feder1co5oave
Copy link
Contributor

I'll just say that this is due to a change to the em inline rule:

@@ -454,7 +456,7 @@ var inline = {
   reflink: /^!?\[(inside)\]\s*\[([^\]]*)\]/,
   nolink: /^!?\[((?:\[[^\]]*\]|[^\[\]])*)\]/,
   strong: /^__([\s\S]+?)__(?!_)|^\*\*([\s\S]+?)\*\*(?!\*)/,
-  em: /^\b_((?:__|[\s\S])+?)_\b|^\*((?:\*\*|[\s\S])+?)\*(?!\*)/,
+  em: /^\b_((?:[^_]|__)+?)_\b|^\*((?:\*\*|[\s\S])+?)\*(?!\*)/,
   code: /^(`+)\s*([\s\S]*?[^`])\s*\1(?!`)/,
   br: /^ {2,}\n(?!\s*$)/,
   del: noop,

First of all, autolinking of plain URLs is GFM matter. Markdown (commonmark) allows autolinking of URIs wrapped inside <..>.
Still, even

_<https://reddit.com/r/science/comments/5yde1e/its_official_time_crystals_are_a_new_state_of/>_

gets parsed to

<p>_<a href="https://reddit.com/r/science/comments/5yde1e/its_official_time_crystals_are_a_new_state_of/">https://reddit.com/r/science/comments/5yde1e/its_official_time_crystals_are_a_new_state_of/</a>_</p>

and this is not correct. This is a tricky one.

Whenever underscores are present in URLs, it is advisable to use reflinks.

@Feder1co5oave
Copy link
Contributor

@joshbruce I would re-open this one and put it under category 'emphasize'.

@joshbruce
Copy link
Member

@Feder1co5oave: Re-opening. Putting under "links" for now. Would like avoid creating a category for individual HTML elements. That's why we have "lists" instead of "description lists", yeah?

Maybe inline and block would make sense as categories as well. I only created the initial categories because there were more than 5 or 6 issues revolving around that topic.

@UziTech
Copy link
Member

UziTech commented Dec 5, 2018

this seems to be fixed in the latest version of marked. demo

@UziTech UziTech closed this as completed Dec 5, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants