Skip to content

Parse the two hyphens in the HTML comment as one hyphen #72

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
ota-meshi opened this issue May 10, 2020 · 2 comments · Fixed by #73
Closed

Parse the two hyphens in the HTML comment as one hyphen #72

ota-meshi opened this issue May 10, 2020 · 2 comments · Fixed by #73

Comments

@ota-meshi
Copy link
Member

I would like to be able to accept directive comment descriptions in eslint-plugin-vue.
However, the comment value did not produce the expected result.

The following HTML comment is parsed as follows:

<template>
  <!-- eslint-disable -- description -->
</template>
[
  {
    "type": "HTMLComment",
    "range": [ /* ...  */ ],
    "loc": { /* ...  */ },
    "value": " eslint-disable - description "
  }
]

I expect the following results.

[
  {
    "type": "HTMLComment",
    "range": [ /* ...  */ ],
    "loc": { /* ...  */ },
-    "value": " eslint-disable - description "
+    "value": " eslint-disable -- description "
  }
]

I've heard that the old HTML specification should avoid consecutive hyphens.
Do you think you should avoid separating the description with two hyphens?

@mysticatea
Copy link
Member

Thank you for your report.

It looks like a bug.

The HTML comment parsing is defined in https://html.spec.whatwg.org/multipage/parsing.html, from the section 12.2.5.43 to 12.2.5.52. It's complex a bit.

"Comment state" -> "Comment end dash state" -> "Comment end state", then it says "Append two U+002D HYPHEN-MINUS characters (-) to the comment token's data.", but the tokenizer appends only one hypen.

@ota-meshi
Copy link
Member Author

Thank you for your comment!
I have opened a PR to fix this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants