lepture/mistune

Emphasis and strong not working together

rgrignon1 opened this issue · 1 comments

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

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'