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

Bad handling of two consecutive bold words #541

Closed
m417z opened this issue Dec 5, 2023 · 6 comments · Fixed by #545
Closed

Bad handling of two consecutive bold words #541

m417z opened this issue Dec 5, 2023 · 6 comments · Fixed by #545
Labels
Bug Priority High priority tickets

Comments

@m417z
Copy link
Contributor

m417z commented Dec 5, 2023

Describe the bug
See example below.

To Reproduce

**a** b **c**

Code:

print(markdown2.markdown('**a** b **c**'))

Expected behavior

<p><strong>a</strong> b <strong>c</strong></p>

Actual:

<p><strong>a<em>* b *</em>c</strong></p>

Debug info
Version of library being used: 2.4.11

Any extras being used: None

Additional context
Add any other context about the problem here.

@fghaas
Copy link
Contributor

fghaas commented Dec 7, 2023

I can confirm this; it appears to have slipped into the 2.4.11 release. 2.4.10 did not suffer from this issue. Downgrading to 2.4.10 is thus a valid temporary workaround.

Not sure if this helps, but per git bisect the commit that broke this was 0eafad6 (from #531).

@nicholasserra
Copy link
Collaborator

Thanks for the reports, we'll check this out

@nicholasserra nicholasserra added the Priority High priority tickets label Dec 7, 2023
m417z added a commit to m417z/ntdoc that referenced this issue Dec 9, 2023
m417z added a commit to m417z/ntdoc that referenced this issue Dec 9, 2023
Crozzers added a commit to Crozzers/python-markdown2 that referenced this issue Dec 9, 2023
@Crozzers
Copy link
Contributor

Crozzers commented Dec 9, 2023

Hi, thanks for reporting this. I've opened a linked PR to address this, let me know if I've missed anything.

syntaxsurge pushed a commit to syntaxsurge/python-markdown2 that referenced this issue Dec 9, 2023
@gitbra
Copy link

gitbra commented Dec 9, 2023

Hi, thanks for the proposed fix.
I tested and the spaces inside ** are not well appreciated, else it looks fine to me.

**Word** **Word **

<p><strong>Word</strong> <em>*Word *</em></p>

@Crozzers
Copy link
Contributor

Crozzers commented Dec 9, 2023

That is intentional and should match the behaviour of previous versions. From the CommonMark spec:

A right-flanking delimiter run is a delimiter run that is (1) not preceded by Unicode whitespace, and...

Although the <em> behaviour seems to be inconsistent with this. I'll add a commit to fix that
EDIT: it looks like the <em> regex considers the first * of the closing delimiter as a match for (?<=\S)*. Doesn't seem like an issue to me

nicholasserra added a commit that referenced this issue Dec 10, 2023
Fix bad handling of consecutive bold words (#541)
@fghaas
Copy link
Contributor

fghaas commented Dec 11, 2023

Thanks! I think you may still want to add an entry to the changelog for this fix — I've taken the liberty to submit a PR for that (see #553).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Priority High priority tickets
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants