Commits (8)
# html-validate changelog
### [4.10.1](https://gitlab.com/html-validate/html-validate/compare/v4.10.0...v4.10.1) (2021-04-25)
### Bug Fixes
- handle directives with excessive whitespace ([0400563](https://gitlab.com/html-validate/html-validate/commit/040056356589b7caf6ae18ee59d11a2f25c9ea44))
## [4.10.0](https://gitlab.com/html-validate/html-validate/compare/v4.9.0...v4.10.0) (2021-04-18)
### Features
......
This diff is collapsed.
{
"name": "html-validate",
"version": "4.10.0",
"version": "4.10.1",
"description": "html linter",
"keywords": [
"html",
......@@ -131,7 +131,7 @@
"prompts": "^2.0.0"
},
"devDependencies": {
"@babel/core": "7.13.15",
"@babel/core": "7.13.16",
"@babel/preset-env": "7.13.15",
"@commitlint/cli": "12.1.1",
"@html-validate/commitlint-config": "1.3.1",
......@@ -161,12 +161,12 @@
"dgeni": "0.4.14",
"dgeni-front-matter": "2.0.3",
"dgeni-packages": "0.29.0",
"eslint": "7.24.0",
"eslint": "7.25.0",
"eslint-plugin-security": "1.4.0",
"eslint-plugin-sonarjs": "0.6.0",
"eslint-plugin-sonarjs": "0.7.0",
"font-awesome": "4.7.0",
"front-matter": "4.0.2",
"grunt": "1.3.0",
"grunt": "1.4.0",
"grunt-browserify": "6.0.0",
"grunt-cli": "1.4.2",
"grunt-contrib-connect": "3.0.0",
......@@ -182,10 +182,10 @@
"marked": "2.0.3",
"minimatch": "3.0.4",
"npm-pkg-lint": "1.3.0",
"postcss": "8.2.10",
"postcss": "8.2.12",
"prettier": "2.2.1",
"pretty-format": "26.6.2",
"sass": "1.32.10",
"sass": "1.32.11",
"semantic-release": "17.4.2",
"serve-static": "1.14.1",
"stringmap": "0.2.2",
......
......@@ -706,17 +706,59 @@ describe("lexer", () => {
expect(token.next().done).toBeTruthy();
});
it("html-validate directive", () => {
expect.assertions(3);
const token = lexer.tokenize(
inlineSource("<!-- [html-validate-action options: comment] -->")
);
expect(token.next()).toBeToken({
type: TokenType.DIRECTIVE,
data: ["<!-- [html-validate-action options: comment] -->", "action options: comment"],
describe("html-validate directive", () => {
it("with comment", () => {
expect.assertions(3);
const token = lexer.tokenize(
inlineSource("<!-- [html-validate-action options: comment] -->")
);
expect(token.next()).toBeToken({
type: TokenType.DIRECTIVE,
data: ["<!-- [html-validate-action options: comment] -->", "action options: comment"],
});
expect(token.next()).toBeToken({ type: TokenType.EOF });
expect(token.next().done).toBeTruthy();
});
it("without comment", () => {
expect.assertions(3);
const token = lexer.tokenize(inlineSource("<!-- [html-validate-action options] -->"));
expect(token.next()).toBeToken({
type: TokenType.DIRECTIVE,
data: ["<!-- [html-validate-action options] -->", "action options"],
});
expect(token.next()).toBeToken({ type: TokenType.EOF });
expect(token.next().done).toBeTruthy();
});
it("with excessive whitespace", () => {
expect.assertions(3);
const token = lexer.tokenize(
inlineSource("<!-- \t\n\t [html-validate-action options: comment] \t\n\t -->")
);
expect(token.next()).toBeToken({
type: TokenType.DIRECTIVE,
data: [
"<!-- \t\n\t [html-validate-action options: comment] \t\n\t -->",
"action options: comment",
],
});
expect(token.next()).toBeToken({ type: TokenType.EOF });
expect(token.next().done).toBeTruthy();
});
it("with no whitespace", () => {
expect.assertions(3);
const token = lexer.tokenize(
inlineSource("<!--[html-validate-action options: comment]-->")
);
expect(token.next()).toBeToken({
type: TokenType.DIRECTIVE,
data: ["<!--[html-validate-action options: comment]-->", "action options: comment"],
});
expect(token.next()).toBeToken({ type: TokenType.EOF });
expect(token.next().done).toBeTruthy();
});
expect(token.next()).toBeToken({ type: TokenType.EOF });
expect(token.next().done).toBeTruthy();
});
/* downlevel reveal is a non-standard "tag", handled separately */
......
......@@ -25,7 +25,7 @@ const MATCH_CDATA_BEGIN = /^<!\[CDATA\[/;
const MATCH_CDATA_END = /^[^]*?]]>/;
const MATCH_SCRIPT_DATA = /^[^]*?(?=<\/script)/;
const MATCH_SCRIPT_END = /^<(\/)(script)/;
const MATCH_DIRECTIVE = /^<!--\s\[html-validate-(.*?)]\s-->/;
const MATCH_DIRECTIVE = /^<!--\s*\[html-validate-(.*?)]\s*-->/;
const MATCH_COMMENT = /^<!--([^]*?)-->/;
const MATCH_CONDITIONAL = /^<!\[([^\]]*?)\]>/;
......