mirror of
https://github.com/DavidAnson/markdownlint.git
synced 2025-12-30 20:48:48 +01:00
Update clearHtmlCommentText helper to match CommonMark (instead of HTML) specification (refs #361).
This commit is contained in:
parent
6f39df1417
commit
c4e236b858
6 changed files with 148 additions and 48 deletions
65
test/html-comments.md
Normal file
65
test/html-comments.md
Normal file
|
|
@ -0,0 +1,65 @@
|
|||
# HTML Comments
|
||||
|
||||
## Block Comments
|
||||
|
||||
<https://spec.commonmark.org/0.29/#html-blocks>
|
||||
|
||||
<!-- *comment * -->
|
||||
|
||||
<!-- *comment * -->text
|
||||
|
||||
<!-- *comment * -->
|
||||
|
||||
<!-- *code * -->
|
||||
|
||||
<!-- *comment *
|
||||
*comment * -->
|
||||
|
||||
<!-- *comment *
|
||||
*comment *
|
||||
*comment * -->
|
||||
|
||||
<!--> *{MD037} * -->
|
||||
|
||||
<!---> *{MD037} * -->
|
||||
|
||||
<!-- *comment * --->
|
||||
|
||||
<!-- -- *comment * -->
|
||||
|
||||
<!-- *comment * -- -->
|
||||
|
||||
## Inline Comments
|
||||
|
||||
<https://spec.commonmark.org/0.29/#html-comment>
|
||||
|
||||
t<!-- *comment * -->
|
||||
|
||||
t<!-- *comment * -->text
|
||||
|
||||
t<!-- *comment * -->
|
||||
|
||||
t<!-- *code * -->
|
||||
|
||||
t<!-- *comment *
|
||||
*comment * -->
|
||||
|
||||
t<!-- *comment *
|
||||
*comment *
|
||||
*comment * -->
|
||||
|
||||
t<!--> *{MD037} * -->
|
||||
|
||||
t<!---> *{MD037} * -->
|
||||
|
||||
t<!-- *{MD037} * --->
|
||||
|
||||
t<!-- -- *{MD037} * -->
|
||||
|
||||
t<!-- *{MD037} * -- -->
|
||||
|
||||
## Notes
|
||||
|
||||
It's important that the rule used above is one that calls
|
||||
`helpers.forEachLine` so `markdown-it` doesn't ignore any
|
||||
incorrectly-remaining comment blocks.
|
||||
|
|
@ -18,11 +18,11 @@ Hard tab
|
|||
Hard tab
|
||||
-->
|
||||
|
||||
<!--
|
||||
Text <!--
|
||||
Hard tab {MD010}
|
||||
Invalid--!>comment
|
||||
Hard tab {MD010}
|
||||
-->
|
||||
--> text
|
||||
|
||||
Te<!-- Hard tab -->xt
|
||||
|
||||
|
|
|
|||
|
|
@ -9,6 +9,12 @@ const helpers = require("../helpers");
|
|||
test("clearHtmlCommentTextValid", (t) => {
|
||||
t.plan(1);
|
||||
const validComments = [
|
||||
"<!-->",
|
||||
"<!--->",
|
||||
"<!---->",
|
||||
"<!-- comment -->",
|
||||
" <!-- comment -->",
|
||||
" <!-- comment -->",
|
||||
"<!-- text -->",
|
||||
"<!--text-->",
|
||||
"<!-- -->",
|
||||
|
|
@ -47,6 +53,12 @@ test("clearHtmlCommentTextValid", (t) => {
|
|||
"text"
|
||||
];
|
||||
const validResult = [
|
||||
"<!-->",
|
||||
"<!--->",
|
||||
"<!---->",
|
||||
"<!-- -->",
|
||||
" <!-- -->",
|
||||
" <!-- -->",
|
||||
"<!-- -->",
|
||||
"<!-- -->",
|
||||
"<!-- -->",
|
||||
|
|
@ -100,22 +112,12 @@ test("clearHtmlCommentTextInvalid", (t) => {
|
|||
"<!-->text-->",
|
||||
"<!--->text-->",
|
||||
"<!---->",
|
||||
// Restrictions from specification
|
||||
"<!-->-->",
|
||||
"<!-->t-->",
|
||||
"<!--->-->",
|
||||
"<!--->t-->",
|
||||
"<!--<!--t-->",
|
||||
"<!--t<!---->",
|
||||
"<!--t<!--t-->",
|
||||
// "<!---->t-->",
|
||||
// "<!--t-->-->",
|
||||
// "<!--t-->t-->",
|
||||
"<!----!>t-->",
|
||||
"<!--t--!>-->",
|
||||
"<!--t--!>t-->",
|
||||
"<!--<!--->",
|
||||
"<!--t<!--->"
|
||||
"<!---->t-->",
|
||||
" <!-- indented code block -->"
|
||||
];
|
||||
const actual = helpers.clearHtmlCommentText(invalidComments.join("\n"));
|
||||
const expected = invalidComments.join("\n");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue