diff --git a/markdown_it/common/html_re.py b/markdown_it/common/html_re.py index 88cddc44..1856c62d 100644 --- a/markdown_it/common/html_re.py +++ b/markdown_it/common/html_re.py @@ -15,7 +15,7 @@ open_tag = "<[A-Za-z][A-Za-z0-9\\-]*" + attribute + "*\\s*\\/?>" close_tag = "<\\/[A-Za-z][A-Za-z0-9\\-]*\\s*>" -comment = "" +comment = "" processing = "<[?][\\s\\S]*?[?]>" declaration = "]*>" cdata = "" diff --git a/tests/test_html_inline.py b/tests/test_html_inline.py index 4f118797..439695e8 100644 --- a/tests/test_html_inline.py +++ b/tests/test_html_inline.py @@ -72,3 +72,20 @@ def match(self, *args, **kwargs): html = MarkdownIt("commonmark").render(src) assert calls, "expected the regex to run for terminated constructs" assert html == "
" + src + "
\n" + + +@pytest.mark.parametrize( + "src", + [ + "", # the comment text ends with "-" + "", + "", + "", + "", + "", + ], +) +def test_comment_text_may_end_with_hyphen(src): + """CommonMark 0.31 only forbids ``-->`` inside the text of an HTML comment.""" + assert MarkdownIt("commonmark").renderInline(src) == src + assert MarkdownIt("commonmark").render(f"x {src} y") == f"x {src} y
\n"