Skip to content

Markdown mixed bold / italic parsed incorrectly #1353

Closed

Description

@Havunen

Describe the bug
Marked parses mixed bold and italic incorrectly

To Reproduce

Link to editor

Expected behavior

However if in place of italic strikethrough is used, everything works as expected.
It should bold first and last 3 characters. And then have italic from the second character to second last character.

Activity

  1. added
    L2 - annoying
    on Oct 15, 2018
  2. fredck commented on Sep 3, 2020

    @fredck

    Is the following case included in the issue? The formatting is not strictly mixed, just touching:

    // Input
    _te_**st**
    
    // Expected output
    <p><em>te</em><strong>st</strong></p>
    
    // Actual output (wrong)
    <p>_te_<strong>st</strong></p>
    

    This was working with v1.1.0 and is not working with v1.1.1.

  3. fredck commented on Sep 3, 2020

    @fredck

    Is the following case included in the issue?

    Figured that this issue is much older than v1.1.1, so I've opened #1754 for the introduced regression.

  4. calculuschild commented on Dec 9, 2020

    @calculuschild
    Contributor

    As far as the cases in the original post, keep these notes in mind:

    1. Underscores can't be used for emphasis/strong inside of a word, because underscores are included in the set of "word characters" ( A-Z, a-z, 0-9, _ ) . That is, an underscore is just a normal _ if between two alphanumeric characters, according to the CommonMark spec.
    2. Asterisks do not have this restriction. Also, because asterisks do not count as "word characters", you can have underscores adjacent to them and they should work properly.

    That said, these are the correct outputs for each case (plus one more I added). Marked currently passes all of these except the all-asterisk one (case 4 below):

    Markdown CommonMark Spec Appearance
    **E_mp_**_ha_**_si_s** <strong>E_mp_</strong><em>ha</em><strong>_si_s</strong> E_mp_ha_si_s
    __E*mp*__*ha*__*si*s__ <strong>E<em>mp</em></strong><em>ha</em><strong><em>si</em>s</strong> Emphasis
    **E*mp***_ha_***si*s** <strong>E<em>mp</em></strong><em>ha</em><strong><em>si</em>s</strong> Emphasis
    **E*mp****ha****si*s** <strong>E<em>mp</em><em><strong>ha</strong></em><em>si</em>s</strong> Emphasis
    __E_mp____ha____si_s__ <strong>E_mp____ha____si_s</strong> E_mp____ha____si_s
  5. github-actions commented on Jun 1, 2021

    @github-actions

    🎉 This issue has been resolved in version 2.0.7 🎉

    The release is available on:

    Your semantic-release bot 📦🚀

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    L2 - annoyingcategory: inline elementscategory: mixed contentreleased

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions