trentm/python-markdown2

`middle-word-em=False` does not emit expected `strong`

Closed this issue · 1 comments

Describe the bug

I'd like to use middle-word-em to remove random italics where code-friendly is not enough. One such case is **worst_case_scenario** which should emit <p><strong>worst_case_scenario</strong></p> but instead emits <p>**worst_case_scenario**</p>.

NB: it does not emit strong even if there's no _ in the input.

To Reproduce

from markdown2 import Markdown

def test_middle_word_em():
    md = Markdown(extras={"middle-word-em": False})
    assert md.convert("**worst_case_scenario**") == "<p><strong>worst_case_scenario</strong></p>"

You can verify the failure with pytest -vvv:

    def test_middle_word_em():
        md = Markdown(extras={"middle-word-em": False})
>       assert md.convert("**worst_case_scenario**") == "<p><strong>worst_case_scenario</strong></p>"
E       AssertionError: assert '<p>**worst_case_scenario**</p>\n' == '<p><strong>worst_case_scenario</strong></p>'
E         
E         - <p><strong>worst_case_scenario</strong></p>
E         + <p>**worst_case_scenario**</p>

Expected behavior
A clear and concise description of what you expected to happen.
**worst_case_scenario** should emit <p><strong>worst_case_scenario</strong></p>

Debug info
markdown2==2.5.0

Any extras being used:
middle-word-em: False

Additional context

it does not emit strong even if there's no _ in the input.

Thanks for the report! Fixed in #607