Skip to content

HTML comment handling doesn't match spec 0.31.2? #285

@robinst

Description

@robinst

I'm updating commonmark-java to version 0.31.2 of the spec and was wondering about HTML comment handling. Namely, given this spec:

An HTML comment consists of <!-->, <!--->, or <!--, a string of
characters not including the string -->, and --> (see the
HTML spec).

I think these two should be parsed as comments:

foo <!-- test --->
foo <!-- test ---->

However, with the current dingus they're not (example 1, example 2):

<p>foo &lt;!-- test ---&gt;</p>
<p>foo &lt;!-- test ----&gt;</p>

The reason is probably this regex:

var HTMLCOMMENT = "<!-->|<!--->|<!--(?:[^-]|-[^-]|--[^>])*-->"

I think <!-->|<!--->|<!--.*?--> would work as expected.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions