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

Markdown mixed bold / italic parsed incorrectly #1353

Closed
Havunen opened this issue Oct 15, 2018 · 4 comments · Fixed by #2075
Closed

Markdown mixed bold / italic parsed incorrectly #1353

Havunen opened this issue Oct 15, 2018 · 4 comments · Fixed by #2075
Labels
category: inline elements category: mixed content L2 - annoying Similar to L1 - broken but there is a known workaround available for the issue released

Comments

@Havunen
Copy link

Havunen commented Oct 15, 2018

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.

@styfle styfle added L2 - annoying Similar to L1 - broken but there is a known workaround available for the issue category: mixed content category: inline elements labels Oct 15, 2018
@fredck
Copy link

fredck commented Sep 3, 2020

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.

@fredck
Copy link

fredck commented Sep 3, 2020

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.

@calculuschild
Copy link
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

@calculuschild calculuschild mentioned this issue May 30, 2021
5 tasks
@github-actions
Copy link

github-actions bot commented Jun 1, 2021

🎉 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
Labels
category: inline elements category: mixed content L2 - annoying Similar to L1 - broken but there is a known workaround available for the issue released
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants