Skip to content

Incorrect HTML output for code span containing </> #1528

Closed
@dbader

Description

@dbader

In markdown==3.8, a code span containing the string "`</>`" is incorrectly rendered. Instead of producing the expected HTML output with the characters escaped, it strips the content entirely:

>>> import markdown
>>> markdown.__version__
'3.8'

>>> markdown.markdown('`</>`')
'<p>``</p>'

Expected result:

`'<p><code>&lt;/&gt;</code></p>'`

Other examples that work correctly:

>>> markdown.markdown('`<`')
✅ '<p><code>&lt;</code></p>'
>>> markdown.markdown('`</`')
✅ '<p><code>&lt;/</code></p>'
>>> markdown.markdown('`</>`')
❌ '<p>``</p>'
>>> markdown.markdown('`/>`')
✅ '<p><code>/&gt;</code></p>'
>>> markdown.markdown('`>`')
✅ '<p><code>&gt;</code></p>'

This issue appears specific to the combination </>. Would appreciate any insight into whether this is a known bug, an edge case in the parser, or an intentional (though surprising) behavior. Thanks!

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