Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Emphasis and strong not working together #342

Open
rgrignon1 opened this issue May 2, 2023 · 1 comment
Open

Emphasis and strong not working together #342

rgrignon1 opened this issue May 2, 2023 · 1 comment

Comments

@rgrignon1
Copy link

rgrignon1 commented May 2, 2023

When using a markdown string containing both emphasis and strong effect, only the strong effect is used and the emphasis characters are left like normal characters.

Example:

"This text should be both ***bold and italic***"

When rendering it with the AstRenderer, I would expect something like:

[
    {
        "type": "paragraph",
        "children": [
            {
                "type": "text",
                "text": "This text should be both "
            },
            {
                "type": "emphasis",
                "children": [
                    {
                        "type": "strong",
                        "children": [
                            {
                                "type": "text",
                                "text": "bold and italic"
                            }
                        ]
                    }
                ]
            }
        ]
    }
]

But instead I get this:

[
    {
        "type": "paragraph",
        "children": [
            {
                "type": "text",
                "text": "This text should be both *"
            },
            {
                "type": "strong",
                "children": [
                    {
                        "type": "text",
                        "text": "bold and italic"
                    }
                ]
            },
            {
                "type": "text",
                "text": "*"
            }
        ]
    }
]

Using both bold and italic is a pretty common use case with markdown (and as we can see here, the github markdown parser accept it), I'm surprised nobody else raised this error before.

I didn't test if the version 3.0 have it fixed, I'm only using the latest released version 2.0.5

@lepture
Copy link
Owner

lepture commented Jun 8, 2023

version 3.0's result:

>>> import mistune
>>> text = "This text should be both ***bold and italic***"
>>> mistune.html(text)
'<p>This text should be both <em><strong>bold and italic</strong></em></p>\n'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants