Skip to content

Placeholder in HTML markup #1571

Closed

Description

@zyxw59

When the markdown source contains an inline HTML comment which contains a markdown link whose text contains markdown formatting, the resulting HTML contains the placeholder for the formatted text.

>>> markdown.markdown("For example <!-- [**Bold link**](http://example.com) -->")
'<p>For example <!-- <a href="http://example.com">\x02klzzwxh:0000\x03</a> --></p>'

This is similar to #42, but only occurs when there is formatting in the link text.

Also notable is that this behavior for comments only occurs when the comment does not start a line — HTML comments at the start of a line are not processed for markdown syntax at all.

For a real-world example of this bug, see rust-lang/this-week-in-rust#7299

Activity

  1. waylan commented on Dec 1, 2025

    @waylan
    Member

    Sigh. I can confirm. We have another weird edge case. This is different from the block-level raw HTML case because Markdown requires block level parsing only when the block starts at the beginning of the line. In other words, the HTML comment is parsed as in-line HTML, which takes a different code path. It also means that Markdown parsing happens inside the comment.

  2. added
    bugBug report.
    coreRelated to the core parser code.
    confirmedConfirmed bug report or approved feature request.
    on Dec 1, 2025
  3. waylan commented on Dec 1, 2025

    @waylan
    Member

    I believe the issue is that we are only escaping one level but we have a placeholder inside a placeholder. Therefore, we need to unescaped until there are no more placeholders.

    https://github.com/Python-Markdown/markdown/blob/master/markdown/inlinepatterns.py#L511-L527

  4. added a commit that references this issue on Dec 1, 2025
    eee3032
  5. added a commit that references this issue on Dec 3, 2025
    2b49115
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

    bugBug report.confirmedConfirmed bug report or approved feature request.coreRelated to the core parser code.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions