Skip to content

Multiple regressions since #665 #671

Closed

Description

All are based on real input problems.

Version: d18e2fc

import markdown2

# Actual: <p><strong>x[<strong>y</strong>]</strong></p>
# Expected: <p><strong>x[</strong>y<strong>]</strong></p>
markdown_text = R"""
**x[**y**]**
"""
print(markdown2.markdown(markdown_text))

# Actual: <p>*A->*<strong>B</strong></p>
# Expected: <p><em>A-></em><strong>B</strong></p>
markdown_text = R"""
*A->***B**
"""
print(markdown2.markdown(markdown_text))

# Actual: <p>**A->**<strong>B</strong></p>
# Expected: <p><strong>A-></strong><strong>B</strong></p>
markdown_text = R"""
**A->****B**
"""
print(markdown2.markdown(markdown_text))

# Actual: <p><em><em>A</em> B_</em>C*</p>
# Expected: <p>*<em>A</em> B_<em>C*</em></p>
markdown_text = R"""
**A* B_*C*
"""
print(markdown2.markdown(markdown_text))

# Actual: <p>**A* B C_D. X Y Z *</p>
# Expected: <p>*<em>A</em> B C_D. X Y Z *</p>
markdown_text = R"""
**A* B C_D. X Y Z *
"""
print(markdown2.markdown(markdown_text))

# Actual: <p>**x.**y</p>
# Expected: <p><strong>x.</strong>y</p>
markdown_text = R"""
**x.**y
"""
print(markdown2.markdown(markdown_text, safe_mode='escape'))

# code-friendly should treat underscores as literal characters
#
# Actual: <p><strong>A</strong><em>B_C_D_E_F</em>G</p>
# Expected: <p>__A___B_C_D_E_F_G</p>
markdown_text = R"""
__A___B_C_D_E_F_G
"""
print(markdown2.markdown(markdown_text, extras={ 'code-friendly': None }))

# code-friendly should treat underscores as literal characters
#
# Actual: <p><strong>A_B</strong> <a href="https://example.com/">C<em>D</em>E</a></p>
# Expected: <p><strong>A_B</strong> <a href="https://example.com/">C_D_E</a></p>
markdown_text = R"""
**A_B** [C_D_E](https://example.com/)
"""
print(markdown2.markdown(markdown_text, extras={ 'code-friendly': None }))

Activity

  1. added 2 commits that reference this issue on Feb 8, 2026
    e04e805
    f41e67b
  2. Crozzers commented on Feb 8, 2026

    @Crozzers
    Contributor

    @justanotheranonymoususer I've pushed some changes to Crozzers/gfm-em-issue671 that fixes this. If you want to test that before I raise a PR and raise any extra issues with it.


    Regarding that first example, that's actually valid GFM. From the rules:

    A right-flanking delimiter run is a delimiter run that is (1) not preceded by Unicode whitespace, and either (2a) not preceded by a punctuation character, or (2b) preceded by a punctuation character and followed by Unicode whitespace or a punctuation character.

    x[**y is a left flanking delimiter run, not right flanking so in this instance nesting the <strong> is valid.

    Same issue with this example: **x.**y. That second run is not a closing delimiter run and if you put it into Github's markdown preview it doesn't render it.

    Rest of them should be fixed though

  3. added a commit that references this issue on Feb 12, 2026
    a7ffb0a
  4. Crozzers commented on Feb 12, 2026

    @Crozzers
    Contributor

    Ok there are some redos issues with those fixes. I'll try and fix those as well

  5. added a commit that references this issue on Feb 15, 2026
    a1e159c
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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions