Skip to content

Emphasized URL with underscores #872

Closed

Description

@p3k

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/

Activity

  1. phiggins42 commented on May 24, 2017

    @phiggins42

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

  2. joshbruce commented on Dec 25, 2017

    @joshbruce
    Member
  3. Feder1co5oave commented on Jan 10, 2018

    @Feder1co5oave
    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.

  4. Feder1co5oave commented on Jan 10, 2018

    @Feder1co5oave
    Contributor

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

  5. joshbruce commented on Jan 10, 2018

    @joshbruce
    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.

  6. UziTech commented on Dec 5, 2018

    @UziTech
    Member

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions