Skip to content

Support backticks inside inline code spans #226

Closed

Description

@projetmbc

With the version 1.1.0, the following code

from markdownify import markdownify as md

print(
    md(
        '<code>We have to `manage` this.</code>',
    )
)

should print

``We have to `manage` this.``

instead of

`We have to `manage` this.`

In one of my project, I have fixed this using the following lines of code.

    def convert_code(self, el, text, parent_tags = None):
        if el.parent.name == "pre":
            return text

        code = el.get_text()

        if "`" in code:
            code = f"`{code}`"

        return f"`{code}`"

Activity

  1. changed the title [-]Code using `[/-] [+]BUG - Inline code using `[/+] on Jun 24, 2025
  2. changed the title [-]BUG - Inline code using `[/-] [+]Support backticks inside inline code spans[/+] on Jun 29, 2025
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