Skip to content

<a> tag links should not be constructed inside preformatted tags #164

Closed

Description

@chrispy-snps

The conversion for <a> tags creates links inside <code> and <pre> tags:

from markdownify import markdownify as md

print(md("<code><a href='http://foo.com/'>foo.com</a></code>"))
# `[foo.com](http://foo.com/)`

print(md("<pre><a href='http://foo.com/'>foo.com</a></pre>"))
# ```
# [foo.com](http://foo.com/)
# ```

This is incorrect because content inside Markdown code spans and code blocks is interpreted literally. In these cases, the tags should be rendered as plaintext.

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