diff --git a/package.json b/package.json index 2253f3c..5427caa 100644 --- a/package.json +++ b/package.json @@ -36,12 +36,13 @@ "devDependencies": { "babel-cli": "^6.8.0", "babel-preset-es2015": "^6.6.0", - "babel-preset-jsdoc-to-assert": "^1.0.1", + "babel-preset-jsdoc-to-assert": "^4.0.0", "babel-preset-power-assert": "^1.0.0", "babel-register": "^6.8.0", - "mocha": "^2.3.3", + "glob": "^7.1.1", + "mocha": "^3.2.0", "power-assert": "^1.4.0", - "textlint": "^6.7.0", + "textlint": "^7.2.2", "textlint-ast-test": "^1.1.3", "textlint-rule-no-todo": "^2.0.0" }, diff --git a/src/HTMLProcessor.js b/src/HTMLProcessor.js index ea154f6..ad9312b 100644 --- a/src/HTMLProcessor.js +++ b/src/HTMLProcessor.js @@ -8,6 +8,7 @@ export default class HTMLProcessor { static availableExtensions() { return [ + ".htm", ".html" ]; } diff --git a/src/html-to-ast.js b/src/html-to-ast.js index 8440a69..3c79a26 100644 --- a/src/html-to-ast.js +++ b/src/html-to-ast.js @@ -42,7 +42,7 @@ function mapNodeType(node, parent) { export function parse(html) { const ast = hast.parse(html); const src = new StructuredSource(html); - var tr = traverse(ast); + const tr = traverse(ast); tr.forEach(function (node) { if (this.notLeaf) { // avoid conflict @@ -53,7 +53,7 @@ export function parse(html) { } else if (node.type === "root") { // FIXME: workaround, should fix hast node.type = nodeTypes[node.type]; - let position = src.rangeToLocation([0, html.length]); + const position = src.rangeToLocation([0, html.length]); // reverse adjust node.position = { start: {line: position.start.line, column: position.start.column + 1}, diff --git a/test/HTMLProcessor-test.js b/test/HTMLProcessor-test.js index 3ed6660..3f2c370 100644 --- a/test/HTMLProcessor-test.js +++ b/test/HTMLProcessor-test.js @@ -68,5 +68,29 @@ describe("HTMLProcessor-test", function () { }); }); }); + context("support file extensions", function () { + beforeEach(function () { + textlint = new TextLintCore(); + textlint.setupProcessors({ + HTMLProcessor: HTMLProcessor + }); + textlint.setupRules({ + "no-todo": require("textlint-rule-no-todo") + }); + }); + it("support {.html, .htm}", function () { + const fixturePathList = [ + path.join(__dirname, "/fixtures/test.html"), + path.join(__dirname, "/fixtures/test.htm") + ]; + const promises = fixturePathList.map((filePath) => { + return textlint.lintFile(filePath).then(results => { + assert(results.messages.length > 0); + assert(results.filePath === filePath); + }); + }); + return Promise.all(promises); + }); + }); }); }); \ No newline at end of file diff --git a/test/ast-test-case/adoption/config.json b/test/ast-test-case/adoption/config.json new file mode 100644 index 0000000..a875830 --- /dev/null +++ b/test/ast-test-case/adoption/config.json @@ -0,0 +1,3 @@ +{ + "fragment": true +} diff --git a/test/ast-test-case/adoption/index.html b/test/ast-test-case/adoption/index.html new file mode 100644 index 0000000..d738cc0 --- /dev/null +++ b/test/ast-test-case/adoption/index.html @@ -0,0 +1 @@ +

diff --git a/test/ast-test-case/adoption/index.json b/test/ast-test-case/adoption/index.json new file mode 100644 index 0000000..bfff8bd --- /dev/null +++ b/test/ast-test-case/adoption/index.json @@ -0,0 +1,126 @@ +{ + "type": "Document", + "children": [ + { + "type": "Link", + "tagName": "a", + "properties": {}, + "children": [ + { + "type": "Html", + "tagName": "b", + "properties": {}, + "children": [ + { + "type": "Html", + "tagName": "b", + "properties": {}, + "children": [ + { + "type": "Paragraph", + "tagName": "p", + "properties": {}, + "children": [], + "loc": { + "start": { + "line": 1, + "column": 9 + }, + "end": { + "line": 1, + "column": 16 + } + }, + "range": [ + 9, + 16 + ], + "raw": "

" + } + ], + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 1, + "column": 16 + } + }, + "range": [ + 6, + 16 + ], + "raw": "

" + } + ], + "loc": { + "start": { + "line": 1, + "column": 3 + }, + "end": { + "line": 1, + "column": 16 + } + }, + "range": [ + 3, + 16 + ], + "raw": "

" + } + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 16 + } + }, + "range": [ + 0, + 16 + ], + "raw": "

" + }, + { + "type": "Str", + "value": "\n", + "loc": { + "start": { + "line": 1, + "column": 16 + }, + "end": { + "line": 2, + "column": 0 + } + }, + "range": [ + 16, + 17 + ], + "raw": "\n" + } + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 0 + } + }, + "range": [ + 0, + 17 + ], + "raw": "

\n" +} \ No newline at end of file diff --git a/test/ast-test-case/adoption/result.html b/test/ast-test-case/adoption/result.html new file mode 100644 index 0000000..f3384ac --- /dev/null +++ b/test/ast-test-case/adoption/result.html @@ -0,0 +1,2 @@ +

+

\ No newline at end of file diff --git a/test/ast-test-case/body-body-attributes/config.json b/test/ast-test-case/body-body-attributes/config.json new file mode 100644 index 0000000..0967ef4 --- /dev/null +++ b/test/ast-test-case/body-body-attributes/config.json @@ -0,0 +1 @@ +{} diff --git a/test/ast-test-case/body-body-attributes/index.html b/test/ast-test-case/body-body-attributes/index.html new file mode 100644 index 0000000..9cdf5d6 --- /dev/null +++ b/test/ast-test-case/body-body-attributes/index.html @@ -0,0 +1,3 @@ + + + diff --git a/test/ast-test-case/body-body-attributes/index.json b/test/ast-test-case/body-body-attributes/index.json new file mode 100644 index 0000000..3a41865 --- /dev/null +++ b/test/ast-test-case/body-body-attributes/index.json @@ -0,0 +1,156 @@ +{ + "type": "Document", + "children": [ + { + "type": "Html", + "tagName": "html", + "properties": {}, + "children": [ + { + "type": "Str", + "value": "\n", + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 2, + "column": 0 + } + }, + "range": [ + 6, + 7 + ], + "raw": "\n" + }, + { + "type": "Html", + "tagName": "body", + "properties": { + "id": "a", + "title": "b", + "className": [ + "c" + ], + "type": "UNKNOWN" + }, + "children": [ + { + "type": "Str", + "value": "\n", + "loc": { + "start": { + "line": 2, + "column": 33 + }, + "end": { + "line": 3, + "column": 0 + } + }, + "range": [ + 40, + 41 + ], + "raw": "\n" + }, + { + "type": "Html", + "tagName": "body", + "properties": { + "className": [ + "d" + ], + "onclick": "e", + "type": "UNKNOWN" + }, + "children": [ + { + "type": "Str", + "value": "\n", + "loc": { + "start": { + "line": 3, + "column": 28 + }, + "end": { + "line": 4, + "column": 0 + } + }, + "range": [ + 69, + 70 + ], + "raw": "\n" + } + ], + "loc": { + "start": { + "line": 3, + "column": 0 + }, + "end": { + "line": 4, + "column": 1 + } + }, + "range": [ + 41, + 71 + ], + "raw": "\n" + } + ], + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 4, + "column": 1 + } + }, + "range": [ + 7, + 71 + ], + "raw": "\n\n" + } + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 4, + "column": 1 + } + }, + "range": [ + 0, + 71 + ], + "raw": "\n\n\n" + } + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 4, + "column": 0 + } + }, + "range": [ + 0, + 70 + ], + "raw": "\n\n\n" +} \ No newline at end of file diff --git a/test/ast-test-case/body-body-attributes/result.html b/test/ast-test-case/body-body-attributes/result.html new file mode 100644 index 0000000..1c798e5 --- /dev/null +++ b/test/ast-test-case/body-body-attributes/result.html @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/test/ast-test-case/body-html-attributes/config.json b/test/ast-test-case/body-html-attributes/config.json new file mode 100644 index 0000000..0967ef4 --- /dev/null +++ b/test/ast-test-case/body-html-attributes/config.json @@ -0,0 +1 @@ +{} diff --git a/test/ast-test-case/body-html-attributes/index.html b/test/ast-test-case/body-html-attributes/index.html new file mode 100644 index 0000000..7e55c1b --- /dev/null +++ b/test/ast-test-case/body-html-attributes/index.html @@ -0,0 +1,3 @@ + + + diff --git a/test/ast-test-case/body-html-attributes/index.json b/test/ast-test-case/body-html-attributes/index.json new file mode 100644 index 0000000..e4341e5 --- /dev/null +++ b/test/ast-test-case/body-html-attributes/index.json @@ -0,0 +1,156 @@ +{ + "type": "Document", + "children": [ + { + "type": "Html", + "tagName": "html", + "properties": {}, + "children": [ + { + "type": "Str", + "value": "\n", + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 2, + "column": 0 + } + }, + "range": [ + 6, + 7 + ], + "raw": "\n" + }, + { + "type": "Html", + "tagName": "body", + "properties": { + "id": "a", + "title": "b", + "className": [ + "c" + ], + "type": "UNKNOWN" + }, + "children": [ + { + "type": "Str", + "value": "\n", + "loc": { + "start": { + "line": 2, + "column": 33 + }, + "end": { + "line": 3, + "column": 0 + } + }, + "range": [ + 40, + 41 + ], + "raw": "\n" + }, + { + "type": "Html", + "tagName": "html", + "properties": { + "className": [ + "d" + ], + "onclick": "e", + "type": "UNKNOWN" + }, + "children": [ + { + "type": "Str", + "value": "\n", + "loc": { + "start": { + "line": 3, + "column": 28 + }, + "end": { + "line": 4, + "column": 0 + } + }, + "range": [ + 69, + 70 + ], + "raw": "\n" + } + ], + "loc": { + "start": { + "line": 3, + "column": 0 + }, + "end": { + "line": 4, + "column": 1 + } + }, + "range": [ + 41, + 71 + ], + "raw": "\n" + } + ], + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 4, + "column": 1 + } + }, + "range": [ + 7, + 71 + ], + "raw": "\n\n" + } + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 4, + "column": 1 + } + }, + "range": [ + 0, + 71 + ], + "raw": "\n\n\n" + } + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 4, + "column": 0 + } + }, + "range": [ + 0, + 70 + ], + "raw": "\n\n\n" +} \ No newline at end of file diff --git a/test/ast-test-case/body-html-attributes/result.html b/test/ast-test-case/body-html-attributes/result.html new file mode 100644 index 0000000..e03bef8 --- /dev/null +++ b/test/ast-test-case/body-html-attributes/result.html @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/test/ast-test-case/character-data/config.json b/test/ast-test-case/character-data/config.json new file mode 100644 index 0000000..a875830 --- /dev/null +++ b/test/ast-test-case/character-data/config.json @@ -0,0 +1,3 @@ +{ + "fragment": true +} diff --git a/test/ast-test-case/character-data/index.html b/test/ast-test-case/character-data/index.html new file mode 100644 index 0000000..2b3ce53 --- /dev/null +++ b/test/ast-test-case/character-data/index.html @@ -0,0 +1,21 @@ + + +Echo]]> + + + +

You can add a string to a number, but this stringifies the number:

+ + x<y + + + 3 + = + x>y3 + diff --git a/test/ast-test-case/character-data/index.json b/test/ast-test-case/character-data/index.json new file mode 100644 index 0000000..1ceb898 --- /dev/null +++ b/test/ast-test-case/character-data/index.json @@ -0,0 +1,554 @@ +{ + "type": "Document", + "children": [ + { + "type": "Comment", + "value": "\nCDATA in HTML is no longer allowed.\nIt will be parsed like a declaration (``, just like\nthe doctype), which means `>`s will break out of them.\nThen, it’ll result in a comment.\n\nCDATA in foreign contet is allowed, but is also “garbled”.\n", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 8, + "column": 3 + } + }, + "range": [ + 0, + 254 + ], + "raw": "" + }, + { + "type": "Str", + "value": "\n\n", + "loc": { + "start": { + "line": 8, + "column": 3 + }, + "end": { + "line": 10, + "column": 0 + } + }, + "range": [ + 254, + 256 + ], + "raw": "\n\n" + }, + { + "type": "UNKNOWN", + "value": "Echo", + "loc": { + "start": { + "line": 10, + "column": 0 + }, + "end": { + "line": 10, + "column": 31 + } + }, + "range": [ + 256, + 287 + ], + "raw": "Echo]]>" + }, + { + "type": "Str", + "value": "\n\n", + "loc": { + "start": { + "line": 10, + "column": 31 + }, + "end": { + "line": 12, + "column": 0 + } + }, + "range": [ + 287, + 289 + ], + "raw": "\n\n" + }, + { + "type": "UNKNOWN", + "value": "", + "loc": { + "start": { + "line": 12, + "column": 0 + }, + "end": { + "line": 12, + "column": 12 + } + }, + "range": [ + 289, + 301 + ], + "raw": "" + }, + { + "type": "Str", + "value": "\n\n", + "loc": { + "start": { + "line": 12, + "column": 12 + }, + "end": { + "line": 14, + "column": 0 + } + }, + "range": [ + 301, + 303 + ], + "raw": "\n\n" + }, + { + "type": "Paragraph", + "tagName": "p", + "properties": {}, + "children": [ + { + "type": "Str", + "value": "You can add a string to a number, but this stringifies the number:", + "loc": { + "start": { + "line": 14, + "column": 3 + }, + "end": { + "line": 14, + "column": 69 + } + }, + "range": [ + 306, + 372 + ], + "raw": "You can add a string to a number, but this stringifies the number:" + } + ], + "loc": { + "start": { + "line": 14, + "column": 0 + }, + "end": { + "line": 14, + "column": 73 + } + }, + "range": [ + 303, + 376 + ], + "raw": "

You can add a string to a number, but this stringifies the number:

" + }, + { + "type": "Str", + "value": "\n", + "loc": { + "start": { + "line": 14, + "column": 73 + }, + "end": { + "line": 15, + "column": 0 + } + }, + "range": [ + 376, + 377 + ], + "raw": "\n" + }, + { + "type": "Html", + "tagName": "math", + "properties": {}, + "children": [ + { + "type": "Str", + "value": "\n ", + "loc": { + "start": { + "line": 15, + "column": 6 + }, + "end": { + "line": 16, + "column": 1 + } + }, + "range": [ + 383, + 385 + ], + "raw": "\n " + }, + { + "type": "Html", + "tagName": "ms", + "properties": {}, + "children": [ + { + "type": "UNKNOWN", + "value": "x" + } + ], + "loc": { + "start": { + "line": 16, + "column": 1 + }, + "end": { + "line": 16, + "column": 25 + } + }, + "range": [ + 385, + 409 + ], + "raw": "" + }, + { + "type": "Str", + "value": "\n ", + "loc": { + "start": { + "line": 16, + "column": 25 + }, + "end": { + "line": 17, + "column": 1 + } + }, + "range": [ + 409, + 411 + ], + "raw": "\n " + }, + { + "type": "Html", + "tagName": "mo", + "properties": {}, + "children": [ + { + "type": "Str", + "value": "+", + "loc": { + "start": { + "line": 17, + "column": 5 + }, + "end": { + "line": 17, + "column": 6 + } + }, + "range": [ + 415, + 416 + ], + "raw": "+" + } + ], + "loc": { + "start": { + "line": 17, + "column": 1 + }, + "end": { + "line": 17, + "column": 11 + } + }, + "range": [ + 411, + 421 + ], + "raw": "+" + }, + { + "type": "Str", + "value": "\n ", + "loc": { + "start": { + "line": 17, + "column": 11 + }, + "end": { + "line": 18, + "column": 1 + } + }, + "range": [ + 421, + 423 + ], + "raw": "\n " + }, + { + "type": "Html", + "tagName": "mn", + "properties": {}, + "children": [ + { + "type": "Str", + "value": "3", + "loc": { + "start": { + "line": 18, + "column": 5 + }, + "end": { + "line": 18, + "column": 6 + } + }, + "range": [ + 427, + 428 + ], + "raw": "3" + } + ], + "loc": { + "start": { + "line": 18, + "column": 1 + }, + "end": { + "line": 18, + "column": 11 + } + }, + "range": [ + 423, + 433 + ], + "raw": "3" + }, + { + "type": "Str", + "value": "\n ", + "loc": { + "start": { + "line": 18, + "column": 11 + }, + "end": { + "line": 19, + "column": 1 + } + }, + "range": [ + 433, + 435 + ], + "raw": "\n " + }, + { + "type": "Html", + "tagName": "mo", + "properties": {}, + "children": [ + { + "type": "Str", + "value": "=", + "loc": { + "start": { + "line": 19, + "column": 5 + }, + "end": { + "line": 19, + "column": 6 + } + }, + "range": [ + 439, + 440 + ], + "raw": "=" + } + ], + "loc": { + "start": { + "line": 19, + "column": 1 + }, + "end": { + "line": 19, + "column": 11 + } + }, + "range": [ + 435, + 445 + ], + "raw": "=" + }, + { + "type": "Str", + "value": "\n ", + "loc": { + "start": { + "line": 19, + "column": 11 + }, + "end": { + "line": 20, + "column": 1 + } + }, + "range": [ + 445, + 447 + ], + "raw": "\n " + }, + { + "type": "Html", + "tagName": "ms", + "properties": {}, + "children": [ + { + "type": "UNKNOWN", + "value": "x>y3", + "loc": { + "start": { + "line": 20, + "column": 5 + }, + "end": { + "line": 20, + "column": 21 + } + }, + "range": [ + 451, + 467 + ], + "raw": "y3]]>" + } + ], + "loc": { + "start": { + "line": 20, + "column": 1 + }, + "end": { + "line": 20, + "column": 26 + } + }, + "range": [ + 447, + 472 + ], + "raw": "y3]]>" + }, + { + "type": "Str", + "value": "\n", + "loc": { + "start": { + "line": 20, + "column": 26 + }, + "end": { + "line": 21, + "column": 0 + } + }, + "range": [ + 472, + 473 + ], + "raw": "\n" + } + ], + "loc": { + "start": { + "line": 15, + "column": 0 + }, + "end": { + "line": 21, + "column": 7 + } + }, + "range": [ + 377, + 480 + ], + "raw": "\n x<y\n +\n 3\n =\n x>y3\n" + }, + { + "type": "Str", + "value": "\n", + "loc": { + "start": { + "line": 21, + "column": 7 + }, + "end": { + "line": 22, + "column": 0 + } + }, + "range": [ + 480, + 481 + ], + "raw": "\n" + } + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 22, + "column": 0 + } + }, + "range": [ + 0, + 481 + ], + "raw": "\n\nEcho]]>\n\n\n\n

You can add a string to a number, but this stringifies the number:

\n\n x<y\n +\n 3\n =\n x>y3\n\n" +} \ No newline at end of file diff --git a/test/ast-test-case/character-data/result.html b/test/ast-test-case/character-data/result.html new file mode 100644 index 0000000..f9f388a --- /dev/null +++ b/test/ast-test-case/character-data/result.html @@ -0,0 +1,21 @@ + + +Echo]]> + + + +

You can add a string to a number, but this stringifies the number:

+ + + + + 3 + = + y3]]> + diff --git a/test/ast-test-case/comment/config.json b/test/ast-test-case/comment/config.json new file mode 100644 index 0000000..a875830 --- /dev/null +++ b/test/ast-test-case/comment/config.json @@ -0,0 +1,3 @@ +{ + "fragment": true +} diff --git a/test/ast-test-case/comment/index.html b/test/ast-test-case/comment/index.html new file mode 100644 index 0000000..47bc4f7 --- /dev/null +++ b/test/ast-test-case/comment/index.html @@ -0,0 +1,3 @@ + + + diff --git a/test/ast-test-case/comment/index.json b/test/ast-test-case/comment/index.json new file mode 100644 index 0000000..694d9e5 --- /dev/null +++ b/test/ast-test-case/comment/index.json @@ -0,0 +1,96 @@ +{ + "type": "Document", + "children": [ + { + "type": "Comment", + "value": "This is a comment", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 24 + } + }, + "range": [ + 0, + 24 + ], + "raw": "" + }, + { + "type": "Str", + "value": "\n\n", + "loc": { + "start": { + "line": 1, + "column": 24 + }, + "end": { + "line": 3, + "column": 0 + } + }, + "range": [ + 24, + 26 + ], + "raw": "\n\n" + }, + { + "type": "Comment", + "value": "", + "loc": { + "start": { + "line": 3, + "column": 0 + }, + "end": { + "line": 3, + "column": 7 + } + }, + "range": [ + 26, + 33 + ], + "raw": "" + }, + { + "type": "Str", + "value": "\n", + "loc": { + "start": { + "line": 3, + "column": 7 + }, + "end": { + "line": 4, + "column": 0 + } + }, + "range": [ + 33, + 34 + ], + "raw": "\n" + } + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 4, + "column": 0 + } + }, + "range": [ + 0, + 34 + ], + "raw": "\n\n\n" +} \ No newline at end of file diff --git a/test/ast-test-case/comments/config.json b/test/ast-test-case/comments/config.json new file mode 100644 index 0000000..a875830 --- /dev/null +++ b/test/ast-test-case/comments/config.json @@ -0,0 +1,3 @@ +{ + "fragment": true +} diff --git a/test/ast-test-case/comments/index.html b/test/ast-test-case/comments/index.html new file mode 100644 index 0000000..b2ecb51 --- /dev/null +++ b/test/ast-test-case/comments/index.html @@ -0,0 +1,12 @@ + + + + + + +Valid: + +Invalid: . +Invalid: . +Invalid: . +Invalid: . diff --git a/test/ast-test-case/comments/index.json b/test/ast-test-case/comments/index.json new file mode 100644 index 0000000..6ca56bd --- /dev/null +++ b/test/ast-test-case/comments/index.json @@ -0,0 +1,343 @@ +{ + "type": "Document", + "children": [ + { + "type": "Comment", + "value": "Alpha", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 12 + } + }, + "range": [ + 0, + 12 + ], + "raw": "" + }, + { + "type": "Str", + "value": " ", + "loc": { + "start": { + "line": 1, + "column": 12 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "range": [ + 12, + 13 + ], + "raw": " " + }, + { + "type": "Comment", + "value": "bravo", + "loc": { + "start": { + "line": 1, + "column": 13 + }, + "end": { + "line": 1, + "column": 25 + } + }, + "range": [ + 13, + 25 + ], + "raw": "" + }, + { + "type": "Str", + "value": "\n\n", + "loc": { + "start": { + "line": 1, + "column": 25 + }, + "end": { + "line": 3, + "column": 0 + } + }, + "range": [ + 25, + 27 + ], + "raw": "\n\n" + }, + { + "type": "Comment", + "value": "charlie", + "loc": { + "start": { + "line": 3, + "column": 0 + }, + "end": { + "line": 3, + "column": 14 + } + }, + "range": [ + 27, + 41 + ], + "raw": "" + }, + { + "type": "Comment", + "value": "delta", + "loc": { + "start": { + "line": 3, + "column": 14 + }, + "end": { + "line": 3, + "column": 26 + } + }, + "range": [ + 41, + 53 + ], + "raw": "" + }, + { + "type": "Str", + "value": "\n\n", + "loc": { + "start": { + "line": 3, + "column": 26 + }, + "end": { + "line": 5, + "column": 0 + } + }, + "range": [ + 53, + 55 + ], + "raw": "\n\n" + }, + { + "type": "Comment", + "value": "echo -- foxtrot", + "loc": { + "start": { + "line": 5, + "column": 0 + }, + "end": { + "line": 5, + "column": 22 + } + }, + "range": [ + 55, + 77 + ], + "raw": "" + }, + { + "type": "Str", + "value": "\n\nValid: ", + "loc": { + "start": { + "line": 5, + "column": 22 + }, + "end": { + "line": 7, + "column": 7 + } + }, + "range": [ + 77, + 86 + ], + "raw": "\n\nValid: " + }, + { + "type": "Comment", + "value": "My favourite operators are > and and " + }, + { + "type": "Str", + "value": "\n\nInvalid: ", + "loc": { + "start": { + "line": 7, + "column": 49 + }, + "end": { + "line": 9, + "column": 9 + } + }, + "range": [ + 128, + 139 + ], + "raw": "\n\nInvalid: " + }, + { + "type": "Comment", + "value": ">.\nInvalid: .\nInvalid: " + }, + { + "type": "Str", + "value": ".\nInvalid: ", + "loc": { + "start": { + "line": 10, + "column": 15 + }, + "end": { + "line": 11, + "column": 9 + } + }, + "range": [ + 161, + 172 + ], + "raw": ".\nInvalid: " + }, + { + "type": "Comment", + "value": "alpha" + }, + { + "type": "Str", + "value": ".\nInvalid: ", + "loc": { + "start": { + "line": 11, + "column": 30 + }, + "end": { + "line": 12, + "column": 9 + } + }, + "range": [ + 193, + 204 + ], + "raw": ".\nInvalid: " + }, + { + "type": "Comment", + "value": "charlie" + }, + { + "type": "Str", + "value": ".\n", + "loc": { + "start": { + "line": 12, + "column": 26 + }, + "end": { + "line": 13, + "column": 0 + } + }, + "range": [ + 221, + 223 + ], + "raw": ".\n" + } + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 13, + "column": 0 + } + }, + "range": [ + 0, + 223 + ], + "raw": " \n\n\n\n\n\nValid: \n\nInvalid: .\nInvalid: .\nInvalid: .\nInvalid: .\n" +} \ No newline at end of file diff --git a/test/ast-test-case/comments/result.html b/test/ast-test-case/comments/result.html new file mode 100644 index 0000000..1b6ffab --- /dev/null +++ b/test/ast-test-case/comments/result.html @@ -0,0 +1,12 @@ + + + + + + +Valid: + +Invalid: . +Invalid: . +Invalid: . +Invalid: . diff --git a/test/ast-test-case/directive-in-fragment/config.json b/test/ast-test-case/directive-in-fragment/config.json new file mode 100644 index 0000000..a875830 --- /dev/null +++ b/test/ast-test-case/directive-in-fragment/config.json @@ -0,0 +1,3 @@ +{ + "fragment": true +} diff --git a/test/ast-test-case/directive-in-fragment/index.html b/test/ast-test-case/directive-in-fragment/index.html new file mode 100644 index 0000000..c7c9915 --- /dev/null +++ b/test/ast-test-case/directive-in-fragment/index.html @@ -0,0 +1 @@ + diff --git a/test/ast-test-case/directive-in-fragment/index.json b/test/ast-test-case/directive-in-fragment/index.json new file mode 100644 index 0000000..efe1c6d --- /dev/null +++ b/test/ast-test-case/directive-in-fragment/index.json @@ -0,0 +1,59 @@ +{ + "type": "Document", + "children": [ + { + "type": "UNKNOWN", + "name": "!doctype", + "value": "!doctype", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "range": [ + 0, + 10 + ], + "raw": "" + }, + { + "type": "Str", + "value": "\n", + "loc": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 2, + "column": 0 + } + }, + "range": [ + 10, + 11 + ], + "raw": "\n" + } + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 0 + } + }, + "range": [ + 0, + 11 + ], + "raw": "\n" +} \ No newline at end of file diff --git a/test/ast-test-case/directive-in-fragment/result.html b/test/ast-test-case/directive-in-fragment/result.html new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/test/ast-test-case/directive-in-fragment/result.html @@ -0,0 +1 @@ + diff --git a/test/ast-test-case/doctype-almost-standards/config.json b/test/ast-test-case/doctype-almost-standards/config.json new file mode 100644 index 0000000..0967ef4 --- /dev/null +++ b/test/ast-test-case/doctype-almost-standards/config.json @@ -0,0 +1 @@ +{} diff --git a/test/ast-test-case/doctype-almost-standards/index.html b/test/ast-test-case/doctype-almost-standards/index.html new file mode 100644 index 0000000..f579722 --- /dev/null +++ b/test/ast-test-case/doctype-almost-standards/index.html @@ -0,0 +1 @@ + diff --git a/test/ast-test-case/doctype-almost-standards/index.json b/test/ast-test-case/doctype-almost-standards/index.json new file mode 100644 index 0000000..0fb707c --- /dev/null +++ b/test/ast-test-case/doctype-almost-standards/index.json @@ -0,0 +1,59 @@ +{ + "type": "Document", + "children": [ + { + "type": "UNKNOWN", + "name": "!doctype", + "value": "!DOCTYPE HTML PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\"", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 63 + } + }, + "range": [ + 0, + 63 + ], + "raw": "" + }, + { + "type": "Str", + "value": "\n", + "loc": { + "start": { + "line": 1, + "column": 63 + }, + "end": { + "line": 2, + "column": 0 + } + }, + "range": [ + 63, + 64 + ], + "raw": "\n" + } + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 0 + } + }, + "range": [ + 0, + 64 + ], + "raw": "\n" +} \ No newline at end of file diff --git a/test/ast-test-case/doctype-almost-standards/result.html b/test/ast-test-case/doctype-almost-standards/result.html new file mode 100644 index 0000000..c264ec0 --- /dev/null +++ b/test/ast-test-case/doctype-almost-standards/result.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/test/ast-test-case/doctype-legacy-double/config.json b/test/ast-test-case/doctype-legacy-double/config.json new file mode 100644 index 0000000..0967ef4 --- /dev/null +++ b/test/ast-test-case/doctype-legacy-double/config.json @@ -0,0 +1 @@ +{} diff --git a/test/ast-test-case/doctype-legacy-double/index.html b/test/ast-test-case/doctype-legacy-double/index.html new file mode 100644 index 0000000..77a5535 --- /dev/null +++ b/test/ast-test-case/doctype-legacy-double/index.html @@ -0,0 +1 @@ + diff --git a/test/ast-test-case/doctype-legacy-double/index.json b/test/ast-test-case/doctype-legacy-double/index.json new file mode 100644 index 0000000..834a032 --- /dev/null +++ b/test/ast-test-case/doctype-legacy-double/index.json @@ -0,0 +1,59 @@ +{ + "type": "Document", + "children": [ + { + "type": "UNKNOWN", + "name": "!doctype", + "value": "!DOCTYPE html SYSTEM \"about:legacy-compat\"", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 44 + } + }, + "range": [ + 0, + 44 + ], + "raw": "" + }, + { + "type": "Str", + "value": "\n", + "loc": { + "start": { + "line": 1, + "column": 44 + }, + "end": { + "line": 2, + "column": 0 + } + }, + "range": [ + 44, + 45 + ], + "raw": "\n" + } + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 0 + } + }, + "range": [ + 0, + 45 + ], + "raw": "\n" +} \ No newline at end of file diff --git a/test/ast-test-case/doctype-legacy-double/result.html b/test/ast-test-case/doctype-legacy-double/result.html new file mode 100644 index 0000000..63f2cc1 --- /dev/null +++ b/test/ast-test-case/doctype-legacy-double/result.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/test/ast-test-case/doctype-legacy-single/config.json b/test/ast-test-case/doctype-legacy-single/config.json new file mode 100644 index 0000000..0967ef4 --- /dev/null +++ b/test/ast-test-case/doctype-legacy-single/config.json @@ -0,0 +1 @@ +{} diff --git a/test/ast-test-case/doctype-legacy-single/index.html b/test/ast-test-case/doctype-legacy-single/index.html new file mode 100644 index 0000000..8e36240 --- /dev/null +++ b/test/ast-test-case/doctype-legacy-single/index.html @@ -0,0 +1 @@ + diff --git a/test/ast-test-case/doctype-legacy-single/index.json b/test/ast-test-case/doctype-legacy-single/index.json new file mode 100644 index 0000000..633037e --- /dev/null +++ b/test/ast-test-case/doctype-legacy-single/index.json @@ -0,0 +1,59 @@ +{ + "type": "Document", + "children": [ + { + "type": "UNKNOWN", + "name": "!doctype", + "value": "!DOCTYPE html SYSTEM 'about:legacy-compat'", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 44 + } + }, + "range": [ + 0, + 44 + ], + "raw": "" + }, + { + "type": "Str", + "value": "\n", + "loc": { + "start": { + "line": 1, + "column": 44 + }, + "end": { + "line": 2, + "column": 0 + } + }, + "range": [ + 44, + 45 + ], + "raw": "\n" + } + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 0 + } + }, + "range": [ + 0, + 45 + ], + "raw": "\n" +} \ No newline at end of file diff --git a/test/ast-test-case/doctype-legacy-single/result.html b/test/ast-test-case/doctype-legacy-single/result.html new file mode 100644 index 0000000..63f2cc1 --- /dev/null +++ b/test/ast-test-case/doctype-legacy-single/result.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/test/ast-test-case/doctype-nameless/config.json b/test/ast-test-case/doctype-nameless/config.json new file mode 100644 index 0000000..0967ef4 --- /dev/null +++ b/test/ast-test-case/doctype-nameless/config.json @@ -0,0 +1 @@ +{} diff --git a/test/ast-test-case/doctype-nameless/index.html b/test/ast-test-case/doctype-nameless/index.html new file mode 100644 index 0000000..793f0b4 --- /dev/null +++ b/test/ast-test-case/doctype-nameless/index.html @@ -0,0 +1 @@ + diff --git a/test/ast-test-case/doctype-nameless/index.json b/test/ast-test-case/doctype-nameless/index.json new file mode 100644 index 0000000..280f03c --- /dev/null +++ b/test/ast-test-case/doctype-nameless/index.json @@ -0,0 +1,59 @@ +{ + "type": "Document", + "children": [ + { + "type": "UNKNOWN", + "name": "!doctype", + "value": "!DOCTYPE", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 10 + } + }, + "range": [ + 0, + 10 + ], + "raw": "" + }, + { + "type": "Str", + "value": "\n", + "loc": { + "start": { + "line": 1, + "column": 10 + }, + "end": { + "line": 2, + "column": 0 + } + }, + "range": [ + 10, + 11 + ], + "raw": "\n" + } + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 0 + } + }, + "range": [ + 0, + 11 + ], + "raw": "\n" +} \ No newline at end of file diff --git a/test/ast-test-case/doctype-nameless/result.html b/test/ast-test-case/doctype-nameless/result.html new file mode 100644 index 0000000..00b6693 --- /dev/null +++ b/test/ast-test-case/doctype-nameless/result.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/test/ast-test-case/doctype-quirksmode-ibm/config.json b/test/ast-test-case/doctype-quirksmode-ibm/config.json new file mode 100644 index 0000000..0967ef4 --- /dev/null +++ b/test/ast-test-case/doctype-quirksmode-ibm/config.json @@ -0,0 +1 @@ +{} diff --git a/test/ast-test-case/doctype-quirksmode-ibm/index.html b/test/ast-test-case/doctype-quirksmode-ibm/index.html new file mode 100644 index 0000000..06529df --- /dev/null +++ b/test/ast-test-case/doctype-quirksmode-ibm/index.html @@ -0,0 +1 @@ + diff --git a/test/ast-test-case/doctype-quirksmode-ibm/index.json b/test/ast-test-case/doctype-quirksmode-ibm/index.json new file mode 100644 index 0000000..89cceba --- /dev/null +++ b/test/ast-test-case/doctype-quirksmode-ibm/index.json @@ -0,0 +1,59 @@ +{ + "type": "Document", + "children": [ + { + "type": "UNKNOWN", + "name": "!doctype", + "value": "!DOCTYPE html SYSTEM \"http://www.ibm.com/data/dtd/v11/ibmxhtml1-transitional.dtd\"", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 83 + } + }, + "range": [ + 0, + 83 + ], + "raw": "" + }, + { + "type": "Str", + "value": "\n", + "loc": { + "start": { + "line": 1, + "column": 83 + }, + "end": { + "line": 2, + "column": 0 + } + }, + "range": [ + 83, + 84 + ], + "raw": "\n" + } + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 0 + } + }, + "range": [ + 0, + 84 + ], + "raw": "\n" +} \ No newline at end of file diff --git a/test/ast-test-case/doctype-quirksmode-ibm/result.html b/test/ast-test-case/doctype-quirksmode-ibm/result.html new file mode 100644 index 0000000..db65fa9 --- /dev/null +++ b/test/ast-test-case/doctype-quirksmode-ibm/result.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/test/ast-test-case/doctype-quirksmode-xml/config.json b/test/ast-test-case/doctype-quirksmode-xml/config.json new file mode 100644 index 0000000..0967ef4 --- /dev/null +++ b/test/ast-test-case/doctype-quirksmode-xml/config.json @@ -0,0 +1 @@ +{} diff --git a/test/ast-test-case/doctype-quirksmode-xml/index.html b/test/ast-test-case/doctype-quirksmode-xml/index.html new file mode 100644 index 0000000..2b5d411 --- /dev/null +++ b/test/ast-test-case/doctype-quirksmode-xml/index.html @@ -0,0 +1 @@ + diff --git a/test/ast-test-case/doctype-quirksmode-xml/index.json b/test/ast-test-case/doctype-quirksmode-xml/index.json new file mode 100644 index 0000000..9385f60 --- /dev/null +++ b/test/ast-test-case/doctype-quirksmode-xml/index.json @@ -0,0 +1,59 @@ +{ + "type": "Document", + "children": [ + { + "type": "UNKNOWN", + "name": "?xml", + "value": "?xml version=\"1.0\"?", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 21 + } + }, + "range": [ + 0, + 21 + ], + "raw": "" + }, + { + "type": "Str", + "value": "\n", + "loc": { + "start": { + "line": 1, + "column": 21 + }, + "end": { + "line": 2, + "column": 0 + } + }, + "range": [ + 21, + 22 + ], + "raw": "\n" + } + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 0 + } + }, + "range": [ + 0, + 22 + ], + "raw": "\n" +} \ No newline at end of file diff --git a/test/ast-test-case/doctype-quirksmode-xml/result.html b/test/ast-test-case/doctype-quirksmode-xml/result.html new file mode 100644 index 0000000..097aa47 --- /dev/null +++ b/test/ast-test-case/doctype-quirksmode-xml/result.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/test/ast-test-case/doctype-quotes-double/config.json b/test/ast-test-case/doctype-quotes-double/config.json new file mode 100644 index 0000000..0967ef4 --- /dev/null +++ b/test/ast-test-case/doctype-quotes-double/config.json @@ -0,0 +1 @@ +{} diff --git a/test/ast-test-case/doctype-quotes-double/index.html b/test/ast-test-case/doctype-quotes-double/index.html new file mode 100644 index 0000000..95b6c23 --- /dev/null +++ b/test/ast-test-case/doctype-quotes-double/index.html @@ -0,0 +1 @@ + diff --git a/test/ast-test-case/doctype-quotes-double/index.json b/test/ast-test-case/doctype-quotes-double/index.json new file mode 100644 index 0000000..955dfd7 --- /dev/null +++ b/test/ast-test-case/doctype-quotes-double/index.json @@ -0,0 +1,59 @@ +{ + "type": "Document", + "children": [ + { + "type": "UNKNOWN", + "name": "!doctype", + "value": "!DOCTYPE HTML PUBLIC '-//Alpha \"bravo\" charlie//DTD HTML Extended 1.0//EN'", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 76 + } + }, + "range": [ + 0, + 76 + ], + "raw": "" + }, + { + "type": "Str", + "value": "\n", + "loc": { + "start": { + "line": 1, + "column": 76 + }, + "end": { + "line": 2, + "column": 0 + } + }, + "range": [ + 76, + 77 + ], + "raw": "\n" + } + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 0 + } + }, + "range": [ + 0, + 77 + ], + "raw": "\n" +} \ No newline at end of file diff --git a/test/ast-test-case/doctype-quotes-double/result.html b/test/ast-test-case/doctype-quotes-double/result.html new file mode 100644 index 0000000..b41eaed --- /dev/null +++ b/test/ast-test-case/doctype-quotes-double/result.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/test/ast-test-case/doctype-quotes-single/config.json b/test/ast-test-case/doctype-quotes-single/config.json new file mode 100644 index 0000000..0967ef4 --- /dev/null +++ b/test/ast-test-case/doctype-quotes-single/config.json @@ -0,0 +1 @@ +{} diff --git a/test/ast-test-case/doctype-quotes-single/index.html b/test/ast-test-case/doctype-quotes-single/index.html new file mode 100644 index 0000000..5d43185 --- /dev/null +++ b/test/ast-test-case/doctype-quotes-single/index.html @@ -0,0 +1 @@ + diff --git a/test/ast-test-case/doctype-quotes-single/index.json b/test/ast-test-case/doctype-quotes-single/index.json new file mode 100644 index 0000000..1310039 --- /dev/null +++ b/test/ast-test-case/doctype-quotes-single/index.json @@ -0,0 +1,59 @@ +{ + "type": "Document", + "children": [ + { + "type": "UNKNOWN", + "name": "!doctype", + "value": "!DOCTYPE HTML PUBLIC \"-//Alpha 'bravo' charlie//DTD HTML Extended 1.0//EN\"", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 76 + } + }, + "range": [ + 0, + 76 + ], + "raw": "" + }, + { + "type": "Str", + "value": "\n", + "loc": { + "start": { + "line": 1, + "column": 76 + }, + "end": { + "line": 2, + "column": 0 + } + }, + "range": [ + 76, + 77 + ], + "raw": "\n" + } + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 0 + } + }, + "range": [ + 0, + 77 + ], + "raw": "\n" +} \ No newline at end of file diff --git a/test/ast-test-case/doctype-quotes-single/result.html b/test/ast-test-case/doctype-quotes-single/result.html new file mode 100644 index 0000000..c4b76d4 --- /dev/null +++ b/test/ast-test-case/doctype-quotes-single/result.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/test/ast-test-case/doctype/config.json b/test/ast-test-case/doctype/config.json new file mode 100644 index 0000000..0967ef4 --- /dev/null +++ b/test/ast-test-case/doctype/config.json @@ -0,0 +1 @@ +{} diff --git a/test/ast-test-case/doctype/index.html b/test/ast-test-case/doctype/index.html new file mode 100644 index 0000000..0e76edd --- /dev/null +++ b/test/ast-test-case/doctype/index.html @@ -0,0 +1 @@ + diff --git a/test/ast-test-case/doctype/index.json b/test/ast-test-case/doctype/index.json new file mode 100644 index 0000000..826591f --- /dev/null +++ b/test/ast-test-case/doctype/index.json @@ -0,0 +1,59 @@ +{ + "type": "Document", + "children": [ + { + "type": "UNKNOWN", + "name": "!doctype", + "value": "!DOCTYPE html", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 15 + } + }, + "range": [ + 0, + 15 + ], + "raw": "" + }, + { + "type": "Str", + "value": "\n", + "loc": { + "start": { + "line": 1, + "column": 15 + }, + "end": { + "line": 2, + "column": 0 + } + }, + "range": [ + 15, + 16 + ], + "raw": "\n" + } + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 0 + } + }, + "range": [ + 0, + 16 + ], + "raw": "\n" +} \ No newline at end of file diff --git a/test/ast-test-case/doctype/result.html b/test/ast-test-case/doctype/result.html new file mode 100644 index 0000000..6fedfd4 --- /dev/null +++ b/test/ast-test-case/doctype/result.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/test/ast-test-case/element-attributes-names/config.json b/test/ast-test-case/element-attributes-names/config.json new file mode 100644 index 0000000..a875830 --- /dev/null +++ b/test/ast-test-case/element-attributes-names/config.json @@ -0,0 +1,3 @@ +{ + "fragment": true +} diff --git a/test/ast-test-case/element-attributes-names/index.html b/test/ast-test-case/element-attributes-names/index.html new file mode 100644 index 0000000..2971b43 --- /dev/null +++ b/test/ast-test-case/element-attributes-names/index.html @@ -0,0 +1,4 @@ + + + + diff --git a/test/ast-test-case/element-attributes-names/index.json b/test/ast-test-case/element-attributes-names/index.json new file mode 100644 index 0000000..292cbcb --- /dev/null +++ b/test/ast-test-case/element-attributes-names/index.json @@ -0,0 +1,192 @@ +{ + "type": "Document", + "children": [ + { + "type": "Link", + "tagName": "a", + "properties": { + "foo": "", + "type": "UNKNOWN" + }, + "children": [], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 11 + } + }, + "range": [ + 0, + 11 + ], + "raw": "" + }, + { + "type": "Str", + "value": "\n", + "loc": { + "start": { + "line": 1, + "column": 11 + }, + "end": { + "line": 2, + "column": 0 + } + }, + "range": [ + 11, + 12 + ], + "raw": "\n" + }, + { + "type": "Link", + "tagName": "a", + "properties": { + "foo": "", + "type": "UNKNOWN" + }, + "children": [], + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 11 + } + }, + "range": [ + 12, + 23 + ], + "raw": "" + }, + { + "type": "Str", + "value": "\n", + "loc": { + "start": { + "line": 2, + "column": 11 + }, + "end": { + "line": 3, + "column": 0 + } + }, + "range": [ + 23, + 24 + ], + "raw": "\n" + }, + { + "type": "Link", + "tagName": "a", + "properties": { + "foo": "", + "type": "UNKNOWN" + }, + "children": [], + "loc": { + "start": { + "line": 3, + "column": 0 + }, + "end": { + "line": 3, + "column": 11 + } + }, + "range": [ + 24, + 35 + ], + "raw": "" + }, + { + "type": "Str", + "value": "\n", + "loc": { + "start": { + "line": 3, + "column": 11 + }, + "end": { + "line": 4, + "column": 0 + } + }, + "range": [ + 35, + 36 + ], + "raw": "\n" + }, + { + "type": "Link", + "tagName": "a", + "properties": { + "foo": "", + "type": "UNKNOWN" + }, + "children": [], + "loc": { + "start": { + "line": 4, + "column": 0 + }, + "end": { + "line": 4, + "column": 19 + } + }, + "range": [ + 36, + 55 + ], + "raw": "" + }, + { + "type": "Str", + "value": "\n", + "loc": { + "start": { + "line": 4, + "column": 19 + }, + "end": { + "line": 5, + "column": 0 + } + }, + "range": [ + 55, + 56 + ], + "raw": "\n" + } + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 5, + "column": 0 + } + }, + "range": [ + 0, + 56 + ], + "raw": "\n\n\n\n" +} \ No newline at end of file diff --git a/test/ast-test-case/element-attributes-names/result.html b/test/ast-test-case/element-attributes-names/result.html new file mode 100644 index 0000000..79b903c --- /dev/null +++ b/test/ast-test-case/element-attributes-names/result.html @@ -0,0 +1,4 @@ + + + + diff --git a/test/ast-test-case/element-attributes/config.json b/test/ast-test-case/element-attributes/config.json new file mode 100644 index 0000000..a875830 --- /dev/null +++ b/test/ast-test-case/element-attributes/config.json @@ -0,0 +1,3 @@ +{ + "fragment": true +} diff --git a/test/ast-test-case/element-attributes/index.html b/test/ast-test-case/element-attributes/index.html new file mode 100644 index 0000000..7c695da --- /dev/null +++ b/test/ast-test-case/element-attributes/index.html @@ -0,0 +1,95 @@ + + + + + + +
+ + + + + + + +ng-whatevs. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + diff --git a/test/ast-test-case/element-attributes/index.json b/test/ast-test-case/element-attributes/index.json new file mode 100644 index 0000000..421f461 --- /dev/null +++ b/test/ast-test-case/element-attributes/index.json @@ -0,0 +1,2172 @@ +{ + "type": "Document", + "children": [ + { + "type": "Comment", + "value": "core:", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 12 + } + }, + "range": [ + 0, + 12 + ], + "raw": "" + }, + { + "type": "Str", + "value": "\n\n", + "loc": { + "start": { + "line": 1, + "column": 12 + }, + "end": { + "line": 3, + "column": 0 + } + }, + "range": [ + 12, + 14 + ], + "raw": "\n\n" + }, + { + "type": "Link", + "tagName": "a", + "properties": { + "href": "http://alpha.com", + "className": [ + "bravo" + ], + "download": true, + "type": "UNKNOWN" + }, + "children": [], + "loc": { + "start": { + "line": 3, + "column": 0 + }, + "end": { + "line": 3, + "column": 54 + } + }, + "range": [ + 14, + 68 + ], + "raw": "" + }, + { + "type": "Str", + "value": "\n\n", + "loc": { + "start": { + "line": 3, + "column": 54 + }, + "end": { + "line": 5, + "column": 0 + } + }, + "range": [ + 68, + 70 + ], + "raw": "\n\n" + }, + { + "type": "Comment", + "value": "double:", + "loc": { + "start": { + "line": 5, + "column": 0 + }, + "end": { + "line": 5, + "column": 14 + } + }, + "range": [ + 70, + 84 + ], + "raw": "" + }, + { + "type": "Str", + "value": "\n\n", + "loc": { + "start": { + "line": 5, + "column": 14 + }, + "end": { + "line": 7, + "column": 0 + } + }, + "range": [ + 84, + 86 + ], + "raw": "\n\n" + }, + { + "type": "Html", + "tagName": "div", + "properties": { + "className": [], + "type": "UNKNOWN" + }, + "children": [], + "loc": { + "start": { + "line": 7, + "column": 0 + }, + "end": { + "line": 7, + "column": 23 + } + }, + "range": [ + 86, + 109 + ], + "raw": "
" + }, + { + "type": "Str", + "value": "\n\n", + "loc": { + "start": { + "line": 7, + "column": 23 + }, + "end": { + "line": 9, + "column": 0 + } + }, + "range": [ + 109, + 111 + ], + "raw": "\n\n" + }, + { + "type": "Comment", + "value": "unknown:", + "loc": { + "start": { + "line": 9, + "column": 0 + }, + "end": { + "line": 9, + "column": 15 + } + }, + "range": [ + 111, + 126 + ], + "raw": "" + }, + { + "type": "Str", + "value": "\n\n", + "loc": { + "start": { + "line": 9, + "column": 15 + }, + "end": { + "line": 11, + "column": 0 + } + }, + "range": [ + 126, + 128 + ], + "raw": "\n\n" + }, + { + "type": "Link", + "tagName": "a", + "properties": { + "ngInit": "", + "type": "UNKNOWN" + }, + "children": [], + "loc": { + "start": { + "line": 11, + "column": 0 + }, + "end": { + "line": 11, + "column": 15 + } + }, + "range": [ + 128, + 143 + ], + "raw": "" + }, + { + "type": "Str", + "value": "\n\n", + "loc": { + "start": { + "line": 11, + "column": 15 + }, + "end": { + "line": 13, + "column": 0 + } + }, + "range": [ + 143, + 145 + ], + "raw": "\n\n" + }, + { + "type": "Link", + "tagName": "a", + "properties": { + "ngRepeat": "", + "type": "UNKNOWN" + }, + "children": [], + "loc": { + "start": { + "line": 13, + "column": 0 + }, + "end": { + "line": 13, + "column": 20 + } + }, + "range": [ + 145, + 165 + ], + "raw": "" + }, + { + "type": "Str", + "value": "\n\n", + "loc": { + "start": { + "line": 13, + "column": 20 + }, + "end": { + "line": 15, + "column": 0 + } + }, + "range": [ + 165, + 167 + ], + "raw": "\n\n" + }, + { + "type": "Link", + "tagName": "a", + "properties": { + "ngClick": "ctrl.onintentclick($scope)", + "type": "UNKNOWN" + }, + "children": [ + { + "type": "Str", + "value": "ng-whatevs", + "loc": { + "start": { + "line": 15, + "column": 41 + }, + "end": { + "line": 15, + "column": 51 + } + }, + "range": [ + 208, + 218 + ], + "raw": "ng-whatevs" + } + ], + "loc": { + "start": { + "line": 15, + "column": 0 + }, + "end": { + "line": 15, + "column": 55 + } + }, + "range": [ + 167, + 222 + ], + "raw": "ng-whatevs" + }, + { + "type": "Str", + "value": ".\n\n", + "loc": { + "start": { + "line": 15, + "column": 55 + }, + "end": { + "line": 17, + "column": 0 + } + }, + "range": [ + 222, + 225 + ], + "raw": ".\n\n" + }, + { + "type": "Comment", + "value": "empty:", + "loc": { + "start": { + "line": 17, + "column": 0 + }, + "end": { + "line": 17, + "column": 13 + } + }, + "range": [ + 225, + 238 + ], + "raw": "" + }, + { + "type": "Str", + "value": "\n\n", + "loc": { + "start": { + "line": 17, + "column": 13 + }, + "end": { + "line": 19, + "column": 0 + } + }, + "range": [ + 238, + 240 + ], + "raw": "\n\n" + }, + { + "type": "Html", + "tagName": "abbr", + "properties": { + "title": "", + "type": "UNKNOWN" + }, + "children": [], + "loc": { + "start": { + "line": 19, + "column": 0 + }, + "end": { + "line": 19, + "column": 19 + } + }, + "range": [ + 240, + 259 + ], + "raw": "" + }, + { + "type": "Str", + "value": "\n\n", + "loc": { + "start": { + "line": 19, + "column": 19 + }, + "end": { + "line": 21, + "column": 0 + } + }, + "range": [ + 259, + 261 + ], + "raw": "\n\n" + }, + { + "type": "Comment", + "value": "space separated:", + "loc": { + "start": { + "line": 21, + "column": 0 + }, + "end": { + "line": 21, + "column": 23 + } + }, + "range": [ + 261, + 284 + ], + "raw": "" + }, + { + "type": "Str", + "value": "\n\n", + "loc": { + "start": { + "line": 21, + "column": 23 + }, + "end": { + "line": 23, + "column": 0 + } + }, + "range": [ + 284, + 286 + ], + "raw": "\n\n" + }, + { + "type": "CodeBlock", + "tagName": "code", + "properties": { + "className": [ + "language-foo", + "bar" + ], + "type": "UNKNOWN" + }, + "children": [], + "loc": { + "start": { + "line": 23, + "column": 0 + }, + "end": { + "line": 23, + "column": 38 + } + }, + "range": [ + 286, + 324 + ], + "raw": "" + }, + { + "type": "Str", + "value": "\n\n", + "loc": { + "start": { + "line": 23, + "column": 38 + }, + "end": { + "line": 25, + "column": 0 + } + }, + "range": [ + 324, + 326 + ], + "raw": "\n\n" + }, + { + "type": "CodeBlock", + "tagName": "code", + "properties": { + "className": [], + "type": "UNKNOWN" + }, + "children": [], + "loc": { + "start": { + "line": 25, + "column": 0 + }, + "end": { + "line": 25, + "column": 22 + } + }, + "range": [ + 326, + 348 + ], + "raw": "" + }, + { + "type": "Str", + "value": "\n\n", + "loc": { + "start": { + "line": 25, + "column": 22 + }, + "end": { + "line": 27, + "column": 0 + } + }, + "range": [ + 348, + 350 + ], + "raw": "\n\n" + }, + { + "type": "CodeBlock", + "tagName": "code", + "properties": { + "className": [], + "type": "UNKNOWN" + }, + "children": [], + "loc": { + "start": { + "line": 27, + "column": 0 + }, + "end": { + "line": 27, + "column": 19 + } + }, + "range": [ + 350, + 369 + ], + "raw": "" + }, + { + "type": "Str", + "value": "\n\n", + "loc": { + "start": { + "line": 27, + "column": 19 + }, + "end": { + "line": 29, + "column": 0 + } + }, + "range": [ + 369, + 371 + ], + "raw": "\n\n" + }, + { + "type": "CodeBlock", + "tagName": "code", + "properties": { + "className": [], + "type": "UNKNOWN" + }, + "children": [], + "loc": { + "start": { + "line": 29, + "column": 0 + }, + "end": { + "line": 29, + "column": 23 + } + }, + "range": [ + 371, + 394 + ], + "raw": "" + }, + { + "type": "Str", + "value": "\n\n", + "loc": { + "start": { + "line": 29, + "column": 23 + }, + "end": { + "line": 31, + "column": 0 + } + }, + "range": [ + 394, + 396 + ], + "raw": "\n\n" + }, + { + "type": "Comment", + "value": "comma separated:", + "loc": { + "start": { + "line": 31, + "column": 0 + }, + "end": { + "line": 31, + "column": 23 + } + }, + "range": [ + 396, + 419 + ], + "raw": "" + }, + { + "type": "Str", + "value": "\n\n", + "loc": { + "start": { + "line": 31, + "column": 23 + }, + "end": { + "line": 33, + "column": 0 + } + }, + "range": [ + 419, + 421 + ], + "raw": "\n\n" + }, + { + "type": "Image", + "tagName": "img", + "properties": { + "srcSet": [ + "medium.jpg 1000w", + "large.jpg 2000w" + ], + "type": "UNKNOWN" + }, + "children": [], + "loc": { + "start": { + "line": 33, + "column": 0 + }, + "end": { + "line": 33, + "column": 48 + } + }, + "range": [ + 421, + 469 + ], + "raw": "" + }, + { + "type": "Str", + "value": "\n\n", + "loc": { + "start": { + "line": 33, + "column": 48 + }, + "end": { + "line": 35, + "column": 0 + } + }, + "range": [ + 469, + 471 + ], + "raw": "\n\n" + }, + { + "type": "Image", + "tagName": "img", + "properties": { + "srcSet": [ + "medium.jpg 1000w" + ], + "type": "UNKNOWN" + }, + "children": [], + "loc": { + "start": { + "line": 35, + "column": 0 + }, + "end": { + "line": 35, + "column": 31 + } + }, + "range": [ + 471, + 502 + ], + "raw": "" + }, + { + "type": "Str", + "value": "\n\n", + "loc": { + "start": { + "line": 35, + "column": 31 + }, + "end": { + "line": 37, + "column": 0 + } + }, + "range": [ + 502, + 504 + ], + "raw": "\n\n" + }, + { + "type": "Image", + "tagName": "img", + "properties": { + "srcSet": [], + "type": "UNKNOWN" + }, + "children": [], + "loc": { + "start": { + "line": 37, + "column": 0 + }, + "end": { + "line": 37, + "column": 15 + } + }, + "range": [ + 504, + 519 + ], + "raw": "" + }, + { + "type": "Str", + "value": "\n\n", + "loc": { + "start": { + "line": 37, + "column": 15 + }, + "end": { + "line": 39, + "column": 0 + } + }, + "range": [ + 519, + 521 + ], + "raw": "\n\n" + }, + { + "type": "Image", + "tagName": "img", + "properties": { + "srcSet": [], + "type": "UNKNOWN" + }, + "children": [], + "loc": { + "start": { + "line": 39, + "column": 0 + }, + "end": { + "line": 39, + "column": 16 + } + }, + "range": [ + 521, + 537 + ], + "raw": "" + }, + { + "type": "Str", + "value": "\n\n", + "loc": { + "start": { + "line": 39, + "column": 16 + }, + "end": { + "line": 41, + "column": 0 + } + }, + "range": [ + 537, + 539 + ], + "raw": "\n\n" + }, + { + "type": "Image", + "tagName": "img", + "properties": { + "srcSet": [ + "" + ], + "type": "UNKNOWN" + }, + "children": [], + "loc": { + "start": { + "line": 41, + "column": 0 + }, + "end": { + "line": 41, + "column": 16 + } + }, + "range": [ + 539, + 555 + ], + "raw": "" + }, + { + "type": "Str", + "value": "\n\n", + "loc": { + "start": { + "line": 41, + "column": 16 + }, + "end": { + "line": 43, + "column": 0 + } + }, + "range": [ + 555, + 557 + ], + "raw": "\n\n" + }, + { + "type": "Image", + "tagName": "img", + "properties": { + "srcSet": [ + "" + ], + "type": "UNKNOWN" + }, + "children": [], + "loc": { + "start": { + "line": 43, + "column": 0 + }, + "end": { + "line": 43, + "column": 18 + } + }, + "range": [ + 557, + 575 + ], + "raw": "" + }, + { + "type": "Str", + "value": "\n\n", + "loc": { + "start": { + "line": 43, + "column": 18 + }, + "end": { + "line": 45, + "column": 0 + } + }, + "range": [ + 575, + 577 + ], + "raw": "\n\n" + }, + { + "type": "Image", + "tagName": "img", + "properties": { + "srcSet": [ + "", + "foo" + ], + "type": "UNKNOWN" + }, + "children": [], + "loc": { + "start": { + "line": 45, + "column": 0 + }, + "end": { + "line": 45, + "column": 19 + } + }, + "range": [ + 577, + 596 + ], + "raw": "" + }, + { + "type": "Str", + "value": "\n\n", + "loc": { + "start": { + "line": 45, + "column": 19 + }, + "end": { + "line": 47, + "column": 0 + } + }, + "range": [ + 596, + 598 + ], + "raw": "\n\n" + }, + { + "type": "Image", + "tagName": "img", + "properties": { + "srcSet": [ + "bar" + ], + "type": "UNKNOWN" + }, + "children": [], + "loc": { + "start": { + "line": 47, + "column": 0 + }, + "end": { + "line": 47, + "column": 19 + } + }, + "range": [ + 598, + 617 + ], + "raw": "" + }, + { + "type": "Str", + "value": "\n\n", + "loc": { + "start": { + "line": 47, + "column": 19 + }, + "end": { + "line": 49, + "column": 0 + } + }, + "range": [ + 617, + 619 + ], + "raw": "\n\n" + }, + { + "type": "Image", + "tagName": "img", + "properties": { + "srcSet": [ + "", + "baz" + ], + "type": "UNKNOWN" + }, + "children": [], + "loc": { + "start": { + "line": 49, + "column": 0 + }, + "end": { + "line": 49, + "column": 20 + } + }, + "range": [ + 619, + 639 + ], + "raw": "" + }, + { + "type": "Str", + "value": "\n\n", + "loc": { + "start": { + "line": 49, + "column": 20 + }, + "end": { + "line": 51, + "column": 0 + } + }, + "range": [ + 639, + 641 + ], + "raw": "\n\n" + }, + { + "type": "Comment", + "value": "style:", + "loc": { + "start": { + "line": 51, + "column": 0 + }, + "end": { + "line": 51, + "column": 13 + } + }, + "range": [ + 641, + 654 + ], + "raw": "" + }, + { + "type": "Str", + "value": "\n\n", + "loc": { + "start": { + "line": 51, + "column": 13 + }, + "end": { + "line": 53, + "column": 0 + } + }, + "range": [ + 654, + 656 + ], + "raw": "\n\n" + }, + { + "type": "Html", + "tagName": "div", + "properties": {}, + "children": [], + "loc": { + "start": { + "line": 53, + "column": 0 + }, + "end": { + "line": 53, + "column": 11 + } + }, + "range": [ + 656, + 667 + ], + "raw": "
" + }, + { + "type": "Str", + "value": "\n\n", + "loc": { + "start": { + "line": 53, + "column": 11 + }, + "end": { + "line": 55, + "column": 0 + } + }, + "range": [ + 667, + 669 + ], + "raw": "\n\n" + }, + { + "type": "Html", + "tagName": "div", + "properties": { + "style": {}, + "type": "UNKNOWN" + }, + "children": [], + "loc": { + "start": { + "line": 55, + "column": 0 + }, + "end": { + "line": 55, + "column": 20 + } + }, + "range": [ + 669, + 689 + ], + "raw": "
" + }, + { + "type": "Str", + "value": "\n\n", + "loc": { + "start": { + "line": 55, + "column": 20 + }, + "end": { + "line": 57, + "column": 0 + } + }, + "range": [ + 689, + 691 + ], + "raw": "\n\n" + }, + { + "type": "Html", + "tagName": "div", + "properties": { + "style": {}, + "type": "UNKNOWN" + }, + "children": [], + "loc": { + "start": { + "line": 57, + "column": 0 + }, + "end": { + "line": 57, + "column": 25 + } + }, + "range": [ + 691, + 716 + ], + "raw": "
" + }, + { + "type": "Str", + "value": "\n\n", + "loc": { + "start": { + "line": 57, + "column": 25 + }, + "end": { + "line": 59, + "column": 0 + } + }, + "range": [ + 716, + 718 + ], + "raw": "\n\n" + }, + { + "type": "Html", + "tagName": "div", + "properties": { + "style": {}, + "type": "UNKNOWN" + }, + "children": [], + "loc": { + "start": { + "line": 59, + "column": 0 + }, + "end": { + "line": 59, + "column": 26 + } + }, + "range": [ + 718, + 744 + ], + "raw": "
" + }, + { + "type": "Str", + "value": "\n\n", + "loc": { + "start": { + "line": 59, + "column": 26 + }, + "end": { + "line": 61, + "column": 0 + } + }, + "range": [ + 744, + 746 + ], + "raw": "\n\n" + }, + { + "type": "Html", + "tagName": "div", + "properties": { + "style": { + "color": "red", + "type": "UNKNOWN" + }, + "type": "UNKNOWN" + }, + "children": [], + "loc": { + "start": { + "line": 61, + "column": 0 + }, + "end": { + "line": 61, + "column": 29 + } + }, + "range": [ + 746, + 775 + ], + "raw": "
" + }, + { + "type": "Str", + "value": "\n\n", + "loc": { + "start": { + "line": 61, + "column": 29 + }, + "end": { + "line": 63, + "column": 0 + } + }, + "range": [ + 775, + 777 + ], + "raw": "\n\n" + }, + { + "type": "Html", + "tagName": "div", + "properties": { + "style": {}, + "type": "UNKNOWN" + }, + "children": [], + "loc": { + "start": { + "line": 63, + "column": 0 + }, + "end": { + "line": 63, + "column": 27 + } + }, + "range": [ + 777, + 804 + ], + "raw": "
" + }, + { + "type": "Str", + "value": "\n\n", + "loc": { + "start": { + "line": 63, + "column": 27 + }, + "end": { + "line": 65, + "column": 0 + } + }, + "range": [ + 804, + 806 + ], + "raw": "\n\n" + }, + { + "type": "Html", + "tagName": "div", + "properties": { + "style": { + "color": "red", + "type": "UNKNOWN" + }, + "type": "UNKNOWN" + }, + "children": [], + "loc": { + "start": { + "line": 65, + "column": 0 + }, + "end": { + "line": 65, + "column": 30 + } + }, + "range": [ + 806, + 836 + ], + "raw": "
" + }, + { + "type": "Str", + "value": "\n\n", + "loc": { + "start": { + "line": 65, + "column": 30 + }, + "end": { + "line": 67, + "column": 0 + } + }, + "range": [ + 836, + 838 + ], + "raw": "\n\n" + }, + { + "type": "Html", + "tagName": "div", + "properties": { + "style": { + "color": "red", + "type": "UNKNOWN" + }, + "type": "UNKNOWN" + }, + "children": [], + "loc": { + "start": { + "line": 67, + "column": 0 + }, + "end": { + "line": 67, + "column": 46 + } + }, + "range": [ + 838, + 884 + ], + "raw": "
" + }, + { + "type": "Str", + "value": "\n\n", + "loc": { + "start": { + "line": 67, + "column": 46 + }, + "end": { + "line": 69, + "column": 0 + } + }, + "range": [ + 884, + 886 + ], + "raw": "\n\n" + }, + { + "type": "Html", + "tagName": "div", + "properties": { + "style": { + "color": "red", + "background-color": "blue", + "type": "UNKNOWN" + }, + "type": "UNKNOWN" + }, + "children": [], + "loc": { + "start": { + "line": 69, + "column": 0 + }, + "end": { + "line": 69, + "column": 52 + } + }, + "range": [ + 886, + 938 + ], + "raw": "
" + }, + { + "type": "Str", + "value": "\n\n", + "loc": { + "start": { + "line": 69, + "column": 52 + }, + "end": { + "line": 71, + "column": 0 + } + }, + "range": [ + 938, + 940 + ], + "raw": "\n\n" + }, + { + "type": "Html", + "tagName": "div", + "properties": { + "style": { + "color": "red", + "background-color": "blue", + "type": "UNKNOWN" + }, + "type": "UNKNOWN" + }, + "children": [], + "loc": { + "start": { + "line": 71, + "column": 0 + }, + "end": { + "line": 71, + "column": 53 + } + }, + "range": [ + 940, + 993 + ], + "raw": "
" + }, + { + "type": "Str", + "value": "\n\n", + "loc": { + "start": { + "line": 71, + "column": 53 + }, + "end": { + "line": 73, + "column": 0 + } + }, + "range": [ + 993, + 995 + ], + "raw": "\n\n" + }, + { + "type": "Comment", + "value": "boolean:", + "loc": { + "start": { + "line": 73, + "column": 0 + }, + "end": { + "line": 73, + "column": 15 + } + }, + "range": [ + 995, + 1010 + ], + "raw": "" + }, + { + "type": "Str", + "value": "\n\n", + "loc": { + "start": { + "line": 73, + "column": 15 + }, + "end": { + "line": 75, + "column": 0 + } + }, + "range": [ + 1010, + 1012 + ], + "raw": "\n\n" + }, + { + "type": "Html", + "tagName": "script", + "properties": { + "async": true, + "type": "UNKNOWN" + }, + "children": [], + "loc": { + "start": { + "line": 75, + "column": 0 + }, + "end": { + "line": 75, + "column": 23 + } + }, + "range": [ + 1012, + 1035 + ], + "raw": "" + }, + { + "type": "Str", + "value": "\n", + "loc": { + "start": { + "line": 75, + "column": 23 + }, + "end": { + "line": 76, + "column": 0 + } + }, + "range": [ + 1035, + 1036 + ], + "raw": "\n" + }, + { + "type": "Html", + "tagName": "script", + "properties": { + "async": true, + "type": "UNKNOWN" + }, + "children": [], + "loc": { + "start": { + "line": 76, + "column": 0 + }, + "end": { + "line": 76, + "column": 26 + } + }, + "range": [ + 1036, + 1062 + ], + "raw": "" + }, + { + "type": "Str", + "value": "\n", + "loc": { + "start": { + "line": 76, + "column": 26 + }, + "end": { + "line": 77, + "column": 0 + } + }, + "range": [ + 1062, + 1063 + ], + "raw": "\n" + }, + { + "type": "Html", + "tagName": "script", + "properties": { + "async": true, + "type": "UNKNOWN" + }, + "children": [], + "loc": { + "start": { + "line": 77, + "column": 0 + }, + "end": { + "line": 77, + "column": 31 + } + }, + "range": [ + 1063, + 1094 + ], + "raw": "" + }, + { + "type": "Str", + "value": "\n\n", + "loc": { + "start": { + "line": 77, + "column": 31 + }, + "end": { + "line": 79, + "column": 0 + } + }, + "range": [ + 1094, + 1096 + ], + "raw": "\n\n" + }, + { + "type": "Comment", + "value": "overloaded boolean (as boolean):", + "loc": { + "start": { + "line": 79, + "column": 0 + }, + "end": { + "line": 79, + "column": 39 + } + }, + "range": [ + 1096, + 1135 + ], + "raw": "" + }, + { + "type": "Str", + "value": "\n\n", + "loc": { + "start": { + "line": 79, + "column": 39 + }, + "end": { + "line": 81, + "column": 0 + } + }, + "range": [ + 1135, + 1137 + ], + "raw": "\n\n" + }, + { + "type": "Link", + "tagName": "a", + "properties": { + "download": true, + "type": "UNKNOWN" + }, + "children": [], + "loc": { + "start": { + "line": 81, + "column": 0 + }, + "end": { + "line": 81, + "column": 16 + } + }, + "range": [ + 1137, + 1153 + ], + "raw": "" + }, + { + "type": "Str", + "value": "\n", + "loc": { + "start": { + "line": 81, + "column": 16 + }, + "end": { + "line": 82, + "column": 0 + } + }, + "range": [ + 1153, + 1154 + ], + "raw": "\n" + }, + { + "type": "Link", + "tagName": "a", + "properties": { + "download": true, + "type": "UNKNOWN" + }, + "children": [], + "loc": { + "start": { + "line": 82, + "column": 0 + }, + "end": { + "line": 82, + "column": 19 + } + }, + "range": [ + 1154, + 1173 + ], + "raw": "" + }, + { + "type": "Str", + "value": "\n", + "loc": { + "start": { + "line": 82, + "column": 19 + }, + "end": { + "line": 83, + "column": 0 + } + }, + "range": [ + 1173, + 1174 + ], + "raw": "\n" + }, + { + "type": "Link", + "tagName": "a", + "properties": { + "download": true, + "type": "UNKNOWN" + }, + "children": [], + "loc": { + "start": { + "line": 83, + "column": 0 + }, + "end": { + "line": 83, + "column": 27 + } + }, + "range": [ + 1174, + 1201 + ], + "raw": "" + }, + { + "type": "Str", + "value": "\n\n", + "loc": { + "start": { + "line": 83, + "column": 27 + }, + "end": { + "line": 85, + "column": 0 + } + }, + "range": [ + 1201, + 1203 + ], + "raw": "\n\n" + }, + { + "type": "Comment", + "value": "overloaded boolean (as overloaded):", + "loc": { + "start": { + "line": 85, + "column": 0 + }, + "end": { + "line": 85, + "column": 42 + } + }, + "range": [ + 1203, + 1245 + ], + "raw": "" + }, + { + "type": "Str", + "value": "\n\n", + "loc": { + "start": { + "line": 85, + "column": 42 + }, + "end": { + "line": 87, + "column": 0 + } + }, + "range": [ + 1245, + 1247 + ], + "raw": "\n\n" + }, + { + "type": "Link", + "tagName": "a", + "properties": { + "download": "example.mp3", + "type": "UNKNOWN" + }, + "children": [], + "loc": { + "start": { + "line": 87, + "column": 0 + }, + "end": { + "line": 87, + "column": 30 + } + }, + "range": [ + 1247, + 1277 + ], + "raw": "" + }, + { + "type": "Str", + "value": "\n\n", + "loc": { + "start": { + "line": 87, + "column": 30 + }, + "end": { + "line": 89, + "column": 0 + } + }, + "range": [ + 1277, + 1279 + ], + "raw": "\n\n" + }, + { + "type": "Comment", + "value": "positive numeric:", + "loc": { + "start": { + "line": 89, + "column": 0 + }, + "end": { + "line": 89, + "column": 24 + } + }, + "range": [ + 1279, + 1303 + ], + "raw": "" + }, + { + "type": "Str", + "value": "\n\n", + "loc": { + "start": { + "line": 89, + "column": 24 + }, + "end": { + "line": 91, + "column": 0 + } + }, + "range": [ + 1303, + 1305 + ], + "raw": "\n\n" + }, + { + "type": "Image", + "tagName": "img", + "properties": { + "height": 100, + "type": "UNKNOWN" + }, + "children": [], + "loc": { + "start": { + "line": 91, + "column": 0 + }, + "end": { + "line": 91, + "column": 18 + } + }, + "range": [ + 1305, + 1323 + ], + "raw": "" + }, + { + "type": "Str", + "value": "\n\n", + "loc": { + "start": { + "line": 91, + "column": 18 + }, + "end": { + "line": 93, + "column": 0 + } + }, + "range": [ + 1323, + 1325 + ], + "raw": "\n\n" + }, + { + "type": "Comment", + "value": "numeric:", + "loc": { + "start": { + "line": 93, + "column": 0 + }, + "end": { + "line": 93, + "column": 15 + } + }, + "range": [ + 1325, + 1340 + ], + "raw": "" + }, + { + "type": "Str", + "value": "\n\n", + "loc": { + "start": { + "line": 93, + "column": 15 + }, + "end": { + "line": 95, + "column": 0 + } + }, + "range": [ + 1340, + 1342 + ], + "raw": "\n\n" + }, + { + "type": "Html", + "tagName": "meter", + "properties": { + "min": "0", + "low": 40, + "high": 90, + "max": "100", + "value": "95", + "type": "UNKNOWN" + }, + "children": [], + "loc": { + "start": { + "line": 95, + "column": 0 + }, + "end": { + "line": 95, + "column": 63 + } + }, + "range": [ + 1342, + 1405 + ], + "raw": "" + }, + { + "type": "Str", + "value": "\n", + "loc": { + "start": { + "line": 95, + "column": 63 + }, + "end": { + "line": 96, + "column": 0 + } + }, + "range": [ + 1405, + 1406 + ], + "raw": "\n" + } + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 96, + "column": 0 + } + }, + "range": [ + 0, + 1406 + ], + "raw": "\n\n\n\n\n\n
\n\n\n\n\n\n\n\nng-whatevs.\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
\n\n
\n\n
\n\n
\n\n
\n\n
\n\n
\n\n
\n\n
\n\n
\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n" +} \ No newline at end of file diff --git a/test/ast-test-case/element-attributes/result.html b/test/ast-test-case/element-attributes/result.html new file mode 100644 index 0000000..7029e35 --- /dev/null +++ b/test/ast-test-case/element-attributes/result.html @@ -0,0 +1,95 @@ + + + + + + +
+ + + + + + + +ng-whatevs. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + diff --git a/test/ast-test-case/element-auto-close-document/config.json b/test/ast-test-case/element-auto-close-document/config.json new file mode 100644 index 0000000..0967ef4 --- /dev/null +++ b/test/ast-test-case/element-auto-close-document/config.json @@ -0,0 +1 @@ +{} diff --git a/test/ast-test-case/element-auto-close-document/index.html b/test/ast-test-case/element-auto-close-document/index.html new file mode 100644 index 0000000..fbe798f --- /dev/null +++ b/test/ast-test-case/element-auto-close-document/index.html @@ -0,0 +1,8 @@ + + Alpha + +

bravo +

charlie

+
    +
  1. delta +
  2. echo diff --git a/test/ast-test-case/element-auto-close-document/index.json b/test/ast-test-case/element-auto-close-document/index.json new file mode 100644 index 0000000..402bc49 --- /dev/null +++ b/test/ast-test-case/element-auto-close-document/index.json @@ -0,0 +1,386 @@ +{ + "type": "Document", + "children": [ + { + "type": "Html", + "tagName": "head", + "properties": {}, + "children": [ + { + "type": "Str", + "value": "\n ", + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 2, + "column": 2 + } + }, + "range": [ + 6, + 9 + ], + "raw": "\n " + }, + { + "type": "Html", + "tagName": "title", + "properties": {}, + "children": [ + { + "type": "Str", + "value": "Alpha", + "loc": { + "start": { + "line": 2, + "column": 9 + }, + "end": { + "line": 2, + "column": 14 + } + }, + "range": [ + 16, + 21 + ], + "raw": "Alpha" + } + ], + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 22 + } + }, + "range": [ + 9, + 29 + ], + "raw": "Alpha" + }, + { + "type": "Str", + "value": "\n", + "loc": { + "start": { + "line": 2, + "column": 22 + }, + "end": { + "line": 3, + "column": 0 + } + }, + "range": [ + 29, + 30 + ], + "raw": "\n" + } + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 6 + } + }, + "range": [ + 0, + 36 + ], + "raw": "\n Alpha\n" + }, + { + "type": "Html", + "tagName": "body", + "properties": {}, + "children": [ + { + "type": "Str", + "value": "\n", + "loc": { + "start": { + "line": 3, + "column": 5 + }, + "end": { + "line": 4, + "column": 0 + } + }, + "range": [ + 35, + 37 + ], + "raw": ">\n" + }, + { + "type": "Paragraph", + "tagName": "p", + "properties": {}, + "children": [ + { + "type": "Str", + "value": "bravo\n", + "loc": { + "start": { + "line": 4, + "column": 3 + }, + "end": { + "line": 5, + "column": 0 + } + }, + "range": [ + 40, + 46 + ], + "raw": "bravo\n" + } + ], + "loc": { + "start": { + "line": 4, + "column": 0 + }, + "end": { + "line": 5, + "column": 3 + } + }, + "range": [ + 37, + 49 + ], + "raw": "

    bravo\n

    " + }, + { + "type": "Paragraph", + "tagName": "p", + "properties": {}, + "children": [ + { + "type": "Str", + "value": "charlie", + "loc": { + "start": { + "line": 5, + "column": 2 + }, + "end": { + "line": 5, + "column": 9 + } + }, + "range": [ + 48, + 55 + ], + "raw": ">charli" + } + ], + "loc": { + "start": { + "line": 5, + "column": 2 + }, + "end": { + "line": 5, + "column": 13 + } + }, + "range": [ + 48, + 59 + ], + "raw": ">charlie\n" + }, + { + "type": "Html", + "tagName": "ol", + "properties": {}, + "children": [ + { + "type": "Str", + "value": "\n ", + "loc": { + "start": { + "line": 6, + "column": 4 + }, + "end": { + "line": 7, + "column": 2 + } + }, + "range": [ + 65, + 68 + ], + "raw": "\n " + }, + { + "type": "List", + "tagName": "li", + "properties": {}, + "children": [ + { + "type": "Str", + "value": "delta\n ", + "loc": { + "start": { + "line": 7, + "column": 6 + }, + "end": { + "line": 8, + "column": 2 + } + }, + "range": [ + 72, + 80 + ], + "raw": "delta\n " + } + ], + "loc": { + "start": { + "line": 7, + "column": 2 + }, + "end": { + "line": 8, + "column": 6 + } + }, + "range": [ + 68, + 84 + ], + "raw": "

  3. delta\n
  4. " + }, + { + "type": "List", + "tagName": "li", + "properties": {}, + "children": [ + { + "type": "Str", + "value": "echo\n", + "loc": { + "start": { + "line": 8, + "column": 5 + }, + "end": { + "line": 9, + "column": 0 + } + }, + "range": [ + 83, + 89 + ], + "raw": ">echo\n" + } + ], + "loc": { + "start": { + "line": 8, + "column": 5 + }, + "end": { + "line": 9, + "column": 1 + } + }, + "range": [ + 83, + 90 + ], + "raw": ">echo\n" + } + ], + "loc": { + "start": { + "line": 6, + "column": 0 + }, + "end": { + "line": 9, + "column": 1 + } + }, + "range": [ + 61, + 90 + ], + "raw": "
      \n
    1. delta\n
    2. echo\n" + } + ], + "loc": { + "start": { + "line": 3, + "column": 5 + }, + "end": { + "line": 9, + "column": 1 + } + }, + "range": [ + 35, + 90 + ], + "raw": ">\n

      bravo\n

      charlie

      \n
        \n
      1. delta\n
      2. echo\n" + } + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 9, + "column": 0 + } + }, + "range": [ + 0, + 89 + ], + "raw": "\n Alpha\n\n

        bravo\n

        charlie

        \n
          \n
        1. delta\n
        2. echo\n" +} \ No newline at end of file diff --git a/test/ast-test-case/element-auto-close-document/result.html b/test/ast-test-case/element-auto-close-document/result.html new file mode 100644 index 0000000..2bbb060 --- /dev/null +++ b/test/ast-test-case/element-auto-close-document/result.html @@ -0,0 +1,9 @@ + + Alpha + +

          bravo +

          charlie

          +
            +
          1. delta +
          2. echo +
          \ No newline at end of file diff --git a/test/ast-test-case/element-auto-close-fragment/config.json b/test/ast-test-case/element-auto-close-fragment/config.json new file mode 100644 index 0000000..a875830 --- /dev/null +++ b/test/ast-test-case/element-auto-close-fragment/config.json @@ -0,0 +1,3 @@ +{ + "fragment": true +} diff --git a/test/ast-test-case/element-auto-close-fragment/index.html b/test/ast-test-case/element-auto-close-fragment/index.html new file mode 100644 index 0000000..fbe798f --- /dev/null +++ b/test/ast-test-case/element-auto-close-fragment/index.html @@ -0,0 +1,8 @@ + + Alpha + +

          bravo +

          charlie

          +
            +
          1. delta +
          2. echo diff --git a/test/ast-test-case/element-auto-close-fragment/index.json b/test/ast-test-case/element-auto-close-fragment/index.json new file mode 100644 index 0000000..402bc49 --- /dev/null +++ b/test/ast-test-case/element-auto-close-fragment/index.json @@ -0,0 +1,386 @@ +{ + "type": "Document", + "children": [ + { + "type": "Html", + "tagName": "head", + "properties": {}, + "children": [ + { + "type": "Str", + "value": "\n ", + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 2, + "column": 2 + } + }, + "range": [ + 6, + 9 + ], + "raw": "\n " + }, + { + "type": "Html", + "tagName": "title", + "properties": {}, + "children": [ + { + "type": "Str", + "value": "Alpha", + "loc": { + "start": { + "line": 2, + "column": 9 + }, + "end": { + "line": 2, + "column": 14 + } + }, + "range": [ + 16, + 21 + ], + "raw": "Alpha" + } + ], + "loc": { + "start": { + "line": 2, + "column": 2 + }, + "end": { + "line": 2, + "column": 22 + } + }, + "range": [ + 9, + 29 + ], + "raw": "Alpha" + }, + { + "type": "Str", + "value": "\n", + "loc": { + "start": { + "line": 2, + "column": 22 + }, + "end": { + "line": 3, + "column": 0 + } + }, + "range": [ + 29, + 30 + ], + "raw": "\n" + } + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 6 + } + }, + "range": [ + 0, + 36 + ], + "raw": "\n Alpha\n" + }, + { + "type": "Html", + "tagName": "body", + "properties": {}, + "children": [ + { + "type": "Str", + "value": "\n", + "loc": { + "start": { + "line": 3, + "column": 5 + }, + "end": { + "line": 4, + "column": 0 + } + }, + "range": [ + 35, + 37 + ], + "raw": ">\n" + }, + { + "type": "Paragraph", + "tagName": "p", + "properties": {}, + "children": [ + { + "type": "Str", + "value": "bravo\n", + "loc": { + "start": { + "line": 4, + "column": 3 + }, + "end": { + "line": 5, + "column": 0 + } + }, + "range": [ + 40, + 46 + ], + "raw": "bravo\n" + } + ], + "loc": { + "start": { + "line": 4, + "column": 0 + }, + "end": { + "line": 5, + "column": 3 + } + }, + "range": [ + 37, + 49 + ], + "raw": "

            bravo\n

            " + }, + { + "type": "Paragraph", + "tagName": "p", + "properties": {}, + "children": [ + { + "type": "Str", + "value": "charlie", + "loc": { + "start": { + "line": 5, + "column": 2 + }, + "end": { + "line": 5, + "column": 9 + } + }, + "range": [ + 48, + 55 + ], + "raw": ">charli" + } + ], + "loc": { + "start": { + "line": 5, + "column": 2 + }, + "end": { + "line": 5, + "column": 13 + } + }, + "range": [ + 48, + 59 + ], + "raw": ">charlie\n" + }, + { + "type": "Html", + "tagName": "ol", + "properties": {}, + "children": [ + { + "type": "Str", + "value": "\n ", + "loc": { + "start": { + "line": 6, + "column": 4 + }, + "end": { + "line": 7, + "column": 2 + } + }, + "range": [ + 65, + 68 + ], + "raw": "\n " + }, + { + "type": "List", + "tagName": "li", + "properties": {}, + "children": [ + { + "type": "Str", + "value": "delta\n ", + "loc": { + "start": { + "line": 7, + "column": 6 + }, + "end": { + "line": 8, + "column": 2 + } + }, + "range": [ + 72, + 80 + ], + "raw": "delta\n " + } + ], + "loc": { + "start": { + "line": 7, + "column": 2 + }, + "end": { + "line": 8, + "column": 6 + } + }, + "range": [ + 68, + 84 + ], + "raw": "

          3. delta\n
          4. " + }, + { + "type": "List", + "tagName": "li", + "properties": {}, + "children": [ + { + "type": "Str", + "value": "echo\n", + "loc": { + "start": { + "line": 8, + "column": 5 + }, + "end": { + "line": 9, + "column": 0 + } + }, + "range": [ + 83, + 89 + ], + "raw": ">echo\n" + } + ], + "loc": { + "start": { + "line": 8, + "column": 5 + }, + "end": { + "line": 9, + "column": 1 + } + }, + "range": [ + 83, + 90 + ], + "raw": ">echo\n" + } + ], + "loc": { + "start": { + "line": 6, + "column": 0 + }, + "end": { + "line": 9, + "column": 1 + } + }, + "range": [ + 61, + 90 + ], + "raw": "
              \n
            1. delta\n
            2. echo\n" + } + ], + "loc": { + "start": { + "line": 3, + "column": 5 + }, + "end": { + "line": 9, + "column": 1 + } + }, + "range": [ + 35, + 90 + ], + "raw": ">\n

              bravo\n

              charlie

              \n
                \n
              1. delta\n
              2. echo\n" + } + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 9, + "column": 0 + } + }, + "range": [ + 0, + 89 + ], + "raw": "\n Alpha\n\n

                bravo\n

                charlie

                \n
                  \n
                1. delta\n
                2. echo\n" +} \ No newline at end of file diff --git a/test/ast-test-case/element-auto-close-fragment/result.html b/test/ast-test-case/element-auto-close-fragment/result.html new file mode 100644 index 0000000..fd3404d --- /dev/null +++ b/test/ast-test-case/element-auto-close-fragment/result.html @@ -0,0 +1,9 @@ + + Alpha + +

                  bravo +

                  charlie

                  +
                    +
                  1. delta +
                  2. echo +
                  \ No newline at end of file diff --git a/test/ast-test-case/element-broken-close/config.json b/test/ast-test-case/element-broken-close/config.json new file mode 100644 index 0000000..a875830 --- /dev/null +++ b/test/ast-test-case/element-broken-close/config.json @@ -0,0 +1,3 @@ +{ + "fragment": true +} diff --git a/test/ast-test-case/element-broken-close/index.html b/test/ast-test-case/element-broken-close/index.html new file mode 100644 index 0000000..5c8d13c --- /dev/null +++ b/test/ast-test-case/element-broken-close/index.html @@ -0,0 +1 @@ +fooStrong, emphasis, and code. diff --git a/test/ast-test-case/element-children/index.json b/test/ast-test-case/element-children/index.json new file mode 100644 index 0000000..ace4248 --- /dev/null +++ b/test/ast-test-case/element-children/index.json @@ -0,0 +1,241 @@ +{ + "type": "Document", + "children": [ + { + "type": "Html", + "tagName": "div", + "properties": {}, + "children": [ + { + "type": "Strong", + "tagName": "strong", + "properties": {}, + "children": [ + { + "type": "Str", + "value": "Strong", + "loc": { + "start": { + "line": 1, + "column": 13 + }, + "end": { + "line": 1, + "column": 19 + } + }, + "range": [ + 13, + 19 + ], + "raw": "Strong" + } + ], + "loc": { + "start": { + "line": 1, + "column": 5 + }, + "end": { + "line": 1, + "column": 28 + } + }, + "range": [ + 5, + 28 + ], + "raw": "Strong" + }, + { + "type": "Str", + "value": ", ", + "loc": { + "start": { + "line": 1, + "column": 28 + }, + "end": { + "line": 1, + "column": 30 + } + }, + "range": [ + 28, + 30 + ], + "raw": ", " + }, + { + "type": "Emphasis", + "tagName": "em", + "properties": {}, + "children": [ + { + "type": "Str", + "value": "emphasis", + "loc": { + "start": { + "line": 1, + "column": 34 + }, + "end": { + "line": 1, + "column": 42 + } + }, + "range": [ + 34, + 42 + ], + "raw": "emphasis" + } + ], + "loc": { + "start": { + "line": 1, + "column": 30 + }, + "end": { + "line": 1, + "column": 47 + } + }, + "range": [ + 30, + 47 + ], + "raw": "emphasis" + }, + { + "type": "Str", + "value": ", and ", + "loc": { + "start": { + "line": 1, + "column": 47 + }, + "end": { + "line": 1, + "column": 53 + } + }, + "range": [ + 47, + 53 + ], + "raw": ", and " + }, + { + "type": "CodeBlock", + "tagName": "code", + "properties": {}, + "children": [ + { + "type": "Str", + "value": "code", + "loc": { + "start": { + "line": 1, + "column": 59 + }, + "end": { + "line": 1, + "column": 63 + } + }, + "range": [ + 59, + 63 + ], + "raw": "code" + } + ], + "loc": { + "start": { + "line": 1, + "column": 53 + }, + "end": { + "line": 1, + "column": 70 + } + }, + "range": [ + 53, + 70 + ], + "raw": "code" + }, + { + "type": "Str", + "value": ".", + "loc": { + "start": { + "line": 1, + "column": 70 + }, + "end": { + "line": 1, + "column": 71 + } + }, + "range": [ + 70, + 71 + ], + "raw": "." + } + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 77 + } + }, + "range": [ + 0, + 77 + ], + "raw": "
                  Strong, emphasis, and code.
                  " + }, + { + "type": "Str", + "value": "\n", + "loc": { + "start": { + "line": 1, + "column": 77 + }, + "end": { + "line": 2, + "column": 0 + } + }, + "range": [ + 77, + 78 + ], + "raw": "\n" + } + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 0 + } + }, + "range": [ + 0, + 78 + ], + "raw": "
                  Strong, emphasis, and code.
                  \n" +} \ No newline at end of file diff --git a/test/ast-test-case/element-closing-attributes/config.json b/test/ast-test-case/element-closing-attributes/config.json new file mode 100644 index 0000000..a875830 --- /dev/null +++ b/test/ast-test-case/element-closing-attributes/config.json @@ -0,0 +1,3 @@ +{ + "fragment": true +} diff --git a/test/ast-test-case/element-closing-attributes/index.html b/test/ast-test-case/element-closing-attributes/index.html new file mode 100644 index 0000000..149b0cf --- /dev/null +++ b/test/ast-test-case/element-closing-attributes/index.html @@ -0,0 +1,3 @@ +bar +bar +bar diff --git a/test/ast-test-case/element-closing-attributes/index.json b/test/ast-test-case/element-closing-attributes/index.json new file mode 100644 index 0000000..44e69b8 --- /dev/null +++ b/test/ast-test-case/element-closing-attributes/index.json @@ -0,0 +1,200 @@ +{ + "type": "Document", + "children": [ + { + "type": "Html", + "tagName": "foo", + "properties": {}, + "children": [ + { + "type": "Str", + "value": "bar", + "loc": { + "start": { + "line": 1, + "column": 5 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "range": [ + 5, + 8 + ], + "raw": "bar" + } + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "range": [ + 0, + 14 + ], + "raw": "bar" + }, + { + "type": "Str", + "value": "\n", + "loc": { + "start": { + "line": 1, + "column": 14 + }, + "end": { + "line": 2, + "column": 0 + } + }, + "range": [ + 14, + 15 + ], + "raw": "\n" + }, + { + "type": "Html", + "tagName": "foo", + "properties": {}, + "children": [ + { + "type": "Str", + "value": "bar", + "loc": { + "start": { + "line": 2, + "column": 5 + }, + "end": { + "line": 2, + "column": 8 + } + }, + "range": [ + 20, + 23 + ], + "raw": "bar" + } + ], + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 14 + } + }, + "range": [ + 15, + 29 + ], + "raw": "bar\n" + }, + { + "type": "Html", + "tagName": "foo", + "properties": {}, + "children": [ + { + "type": "Str", + "value": "bar", + "loc": { + "start": { + "line": 3, + "column": 5 + }, + "end": { + "line": 3, + "column": 8 + } + }, + "range": [ + 39, + 42 + ], + "raw": "bar" + } + ], + "loc": { + "start": { + "line": 3, + "column": 0 + }, + "end": { + "line": 3, + "column": 14 + } + }, + "range": [ + 34, + 48 + ], + "raw": "bar\n" + } + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 4, + "column": 0 + } + }, + "range": [ + 0, + 59 + ], + "raw": "bar\nbar\nbar\n" +} \ No newline at end of file diff --git a/test/ast-test-case/element-closing-attributes/result.html b/test/ast-test-case/element-closing-attributes/result.html new file mode 100644 index 0000000..2dad3ac --- /dev/null +++ b/test/ast-test-case/element-closing-attributes/result.html @@ -0,0 +1,3 @@ +bar +bar +bar diff --git a/test/ast-test-case/element-closing/config.json b/test/ast-test-case/element-closing/config.json new file mode 100644 index 0000000..a875830 --- /dev/null +++ b/test/ast-test-case/element-closing/config.json @@ -0,0 +1,3 @@ +{ + "fragment": true +} diff --git a/test/ast-test-case/element-closing/index.html b/test/ast-test-case/element-closing/index.html new file mode 100644 index 0000000..e3f53f9 --- /dev/null +++ b/test/ast-test-case/element-closing/index.html @@ -0,0 +1,3 @@ +bar +bar +bar diff --git a/test/ast-test-case/element-closing/index.json b/test/ast-test-case/element-closing/index.json new file mode 100644 index 0000000..7ad535e --- /dev/null +++ b/test/ast-test-case/element-closing/index.json @@ -0,0 +1,200 @@ +{ + "type": "Document", + "children": [ + { + "type": "Html", + "tagName": "foo", + "properties": {}, + "children": [ + { + "type": "Str", + "value": "bar", + "loc": { + "start": { + "line": 1, + "column": 5 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "range": [ + 5, + 8 + ], + "raw": "bar" + } + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "range": [ + 0, + 14 + ], + "raw": "bar" + }, + { + "type": "Str", + "value": "\n", + "loc": { + "start": { + "line": 1, + "column": 14 + }, + "end": { + "line": 2, + "column": 0 + } + }, + "range": [ + 14, + 15 + ], + "raw": "\n" + }, + { + "type": "Html", + "tagName": "foo", + "properties": {}, + "children": [ + { + "type": "Str", + "value": "bar", + "loc": { + "start": { + "line": 2, + "column": 5 + }, + "end": { + "line": 2, + "column": 8 + } + }, + "range": [ + 20, + 23 + ], + "raw": "bar" + } + ], + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 14 + } + }, + "range": [ + 15, + 29 + ], + "raw": "bar" + }, + { + "type": "Str", + "value": "\n", + "loc": { + "start": { + "line": 2, + "column": 14 + }, + "end": { + "line": 3, + "column": 0 + } + }, + "range": [ + 29, + 30 + ], + "raw": "\n" + }, + { + "type": "Html", + "tagName": "foo", + "properties": {}, + "children": [ + { + "type": "Str", + "value": "bar", + "loc": { + "start": { + "line": 3, + "column": 5 + }, + "end": { + "line": 3, + "column": 8 + } + }, + "range": [ + 35, + 38 + ], + "raw": "bar" + } + ], + "loc": { + "start": { + "line": 3, + "column": 0 + }, + "end": { + "line": 3, + "column": 14 + } + }, + "range": [ + 30, + 44 + ], + "raw": "bar" + }, + { + "type": "Str", + "value": "\n", + "loc": { + "start": { + "line": 3, + "column": 14 + }, + "end": { + "line": 4, + "column": 0 + } + }, + "range": [ + 44, + 45 + ], + "raw": "\n" + } + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 4, + "column": 0 + } + }, + "range": [ + 0, + 45 + ], + "raw": "bar\nbar\nbar\n" +} \ No newline at end of file diff --git a/test/ast-test-case/element-closing/result.html b/test/ast-test-case/element-closing/result.html new file mode 100644 index 0000000..2dad3ac --- /dev/null +++ b/test/ast-test-case/element-closing/result.html @@ -0,0 +1,3 @@ +bar +bar +bar diff --git a/test/ast-test-case/element-empty/config.json b/test/ast-test-case/element-empty/config.json new file mode 100644 index 0000000..a875830 --- /dev/null +++ b/test/ast-test-case/element-empty/config.json @@ -0,0 +1,3 @@ +{ + "fragment": true +} diff --git a/test/ast-test-case/element-empty/index.html b/test/ast-test-case/element-empty/index.html new file mode 100644 index 0000000..dc1c977 --- /dev/null +++ b/test/ast-test-case/element-empty/index.html @@ -0,0 +1 @@ + diff --git a/test/ast-test-case/element-empty/index.json b/test/ast-test-case/element-empty/index.json new file mode 100644 index 0000000..1660f71 --- /dev/null +++ b/test/ast-test-case/element-empty/index.json @@ -0,0 +1,60 @@ +{ + "type": "Document", + "children": [ + { + "type": "Html", + "tagName": "span", + "properties": {}, + "children": [], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "range": [ + 0, + 13 + ], + "raw": "" + }, + { + "type": "Str", + "value": "\n", + "loc": { + "start": { + "line": 1, + "column": 13 + }, + "end": { + "line": 2, + "column": 0 + } + }, + "range": [ + 13, + 14 + ], + "raw": "\n" + } + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 0 + } + }, + "range": [ + 0, + 14 + ], + "raw": "\n" +} \ No newline at end of file diff --git a/test/ast-test-case/element-loose-close-document/config.json b/test/ast-test-case/element-loose-close-document/config.json new file mode 100644 index 0000000..0967ef4 --- /dev/null +++ b/test/ast-test-case/element-loose-close-document/config.json @@ -0,0 +1 @@ +{} diff --git a/test/ast-test-case/element-loose-close-document/index.html b/test/ast-test-case/element-loose-close-document/index.html new file mode 100644 index 0000000..484f35a --- /dev/null +++ b/test/ast-test-case/element-loose-close-document/index.html @@ -0,0 +1,6 @@ + + + +

                  + +

                  diff --git a/test/ast-test-case/element-loose-close-document/index.json b/test/ast-test-case/element-loose-close-document/index.json new file mode 100644 index 0000000..e941814 --- /dev/null +++ b/test/ast-test-case/element-loose-close-document/index.json @@ -0,0 +1,162 @@ +{ + "type": "Document", + "children": [ + { + "type": "Html", + "tagName": "body", + "properties": {}, + "children": [], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 19 + } + }, + "range": [ + 0, + 19 + ], + "raw": "" + }, + { + "type": "Str", + "value": "\n\n\n", + "loc": { + "start": { + "line": 1, + "column": 26 + }, + "end": { + "line": 4, + "column": 0 + } + }, + "range": [ + 26, + 29 + ], + "raw": "\n\n\n" + }, + { + "type": "Paragraph", + "tagName": "p", + "properties": {}, + "children": [], + "loc": { + "start": { + "line": 4, + "column": 3 + }, + "end": { + "line": 4, + "column": 4 + } + }, + "range": [ + 32, + 33 + ], + "raw": ">" + }, + { + "type": "Str", + "value": "\n\n", + "loc": { + "start": { + "line": 4, + "column": 3 + }, + "end": { + "line": 6, + "column": 0 + } + }, + "range": [ + 32, + 35 + ], + "raw": ">\n\n" + }, + { + "type": "Html", + "tagName": "div", + "properties": {}, + "children": [ + { + "type": "Paragraph", + "tagName": "p", + "properties": {}, + "children": [], + "loc": { + "start": { + "line": 6, + "column": 8 + }, + "end": { + "line": 6, + "column": 9 + } + }, + "range": [ + 43, + 44 + ], + "raw": ">" + } + ], + "loc": { + "start": { + "line": 6, + "column": 0 + }, + "end": { + "line": 6, + "column": 14 + } + }, + "range": [ + 35, + 49 + ], + "raw": "

                  \n" + } + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 7, + "column": 0 + } + }, + "range": [ + 0, + 51 + ], + "raw": "
                  \n\n\n

                  \n\n

                  \n" +} \ No newline at end of file diff --git a/test/ast-test-case/element-loose-close-document/result.html b/test/ast-test-case/element-loose-close-document/result.html new file mode 100644 index 0000000..7514f11 --- /dev/null +++ b/test/ast-test-case/element-loose-close-document/result.html @@ -0,0 +1,7 @@ + + + +

                  + +

                  + \ No newline at end of file diff --git a/test/ast-test-case/element-loose-close-fragment/config.json b/test/ast-test-case/element-loose-close-fragment/config.json new file mode 100644 index 0000000..a875830 --- /dev/null +++ b/test/ast-test-case/element-loose-close-fragment/config.json @@ -0,0 +1,3 @@ +{ + "fragment": true +} diff --git a/test/ast-test-case/element-loose-close-fragment/index.html b/test/ast-test-case/element-loose-close-fragment/index.html new file mode 100644 index 0000000..484f35a --- /dev/null +++ b/test/ast-test-case/element-loose-close-fragment/index.html @@ -0,0 +1,6 @@ + + + +

                  + +

                  diff --git a/test/ast-test-case/element-loose-close-fragment/index.json b/test/ast-test-case/element-loose-close-fragment/index.json new file mode 100644 index 0000000..e941814 --- /dev/null +++ b/test/ast-test-case/element-loose-close-fragment/index.json @@ -0,0 +1,162 @@ +{ + "type": "Document", + "children": [ + { + "type": "Html", + "tagName": "body", + "properties": {}, + "children": [], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 19 + } + }, + "range": [ + 0, + 19 + ], + "raw": "" + }, + { + "type": "Str", + "value": "\n\n\n", + "loc": { + "start": { + "line": 1, + "column": 26 + }, + "end": { + "line": 4, + "column": 0 + } + }, + "range": [ + 26, + 29 + ], + "raw": "\n\n\n" + }, + { + "type": "Paragraph", + "tagName": "p", + "properties": {}, + "children": [], + "loc": { + "start": { + "line": 4, + "column": 3 + }, + "end": { + "line": 4, + "column": 4 + } + }, + "range": [ + 32, + 33 + ], + "raw": ">" + }, + { + "type": "Str", + "value": "\n\n", + "loc": { + "start": { + "line": 4, + "column": 3 + }, + "end": { + "line": 6, + "column": 0 + } + }, + "range": [ + 32, + 35 + ], + "raw": ">\n\n" + }, + { + "type": "Html", + "tagName": "div", + "properties": {}, + "children": [ + { + "type": "Paragraph", + "tagName": "p", + "properties": {}, + "children": [], + "loc": { + "start": { + "line": 6, + "column": 8 + }, + "end": { + "line": 6, + "column": 9 + } + }, + "range": [ + 43, + 44 + ], + "raw": ">" + } + ], + "loc": { + "start": { + "line": 6, + "column": 0 + }, + "end": { + "line": 6, + "column": 14 + } + }, + "range": [ + 35, + 49 + ], + "raw": "

                  \n" + } + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 7, + "column": 0 + } + }, + "range": [ + 0, + 51 + ], + "raw": "
                  \n\n\n

                  \n\n

                  \n" +} \ No newline at end of file diff --git a/test/ast-test-case/element-loose-close-fragment/result.html b/test/ast-test-case/element-loose-close-fragment/result.html new file mode 100644 index 0000000..e8972b1 --- /dev/null +++ b/test/ast-test-case/element-loose-close-fragment/result.html @@ -0,0 +1,6 @@ + + + +

                  + +

                  diff --git a/test/ast-test-case/element-opening/config.json b/test/ast-test-case/element-opening/config.json new file mode 100644 index 0000000..a875830 --- /dev/null +++ b/test/ast-test-case/element-opening/config.json @@ -0,0 +1,3 @@ +{ + "fragment": true +} diff --git a/test/ast-test-case/element-opening/index.html b/test/ast-test-case/element-opening/index.html new file mode 100644 index 0000000..58816ff --- /dev/null +++ b/test/ast-test-case/element-opening/index.html @@ -0,0 +1,3 @@ +bar +bar +bar diff --git a/test/ast-test-case/element-opening/index.json b/test/ast-test-case/element-opening/index.json new file mode 100644 index 0000000..aba9410 --- /dev/null +++ b/test/ast-test-case/element-opening/index.json @@ -0,0 +1,200 @@ +{ + "type": "Document", + "children": [ + { + "type": "Html", + "tagName": "foo", + "properties": {}, + "children": [ + { + "type": "Str", + "value": "bar", + "loc": { + "start": { + "line": 1, + "column": 5 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "range": [ + 5, + 8 + ], + "raw": "bar" + } + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 14 + } + }, + "range": [ + 0, + 14 + ], + "raw": "bar" + }, + { + "type": "Str", + "value": "\n", + "loc": { + "start": { + "line": 1, + "column": 14 + }, + "end": { + "line": 2, + "column": 0 + } + }, + "range": [ + 14, + 15 + ], + "raw": "\n" + }, + { + "type": "Html", + "tagName": "foo", + "properties": {}, + "children": [ + { + "type": "Str", + "value": "bar", + "loc": { + "start": { + "line": 2, + "column": 5 + }, + "end": { + "line": 2, + "column": 8 + } + }, + "range": [ + 20, + 23 + ], + "raw": "bar" + } + ], + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 14 + } + }, + "range": [ + 15, + 29 + ], + "raw": "bar" + }, + { + "type": "Str", + "value": "\n", + "loc": { + "start": { + "line": 2, + "column": 14 + }, + "end": { + "line": 3, + "column": 0 + } + }, + "range": [ + 29, + 30 + ], + "raw": "\n" + }, + { + "type": "Html", + "tagName": "foo", + "properties": {}, + "children": [ + { + "type": "Str", + "value": "bar", + "loc": { + "start": { + "line": 3, + "column": 5 + }, + "end": { + "line": 3, + "column": 8 + } + }, + "range": [ + 35, + 38 + ], + "raw": "bar" + } + ], + "loc": { + "start": { + "line": 3, + "column": 0 + }, + "end": { + "line": 3, + "column": 14 + } + }, + "range": [ + 30, + 44 + ], + "raw": "bar" + }, + { + "type": "Str", + "value": "\n", + "loc": { + "start": { + "line": 3, + "column": 14 + }, + "end": { + "line": 4, + "column": 0 + } + }, + "range": [ + 44, + 45 + ], + "raw": "\n" + } + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 4, + "column": 0 + } + }, + "range": [ + 0, + 45 + ], + "raw": "bar\nbar\nbar\n" +} \ No newline at end of file diff --git a/test/ast-test-case/element-opening/result.html b/test/ast-test-case/element-opening/result.html new file mode 100644 index 0000000..2dad3ac --- /dev/null +++ b/test/ast-test-case/element-opening/result.html @@ -0,0 +1,3 @@ +bar +bar +bar diff --git a/test/ast-test-case/element-void-close/config.json b/test/ast-test-case/element-void-close/config.json new file mode 100644 index 0000000..a875830 --- /dev/null +++ b/test/ast-test-case/element-void-close/config.json @@ -0,0 +1,3 @@ +{ + "fragment": true +} diff --git a/test/ast-test-case/element-void-close/index.html b/test/ast-test-case/element-void-close/index.html new file mode 100644 index 0000000..632cf29 --- /dev/null +++ b/test/ast-test-case/element-void-close/index.html @@ -0,0 +1,2 @@ +
                  text
                  +text diff --git a/test/ast-test-case/element-void-close/index.json b/test/ast-test-case/element-void-close/index.json new file mode 100644 index 0000000..5fd2041 --- /dev/null +++ b/test/ast-test-case/element-void-close/index.json @@ -0,0 +1,140 @@ +{ + "type": "Document", + "children": [ + { + "type": "break", + "tagName": "br", + "properties": {}, + "children": [], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 4 + } + }, + "range": [ + 0, + 4 + ], + "raw": "
                  " + }, + { + "type": "Str", + "value": "text", + "loc": { + "start": { + "line": 1, + "column": 4 + }, + "end": { + "line": 1, + "column": 8 + } + }, + "range": [ + 4, + 8 + ], + "raw": "text" + }, + { + "type": "break", + "tagName": "br", + "properties": {}, + "children": [], + "loc": { + "start": { + "line": 1, + "column": 12 + }, + "end": { + "line": 1, + "column": 13 + } + }, + "range": [ + 12, + 13 + ], + "raw": ">" + }, + { + "type": "Str", + "value": "\n", + "loc": { + "start": { + "line": 1, + "column": 12 + }, + "end": { + "line": 2, + "column": 0 + } + }, + "range": [ + 12, + 14 + ], + "raw": ">\n" + }, + { + "type": "Image", + "tagName": "img", + "properties": {}, + "children": [], + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 5 + } + }, + "range": [ + 14, + 19 + ], + "raw": "" + }, + { + "type": "Str", + "value": "text\n", + "loc": { + "start": { + "line": 2, + "column": 5 + }, + "end": { + "line": 3, + "column": 0 + } + }, + "range": [ + 19, + 30 + ], + "raw": "text\n" + } + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 0 + } + }, + "range": [ + 0, + 30 + ], + "raw": "
                  text
                  \ntext\n" +} \ No newline at end of file diff --git a/test/ast-test-case/element-void-close/result.html b/test/ast-test-case/element-void-close/result.html new file mode 100644 index 0000000..99a376f --- /dev/null +++ b/test/ast-test-case/element-void-close/result.html @@ -0,0 +1,2 @@ +
                  text
                  +text diff --git a/test/ast-test-case/element-void/config.json b/test/ast-test-case/element-void/config.json new file mode 100644 index 0000000..a875830 --- /dev/null +++ b/test/ast-test-case/element-void/config.json @@ -0,0 +1,3 @@ +{ + "fragment": true +} diff --git a/test/ast-test-case/element-void/index.html b/test/ast-test-case/element-void/index.html new file mode 100644 index 0000000..9ebc10d --- /dev/null +++ b/test/ast-test-case/element-void/index.html @@ -0,0 +1,15 @@ +foo + +
                  + +

                  this
                  and that

                  + +

                  this
                  and that

                  + + + + + + + + diff --git a/test/ast-test-case/element-void/index.json b/test/ast-test-case/element-void/index.json new file mode 100644 index 0000000..565b160 --- /dev/null +++ b/test/ast-test-case/element-void/index.json @@ -0,0 +1,769 @@ +{ + "type": "Document", + "children": [ + { + "type": "Image", + "tagName": "img", + "properties": { + "src": "http://example.com/fav.ico", + "alt": "foo", + "title": "bar", + "type": "UNKNOWN" + }, + "children": [], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 60 + } + }, + "range": [ + 0, + 60 + ], + "raw": "\"foo\"" + }, + { + "type": "Str", + "value": "\n\n", + "loc": { + "start": { + "line": 1, + "column": 60 + }, + "end": { + "line": 3, + "column": 0 + } + }, + "range": [ + 60, + 62 + ], + "raw": "\n\n" + }, + { + "type": "horizontalRule", + "tagName": "hr", + "properties": {}, + "children": [], + "loc": { + "start": { + "line": 3, + "column": 0 + }, + "end": { + "line": 3, + "column": 4 + } + }, + "range": [ + 62, + 66 + ], + "raw": "
                  " + }, + { + "type": "Str", + "value": "\n\n", + "loc": { + "start": { + "line": 3, + "column": 4 + }, + "end": { + "line": 5, + "column": 0 + } + }, + "range": [ + 66, + 68 + ], + "raw": "\n\n" + }, + { + "type": "Paragraph", + "tagName": "p", + "properties": {}, + "children": [ + { + "type": "Str", + "value": "this", + "loc": { + "start": { + "line": 5, + "column": 3 + }, + "end": { + "line": 5, + "column": 7 + } + }, + "range": [ + 71, + 75 + ], + "raw": "this" + }, + { + "type": "break", + "tagName": "br", + "properties": {}, + "children": [], + "loc": { + "start": { + "line": 5, + "column": 7 + }, + "end": { + "line": 5, + "column": 12 + } + }, + "range": [ + 75, + 80 + ], + "raw": "
                  " + }, + { + "type": "Str", + "value": "and that", + "loc": { + "start": { + "line": 5, + "column": 12 + }, + "end": { + "line": 5, + "column": 20 + } + }, + "range": [ + 80, + 88 + ], + "raw": "and that" + } + ], + "loc": { + "start": { + "line": 5, + "column": 0 + }, + "end": { + "line": 5, + "column": 24 + } + }, + "range": [ + 68, + 92 + ], + "raw": "

                  this
                  and that

                  " + }, + { + "type": "Str", + "value": "\n\n", + "loc": { + "start": { + "line": 5, + "column": 24 + }, + "end": { + "line": 7, + "column": 0 + } + }, + "range": [ + 92, + 94 + ], + "raw": "\n\n" + }, + { + "type": "Paragraph", + "tagName": "p", + "properties": {}, + "children": [ + { + "type": "Str", + "value": "this", + "loc": { + "start": { + "line": 7, + "column": 3 + }, + "end": { + "line": 7, + "column": 7 + } + }, + "range": [ + 97, + 101 + ], + "raw": "this" + }, + { + "type": "break", + "tagName": "br", + "properties": {}, + "children": [], + "loc": { + "start": { + "line": 7, + "column": 7 + }, + "end": { + "line": 7, + "column": 11 + } + }, + "range": [ + 101, + 105 + ], + "raw": "
                  " + }, + { + "type": "Str", + "value": "and that", + "loc": { + "start": { + "line": 7, + "column": 11 + }, + "end": { + "line": 7, + "column": 19 + } + }, + "range": [ + 105, + 113 + ], + "raw": "and that" + } + ], + "loc": { + "start": { + "line": 7, + "column": 0 + }, + "end": { + "line": 7, + "column": 23 + } + }, + "range": [ + 94, + 117 + ], + "raw": "

                  this
                  and that

                  " + }, + { + "type": "Str", + "value": "\n\n", + "loc": { + "start": { + "line": 7, + "column": 23 + }, + "end": { + "line": 9, + "column": 0 + } + }, + "range": [ + 117, + 119 + ], + "raw": "\n\n" + }, + { + "type": "Html", + "tagName": "svg", + "properties": {}, + "children": [ + { + "type": "Html", + "tagName": "path", + "properties": {}, + "children": [], + "loc": { + "start": { + "line": 9, + "column": 5 + }, + "end": { + "line": 9, + "column": 11 + } + }, + "range": [ + 124, + 130 + ], + "raw": "" + }, + { + "type": "Html", + "tagName": "circle", + "properties": {}, + "children": [], + "loc": { + "start": { + "line": 9, + "column": 11 + }, + "end": { + "line": 9, + "column": 19 + } + }, + "range": [ + 130, + 138 + ], + "raw": "" + }, + { + "type": "Html", + "tagName": "g", + "properties": {}, + "children": [ + { + "type": "Html", + "tagName": "rect", + "properties": {}, + "children": [], + "loc": { + "start": { + "line": 9, + "column": 22 + }, + "end": { + "line": 9, + "column": 28 + } + }, + "range": [ + 141, + 147 + ], + "raw": "" + } + ], + "loc": { + "start": { + "line": 9, + "column": 19 + }, + "end": { + "line": 9, + "column": 34 + } + }, + "range": [ + 138, + 153 + ], + "raw": "" + } + ], + "loc": { + "start": { + "line": 9, + "column": 0 + }, + "end": { + "line": 9, + "column": 34 + } + }, + "range": [ + 119, + 153 + ], + "raw": "" + }, + { + "type": "Str", + "value": "\n\n", + "loc": { + "start": { + "line": 9, + "column": 34 + }, + "end": { + "line": 11, + "column": 0 + } + }, + "range": [ + 153, + 155 + ], + "raw": "\n\n" + }, + { + "type": "Html", + "tagName": "svg", + "properties": {}, + "children": [ + { + "type": "Html", + "tagName": "path", + "properties": {}, + "children": [], + "loc": { + "start": { + "line": 11, + "column": 5 + }, + "end": { + "line": 11, + "column": 12 + } + }, + "range": [ + 160, + 167 + ], + "raw": "" + }, + { + "type": "Html", + "tagName": "circle", + "properties": {}, + "children": [], + "loc": { + "start": { + "line": 11, + "column": 12 + }, + "end": { + "line": 11, + "column": 21 + } + }, + "range": [ + 167, + 176 + ], + "raw": "" + }, + { + "type": "Html", + "tagName": "g", + "properties": {}, + "children": [ + { + "type": "Html", + "tagName": "rect", + "properties": {}, + "children": [], + "loc": { + "start": { + "line": 11, + "column": 25 + }, + "end": { + "line": 11, + "column": 32 + } + }, + "range": [ + 180, + 187 + ], + "raw": "" + } + ], + "loc": { + "start": { + "line": 11, + "column": 21 + }, + "end": { + "line": 11, + "column": 38 + } + }, + "range": [ + 176, + 193 + ], + "raw": "" + } + ], + "loc": { + "start": { + "line": 11, + "column": 0 + }, + "end": { + "line": 11, + "column": 38 + } + }, + "range": [ + 155, + 193 + ], + "raw": "" + }, + { + "type": "Str", + "value": "\n\n", + "loc": { + "start": { + "line": 11, + "column": 38 + }, + "end": { + "line": 13, + "column": 0 + } + }, + "range": [ + 193, + 195 + ], + "raw": "\n\n" + }, + { + "type": "Html", + "tagName": "math", + "properties": {}, + "children": [ + { + "type": "Html", + "tagName": "mglyph", + "properties": {}, + "children": [ + { + "type": "Html", + "tagName": "mspace", + "properties": {}, + "children": [ + { + "type": "Html", + "tagName": "malignmark", + "properties": {}, + "children": [], + "loc": { + "start": { + "line": 13, + "column": 22 + }, + "end": { + "line": 13, + "column": 41 + } + }, + "range": [ + 217, + 236 + ], + "raw": "" + } + ], + "loc": { + "start": { + "line": 13, + "column": 14 + }, + "end": { + "line": 13, + "column": 41 + } + }, + "range": [ + 209, + 236 + ], + "raw": "" + } + ], + "loc": { + "start": { + "line": 13, + "column": 6 + }, + "end": { + "line": 13, + "column": 41 + } + }, + "range": [ + 201, + 236 + ], + "raw": "" + } + ], + "loc": { + "start": { + "line": 13, + "column": 0 + }, + "end": { + "line": 13, + "column": 41 + } + }, + "range": [ + 195, + 236 + ], + "raw": "" + }, + { + "type": "Str", + "value": "\n\n", + "loc": { + "start": { + "line": 13, + "column": 41 + }, + "end": { + "line": 15, + "column": 0 + } + }, + "range": [ + 236, + 238 + ], + "raw": "\n\n" + }, + { + "type": "Html", + "tagName": "math", + "properties": {}, + "children": [ + { + "type": "Html", + "tagName": "mglyph", + "properties": {}, + "children": [ + { + "type": "Html", + "tagName": "mspace", + "properties": {}, + "children": [ + { + "type": "Html", + "tagName": "malignmark", + "properties": {}, + "children": [], + "loc": { + "start": { + "line": 15, + "column": 24 + }, + "end": { + "line": 15, + "column": 44 + } + }, + "range": [ + 262, + 282 + ], + "raw": "" + } + ], + "loc": { + "start": { + "line": 15, + "column": 15 + }, + "end": { + "line": 15, + "column": 44 + } + }, + "range": [ + 253, + 282 + ], + "raw": "" + } + ], + "loc": { + "start": { + "line": 15, + "column": 6 + }, + "end": { + "line": 15, + "column": 44 + } + }, + "range": [ + 244, + 282 + ], + "raw": "" + } + ], + "loc": { + "start": { + "line": 15, + "column": 0 + }, + "end": { + "line": 15, + "column": 44 + } + }, + "range": [ + 238, + 282 + ], + "raw": "" + }, + { + "type": "Str", + "value": "\n", + "loc": { + "start": { + "line": 15, + "column": 44 + }, + "end": { + "line": 16, + "column": 0 + } + }, + "range": [ + 282, + 283 + ], + "raw": "\n" + } + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 16, + "column": 0 + } + }, + "range": [ + 0, + 283 + ], + "raw": "\"foo\"\n\n
                  \n\n

                  this
                  and that

                  \n\n

                  this
                  and that

                  \n\n\n\n\n\n\n\n\n" +} \ No newline at end of file diff --git a/test/ast-test-case/element-void/result.html b/test/ast-test-case/element-void/result.html new file mode 100644 index 0000000..e9809b6 --- /dev/null +++ b/test/ast-test-case/element-void/result.html @@ -0,0 +1,15 @@ +foo + +
                  + +

                  this
                  and that

                  + +

                  this
                  and that

                  + + + + + + + + diff --git a/test/ast-test-case/element/config.json b/test/ast-test-case/element/config.json new file mode 100644 index 0000000..a875830 --- /dev/null +++ b/test/ast-test-case/element/config.json @@ -0,0 +1,3 @@ +{ + "fragment": true +} diff --git a/test/ast-test-case/element/index.html b/test/ast-test-case/element/index.html new file mode 100644 index 0000000..4fead10 --- /dev/null +++ b/test/ast-test-case/element/index.html @@ -0,0 +1 @@ +Hello World. diff --git a/test/ast-test-case/element/index.json b/test/ast-test-case/element/index.json new file mode 100644 index 0000000..5ffc0b0 --- /dev/null +++ b/test/ast-test-case/element/index.json @@ -0,0 +1,80 @@ +{ + "type": "Document", + "children": [ + { + "type": "Strong", + "tagName": "strong", + "properties": {}, + "children": [ + { + "type": "Str", + "value": "Hello World.", + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 1, + "column": 20 + } + }, + "range": [ + 8, + 20 + ], + "raw": "Hello World." + } + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 29 + } + }, + "range": [ + 0, + 29 + ], + "raw": "Hello World." + }, + { + "type": "Str", + "value": "\n", + "loc": { + "start": { + "line": 1, + "column": 29 + }, + "end": { + "line": 2, + "column": 0 + } + }, + "range": [ + 29, + 30 + ], + "raw": "\n" + } + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 0 + } + }, + "range": [ + 0, + 30 + ], + "raw": "Hello World.\n" +} \ No newline at end of file diff --git a/test/ast-test-case/empty-document/config.json b/test/ast-test-case/empty-document/config.json new file mode 100644 index 0000000..0967ef4 --- /dev/null +++ b/test/ast-test-case/empty-document/config.json @@ -0,0 +1 @@ +{} diff --git a/test/ast-test-case/empty-document/index.html b/test/ast-test-case/empty-document/index.html new file mode 100644 index 0000000..e69de29 diff --git a/test/ast-test-case/empty-document/index.json b/test/ast-test-case/empty-document/index.json new file mode 100644 index 0000000..0aa8e04 --- /dev/null +++ b/test/ast-test-case/empty-document/index.json @@ -0,0 +1,19 @@ +{ + "type": "Document", + "children": [], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 0 + } + }, + "range": [ + 0, + 0 + ], + "raw": "" +} \ No newline at end of file diff --git a/test/ast-test-case/empty-document/result.html b/test/ast-test-case/empty-document/result.html new file mode 100644 index 0000000..1707182 --- /dev/null +++ b/test/ast-test-case/empty-document/result.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/test/ast-test-case/empty-fragment/config.json b/test/ast-test-case/empty-fragment/config.json new file mode 100644 index 0000000..a875830 --- /dev/null +++ b/test/ast-test-case/empty-fragment/config.json @@ -0,0 +1,3 @@ +{ + "fragment": true +} diff --git a/test/ast-test-case/empty-fragment/index.html b/test/ast-test-case/empty-fragment/index.html new file mode 100644 index 0000000..e69de29 diff --git a/test/ast-test-case/empty-fragment/index.json b/test/ast-test-case/empty-fragment/index.json new file mode 100644 index 0000000..0aa8e04 --- /dev/null +++ b/test/ast-test-case/empty-fragment/index.json @@ -0,0 +1,19 @@ +{ + "type": "Document", + "children": [], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 0 + } + }, + "range": [ + 0, + 0 + ], + "raw": "" +} \ No newline at end of file diff --git a/test/ast-test-case/entities-in-literals/config.json b/test/ast-test-case/entities-in-literals/config.json new file mode 100644 index 0000000..a875830 --- /dev/null +++ b/test/ast-test-case/entities-in-literals/config.json @@ -0,0 +1,3 @@ +{ + "fragment": true +} diff --git a/test/ast-test-case/entities-in-literals/index.html b/test/ast-test-case/entities-in-literals/index.html new file mode 100644 index 0000000..7bc0611 --- /dev/null +++ b/test/ast-test-case/entities-in-literals/index.html @@ -0,0 +1,17 @@ + + + + + diff --git a/test/ast-test-case/entities-in-literals/index.json b/test/ast-test-case/entities-in-literals/index.json new file mode 100644 index 0000000..4f8e0df --- /dev/null +++ b/test/ast-test-case/entities-in-literals/index.json @@ -0,0 +1,200 @@ +{ + "type": "Document", + "children": [ + { + "type": "Html", + "tagName": "script", + "properties": {}, + "children": [ + { + "type": "CodeBlock", + "value": "\nif (12 > 13) {\n console.log('foo');\n}\n", + "loc": { + "start": { + "line": 1, + "column": 8 + }, + "end": { + "line": 5, + "column": 0 + } + }, + "range": [ + 8, + 50 + ], + "raw": "\nif (12 > 13) {\n console.log('foo');\n}\n" + } + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 5, + "column": 9 + } + }, + "range": [ + 0, + 59 + ], + "raw": "" + }, + { + "type": "Str", + "value": "\n\n", + "loc": { + "start": { + "line": 5, + "column": 9 + }, + "end": { + "line": 7, + "column": 0 + } + }, + "range": [ + 59, + 61 + ], + "raw": "\n\n" + }, + { + "type": "Html", + "tagName": "script", + "properties": {}, + "children": [ + { + "type": "CodeBlock", + "value": "\n for (var index = -1, length = 2; index < length; index++) {\n console.log(index);\n }\n", + "loc": { + "start": { + "line": 7, + "column": 8 + }, + "end": { + "line": 11, + "column": 0 + } + }, + "range": [ + 69, + 160 + ], + "raw": "\n for (var index = -1, length = 2; index < length; index++) {\n console.log(index);\n }\n" + } + ], + "loc": { + "start": { + "line": 7, + "column": 0 + }, + "end": { + "line": 11, + "column": 9 + } + }, + "range": [ + 61, + 169 + ], + "raw": "" + }, + { + "type": "Str", + "value": "\n\n", + "loc": { + "start": { + "line": 11, + "column": 9 + }, + "end": { + "line": 13, + "column": 0 + } + }, + "range": [ + 169, + 171 + ], + "raw": "\n\n" + }, + { + "type": "Html", + "tagName": "style", + "properties": {}, + "children": [ + { + "type": "Str", + "value": "\nhtml > body {\n color: red;\n}\n", + "loc": { + "start": { + "line": 13, + "column": 7 + }, + "end": { + "line": 17, + "column": 0 + } + }, + "range": [ + 178, + 209 + ], + "raw": "\nhtml > body {\n color: red;\n}\n" + } + ], + "loc": { + "start": { + "line": 13, + "column": 0 + }, + "end": { + "line": 17, + "column": 8 + } + }, + "range": [ + 171, + 217 + ], + "raw": "" + }, + { + "type": "Str", + "value": "\n", + "loc": { + "start": { + "line": 17, + "column": 8 + }, + "end": { + "line": 18, + "column": 0 + } + }, + "range": [ + 217, + 218 + ], + "raw": "\n" + } + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 18, + "column": 0 + } + }, + "range": [ + 0, + 218 + ], + "raw": "\n\n\n\n\n" +} \ No newline at end of file diff --git a/test/ast-test-case/entities/config.json b/test/ast-test-case/entities/config.json new file mode 100644 index 0000000..a875830 --- /dev/null +++ b/test/ast-test-case/entities/config.json @@ -0,0 +1,3 @@ +{ + "fragment": true +} diff --git a/test/ast-test-case/entities/index.html b/test/ast-test-case/entities/index.html new file mode 100644 index 0000000..9ba59a9 --- /dev/null +++ b/test/ast-test-case/entities/index.html @@ -0,0 +1,2 @@ +© & baz. AT&T. +alpha < bravo ' charlie > delta. diff --git a/test/ast-test-case/entities/index.json b/test/ast-test-case/entities/index.json new file mode 100644 index 0000000..c3f33cd --- /dev/null +++ b/test/ast-test-case/entities/index.json @@ -0,0 +1,39 @@ +{ + "type": "Document", + "children": [ + { + "type": "Str", + "value": "© & baz. AT&T.\nalpha < bravo ' charlie > delta.\n", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 0 + } + }, + "range": [ + 0, + 67 + ], + "raw": "© & baz. AT&T.\nalpha < bravo ' charlie > delta.\n" + } + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 3, + "column": 0 + } + }, + "range": [ + 0, + 67 + ], + "raw": "© & baz. AT&T.\nalpha < bravo ' charlie > delta.\n" +} \ No newline at end of file diff --git a/test/ast-test-case/entities/result.html b/test/ast-test-case/entities/result.html new file mode 100644 index 0000000..3fec9c2 --- /dev/null +++ b/test/ast-test-case/entities/result.html @@ -0,0 +1,2 @@ +© & baz. AT&T. +alpha < bravo ' charlie > delta. diff --git a/test/ast-test-case/processing-instruction/config.json b/test/ast-test-case/processing-instruction/config.json new file mode 100644 index 0000000..a875830 --- /dev/null +++ b/test/ast-test-case/processing-instruction/config.json @@ -0,0 +1,3 @@ +{ + "fragment": true +} diff --git a/test/ast-test-case/processing-instruction/index.html b/test/ast-test-case/processing-instruction/index.html new file mode 100644 index 0000000..12bbf74 --- /dev/null +++ b/test/ast-test-case/processing-instruction/index.html @@ -0,0 +1 @@ + diff --git a/test/ast-test-case/processing-instruction/index.json b/test/ast-test-case/processing-instruction/index.json new file mode 100644 index 0000000..3b8f460 --- /dev/null +++ b/test/ast-test-case/processing-instruction/index.json @@ -0,0 +1,59 @@ +{ + "type": "Document", + "children": [ + { + "type": "UNKNOWN", + "name": "?xml", + "value": "?xml version=\"1.0\" encoding=\"UTF-8\"?", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 38 + } + }, + "range": [ + 0, + 38 + ], + "raw": "" + }, + { + "type": "Str", + "value": "\n", + "loc": { + "start": { + "line": 1, + "column": 38 + }, + "end": { + "line": 2, + "column": 0 + } + }, + "range": [ + 38, + 39 + ], + "raw": "\n" + } + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 2, + "column": 0 + } + }, + "range": [ + 0, + 39 + ], + "raw": "\n" +} \ No newline at end of file diff --git a/test/ast-test-case/processing-instruction/result.html b/test/ast-test-case/processing-instruction/result.html new file mode 100644 index 0000000..9324684 --- /dev/null +++ b/test/ast-test-case/processing-instruction/result.html @@ -0,0 +1 @@ + diff --git a/test/ast-test-case/quirksmode-off/config.json b/test/ast-test-case/quirksmode-off/config.json new file mode 100644 index 0000000..0967ef4 --- /dev/null +++ b/test/ast-test-case/quirksmode-off/config.json @@ -0,0 +1 @@ +{} diff --git a/test/ast-test-case/quirksmode-off/index.html b/test/ast-test-case/quirksmode-off/index.html new file mode 100644 index 0000000..e6c19a0 --- /dev/null +++ b/test/ast-test-case/quirksmode-off/index.html @@ -0,0 +1,5 @@ + + +Not-Quirksmode +

                  Outside of quirksmode, the following table is outside this paragraph: +!
                  diff --git a/test/ast-test-case/quirksmode-off/index.json b/test/ast-test-case/quirksmode-off/index.json new file mode 100644 index 0000000..054a230 --- /dev/null +++ b/test/ast-test-case/quirksmode-off/index.json @@ -0,0 +1,261 @@ +{ + "type": "Document", + "children": [ + { + "type": "UNKNOWN", + "name": "!doctype", + "value": "!doctype html", + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 15 + } + }, + "range": [ + 0, + 15 + ], + "raw": "" + }, + { + "type": "Str", + "value": "\n", + "loc": { + "start": { + "line": 1, + "column": 15 + }, + "end": { + "line": 2, + "column": 0 + } + }, + "range": [ + 15, + 16 + ], + "raw": "\n" + }, + { + "type": "Html", + "tagName": "html", + "properties": {}, + "children": [ + { + "type": "Str", + "value": "\n", + "loc": { + "start": { + "line": 2, + "column": 6 + }, + "end": { + "line": 3, + "column": 0 + } + }, + "range": [ + 22, + 23 + ], + "raw": "\n" + }, + { + "type": "Html", + "tagName": "title", + "properties": {}, + "children": [ + { + "type": "Str", + "value": "Not-Quirksmode", + "loc": { + "start": { + "line": 3, + "column": 7 + }, + "end": { + "line": 3, + "column": 21 + } + }, + "range": [ + 30, + 44 + ], + "raw": "Not-Quirksmode" + } + ], + "loc": { + "start": { + "line": 3, + "column": 0 + }, + "end": { + "line": 3, + "column": 29 + } + }, + "range": [ + 23, + 52 + ], + "raw": "Not-Quirksmode" + }, + { + "type": "Str", + "value": "\n", + "loc": { + "start": { + "line": 3, + "column": 29 + }, + "end": { + "line": 4, + "column": 0 + } + }, + "range": [ + 52, + 53 + ], + "raw": "\n" + }, + { + "type": "Paragraph", + "tagName": "p", + "properties": {}, + "children": [ + { + "type": "Str", + "value": "Outside of quirksmode, the following table is outside this paragraph:\n", + "loc": { + "start": { + "line": 4, + "column": 3 + }, + "end": { + "line": 5, + "column": 0 + } + }, + "range": [ + 56, + 126 + ], + "raw": "Outside of quirksmode, the following table is outside this paragraph:\n" + }, + { + "type": "Html", + "tagName": "table", + "properties": {}, + "children": [ + { + "type": "Str", + "value": "!", + "loc": { + "start": { + "line": 5, + "column": 7 + }, + "end": { + "line": 5, + "column": 8 + } + }, + "range": [ + 133, + 134 + ], + "raw": "!" + } + ], + "loc": { + "start": { + "line": 5, + "column": 0 + }, + "end": { + "line": 5, + "column": 16 + } + }, + "range": [ + 126, + 142 + ], + "raw": "!
                  " + }, + { + "type": "Str", + "value": "\n", + "loc": { + "start": { + "line": 5, + "column": 16 + }, + "end": { + "line": 6, + "column": 0 + } + }, + "range": [ + 142, + 143 + ], + "raw": "\n" + } + ], + "loc": { + "start": { + "line": 4, + "column": 0 + }, + "end": { + "line": 6, + "column": 1 + } + }, + "range": [ + 53, + 144 + ], + "raw": "

                  Outside of quirksmode, the following table is outside this paragraph:\n!
                  \n" + } + ], + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 6, + "column": 1 + } + }, + "range": [ + 16, + 144 + ], + "raw": "\nNot-Quirksmode\n

                  Outside of quirksmode, the following table is outside this paragraph:\n!
                  \n" + } + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 6, + "column": 0 + } + }, + "range": [ + 0, + 143 + ], + "raw": "\n\nNot-Quirksmode\n

                  Outside of quirksmode, the following table is outside this paragraph:\n!
                  \n" +} \ No newline at end of file diff --git a/test/ast-test-case/quirksmode-off/result.html b/test/ast-test-case/quirksmode-off/result.html new file mode 100644 index 0000000..1538037 --- /dev/null +++ b/test/ast-test-case/quirksmode-off/result.html @@ -0,0 +1,4 @@ +Not-Quirksmode +

                  Outside of quirksmode, the following table is outside this paragraph: +

                  !
                  + \ No newline at end of file diff --git a/test/ast-test-case/quirksmode-on/config.json b/test/ast-test-case/quirksmode-on/config.json new file mode 100644 index 0000000..0967ef4 --- /dev/null +++ b/test/ast-test-case/quirksmode-on/config.json @@ -0,0 +1 @@ +{} diff --git a/test/ast-test-case/quirksmode-on/index.html b/test/ast-test-case/quirksmode-on/index.html new file mode 100644 index 0000000..5e00f77 --- /dev/null +++ b/test/ast-test-case/quirksmode-on/index.html @@ -0,0 +1,4 @@ + +Quirksmode +

                  In quirksmode, the following table is in this paragraph: +!
                  diff --git a/test/ast-test-case/quirksmode-on/index.json b/test/ast-test-case/quirksmode-on/index.json new file mode 100644 index 0000000..51b77d8 --- /dev/null +++ b/test/ast-test-case/quirksmode-on/index.json @@ -0,0 +1,222 @@ +{ + "type": "Document", + "children": [ + { + "type": "Html", + "tagName": "html", + "properties": {}, + "children": [ + { + "type": "Str", + "value": "\n", + "loc": { + "start": { + "line": 1, + "column": 6 + }, + "end": { + "line": 2, + "column": 0 + } + }, + "range": [ + 6, + 7 + ], + "raw": "\n" + }, + { + "type": "Html", + "tagName": "title", + "properties": {}, + "children": [ + { + "type": "Str", + "value": "Quirksmode", + "loc": { + "start": { + "line": 2, + "column": 7 + }, + "end": { + "line": 2, + "column": 17 + } + }, + "range": [ + 14, + 24 + ], + "raw": "Quirksmode" + } + ], + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 2, + "column": 25 + } + }, + "range": [ + 7, + 32 + ], + "raw": "Quirksmode" + }, + { + "type": "Str", + "value": "\n", + "loc": { + "start": { + "line": 2, + "column": 25 + }, + "end": { + "line": 3, + "column": 0 + } + }, + "range": [ + 32, + 33 + ], + "raw": "\n" + }, + { + "type": "Paragraph", + "tagName": "p", + "properties": {}, + "children": [ + { + "type": "Str", + "value": "In quirksmode, the following table is in this paragraph:\n", + "loc": { + "start": { + "line": 3, + "column": 3 + }, + "end": { + "line": 4, + "column": 0 + } + }, + "range": [ + 36, + 93 + ], + "raw": "In quirksmode, the following table is in this paragraph:\n" + }, + { + "type": "Html", + "tagName": "table", + "properties": {}, + "children": [ + { + "type": "Str", + "value": "!", + "loc": { + "start": { + "line": 4, + "column": 7 + }, + "end": { + "line": 4, + "column": 8 + } + }, + "range": [ + 100, + 101 + ], + "raw": "!" + } + ], + "loc": { + "start": { + "line": 4, + "column": 0 + }, + "end": { + "line": 4, + "column": 16 + } + }, + "range": [ + 93, + 109 + ], + "raw": "!
                  " + }, + { + "type": "Str", + "value": "\n", + "loc": { + "start": { + "line": 4, + "column": 16 + }, + "end": { + "line": 5, + "column": 0 + } + }, + "range": [ + 109, + 110 + ], + "raw": "\n" + } + ], + "loc": { + "start": { + "line": 3, + "column": 0 + }, + "end": { + "line": 5, + "column": 1 + } + }, + "range": [ + 33, + 111 + ], + "raw": "

                  In quirksmode, the following table is in this paragraph:\n!
                  \n" + } + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 5, + "column": 1 + } + }, + "range": [ + 0, + 111 + ], + "raw": "\nQuirksmode\n

                  In quirksmode, the following table is in this paragraph:\n!
                  \n" + } + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 5, + "column": 0 + } + }, + "range": [ + 0, + 110 + ], + "raw": "\nQuirksmode\n

                  In quirksmode, the following table is in this paragraph:\n!
                  \n" +} \ No newline at end of file diff --git a/test/ast-test-case/quirksmode-on/result.html b/test/ast-test-case/quirksmode-on/result.html new file mode 100644 index 0000000..6815691 --- /dev/null +++ b/test/ast-test-case/quirksmode-on/result.html @@ -0,0 +1,4 @@ +Quirksmode +

                  In quirksmode, the following table is in this paragraph: +!
                  +

                  \ No newline at end of file diff --git a/test/ast-test-case/verbose/config.json b/test/ast-test-case/verbose/config.json new file mode 100644 index 0000000..4f1cb33 --- /dev/null +++ b/test/ast-test-case/verbose/config.json @@ -0,0 +1,4 @@ +{ + "verbose": true, + "reprocess": false +} diff --git a/test/ast-test-case/verbose/index.html b/test/ast-test-case/verbose/index.html new file mode 100644 index 0000000..5f7d4e8 --- /dev/null +++ b/test/ast-test-case/verbose/index.html @@ -0,0 +1,4 @@ + +

                  +

                  +
                  diff --git a/test/ast-test-case/verbose/index.json b/test/ast-test-case/verbose/index.json new file mode 100644 index 0000000..ba756ba --- /dev/null +++ b/test/ast-test-case/verbose/index.json @@ -0,0 +1,184 @@ +{ + "type": "Document", + "children": [ + { + "type": "Image", + "tagName": "img", + "properties": { + "src": "#", + "type": "UNKNOWN" + }, + "children": [], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 1, + "column": 17 + } + }, + "range": [ + 0, + 17 + ], + "raw": "" + }, + { + "type": "Str", + "value": "\n", + "loc": { + "start": { + "line": 1, + "column": 17 + }, + "end": { + "line": 2, + "column": 0 + } + }, + "range": [ + 17, + 18 + ], + "raw": "\n" + }, + { + "type": "Paragraph", + "tagName": "p", + "properties": {}, + "children": [ + { + "type": "Str", + "value": "\n", + "loc": { + "start": { + "line": 2, + "column": 3 + }, + "end": { + "line": 3, + "column": 0 + } + }, + "range": [ + 21, + 22 + ], + "raw": "\n" + }, + { + "type": "Html", + "tagName": "div", + "properties": {}, + "children": [], + "loc": { + "start": { + "line": 3, + "column": 0 + }, + "end": { + "line": 3, + "column": 11 + } + }, + "range": [ + 22, + 33 + ], + "raw": "
                  " + }, + { + "type": "Str", + "value": "\n", + "loc": { + "start": { + "line": 3, + "column": 11 + }, + "end": { + "line": 4, + "column": 0 + } + }, + "range": [ + 33, + 34 + ], + "raw": "\n" + }, + { + "type": "break", + "tagName": "br", + "properties": {}, + "children": [], + "loc": { + "start": { + "line": 4, + "column": 4 + }, + "end": { + "line": 4, + "column": 5 + } + }, + "range": [ + 38, + 39 + ], + "raw": ">" + }, + { + "type": "Str", + "value": "\n", + "loc": { + "start": { + "line": 4, + "column": 4 + }, + "end": { + "line": 5, + "column": 0 + } + }, + "range": [ + 38, + 40 + ], + "raw": ">\n" + } + ], + "loc": { + "start": { + "line": 2, + "column": 0 + }, + "end": { + "line": 5, + "column": 1 + } + }, + "range": [ + 18, + 41 + ], + "raw": "

                  \n

                  \n
                  \n" + } + ], + "loc": { + "start": { + "line": 1, + "column": 0 + }, + "end": { + "line": 5, + "column": 0 + } + }, + "range": [ + 0, + 40 + ], + "raw": "\n

                  \n

                  \n
                  \n" +} \ No newline at end of file diff --git a/test/ast-test-case/verbose/result.html b/test/ast-test-case/verbose/result.html new file mode 100644 index 0000000..6ff497a --- /dev/null +++ b/test/ast-test-case/verbose/result.html @@ -0,0 +1,5 @@ + +

                  +

                  +
                  + \ No newline at end of file diff --git a/test/fixtures/test.htm b/test/fixtures/test.htm new file mode 100644 index 0000000..5e8e459 --- /dev/null +++ b/test/fixtures/test.htm @@ -0,0 +1,14 @@ + + + + + Title + + +
                  +

                  + TODO: This is TODO +

                  +
                  + + \ No newline at end of file diff --git a/test/html-to-ast-test.js b/test/html-to-ast-test.js index 7a7cab6..7af534b 100644 --- a/test/html-to-ast-test.js +++ b/test/html-to-ast-test.js @@ -4,6 +4,7 @@ const assert = require("power-assert"); const fs = require("fs"); const path = require("path"); const test = require("textlint-ast-test").test; +const glob = require("glob"); import {parse} from "../src/html-to-ast"; describe("html-to-ast-test", function () { it("should return AST that passed isTxtAST", function () { @@ -11,4 +12,26 @@ describe("html-to-ast-test", function () { const AST = parse(fixture); test(AST); }); + // test-case is come from https://github.com/wooorm/rehype + // MIT + context("test-case", () => { + const htmls = glob.sync(__dirname + "/ast-test-case/*/index.html"); + const directories = htmls.map(filePath => { + return path.dirname(filePath); + }); + const ignoreTestCase = /element-broken-close/; + directories.forEach(directory => { + if (ignoreTestCase.test(directory)) { + xit(`Skip ${path.basename(directory)}`, () => { + }); + return; + } + it(`should parse to ast ${path.basename(directory)}`, () => { + const content = fs.readFileSync(path.join(directory, "index.html"), "utf-8"); + const expected = JSON.parse(fs.readFileSync(path.join(directory, "index.json"), "utf-8")); + const AST = parse(content); + assert.deepEqual(JSON.parse(JSON.stringify(AST)), expected); + }); + }); + }); }); \ No newline at end of file