Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion markdown_it/common/html_re.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = "<!---?>|<!--[\\s\\S]*?-->"
processing = "<[?][\\s\\S]*?[?]>"
declaration = "<![A-Za-z][^>]*>"
cdata = "<!\\[CDATA\\[[\\s\\S]*?\\]\\]>"
Expand Down
17 changes: 17 additions & 0 deletions tests/test_html_inline.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 == "<p>" + src + "</p>\n"


@pytest.mark.parametrize(
"src",
[
"<!-- note --->", # the comment text ends with "-"
"<!--- note --->",
"<!----->",
"<!------>",
"<!-- note ---->",
"<!-- a -- b --->",
],
)
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"<p>x {src} y</p>\n"