",
+ "loc": {
+ "start": {
+ "line": 5,
+ "column": 18
+ },
+ "end": {
+ "line": 5,
+ "column": 19
+ }
+ },
+ "range": [
+ 69,
+ 70
+ ]
+ },
+ "selfClosing": false
}
],
"openStart": {
@@ -172,25 +249,7 @@
19
]
},
- "selfClosing": false,
- "close": {
- "type": "CloseTag",
- "value": "",
- "loc": {
- "start": {
- "line": 17,
- "column": 0
- },
- "end": {
- "line": 17,
- "column": 11
- }
- },
- "range": [
- 260,
- 271
- ]
- }
+ "selfClosing": false
}
],
"loc": {
diff --git a/src/tree-constructor/__tests__/__file_snapshots__/construct-tree-Doctypes-0.json b/src/__tests__/tree-constructor/__file_snapshots__/construct-tree-Doctypes-0.json
similarity index 100%
rename from src/tree-constructor/__tests__/__file_snapshots__/construct-tree-Doctypes-0.json
rename to src/__tests__/tree-constructor/__file_snapshots__/construct-tree-Doctypes-0.json
diff --git a/src/tree-constructor/__tests__/__file_snapshots__/construct-tree-Empty-0.json b/src/__tests__/tree-constructor/__file_snapshots__/construct-tree-Empty-0.json
similarity index 100%
rename from src/tree-constructor/__tests__/__file_snapshots__/construct-tree-Empty-0.json
rename to src/__tests__/tree-constructor/__file_snapshots__/construct-tree-Empty-0.json
diff --git a/src/tree-constructor/__tests__/__file_snapshots__/construct-tree-Nested-tags-0.json b/src/__tests__/tree-constructor/__file_snapshots__/construct-tree-Nested-tags-0.json
similarity index 100%
rename from src/tree-constructor/__tests__/__file_snapshots__/construct-tree-Nested-tags-0.json
rename to src/__tests__/tree-constructor/__file_snapshots__/construct-tree-Nested-tags-0.json
diff --git a/src/tree-constructor/__tests__/__file_snapshots__/construct-tree-Opening-closing-text-0.json b/src/__tests__/tree-constructor/__file_snapshots__/construct-tree-Opening-closing-text-0.json
similarity index 100%
rename from src/tree-constructor/__tests__/__file_snapshots__/construct-tree-Opening-closing-text-0.json
rename to src/__tests__/tree-constructor/__file_snapshots__/construct-tree-Opening-closing-text-0.json
diff --git a/src/tree-constructor/__tests__/__file_snapshots__/construct-tree-Script-elements-0.json b/src/__tests__/tree-constructor/__file_snapshots__/construct-tree-Script-elements-0.json
similarity index 100%
rename from src/tree-constructor/__tests__/__file_snapshots__/construct-tree-Script-elements-0.json
rename to src/__tests__/tree-constructor/__file_snapshots__/construct-tree-Script-elements-0.json
diff --git a/src/tree-constructor/__tests__/__file_snapshots__/construct-tree-Script-elements-attributes-0.json b/src/__tests__/tree-constructor/__file_snapshots__/construct-tree-Script-elements-attributes-0.json
similarity index 100%
rename from src/tree-constructor/__tests__/__file_snapshots__/construct-tree-Script-elements-attributes-0.json
rename to src/__tests__/tree-constructor/__file_snapshots__/construct-tree-Script-elements-attributes-0.json
diff --git a/src/tree-constructor/__tests__/__file_snapshots__/construct-tree-Style-elements-0.json b/src/__tests__/tree-constructor/__file_snapshots__/construct-tree-Style-elements-0.json
similarity index 99%
rename from src/tree-constructor/__tests__/__file_snapshots__/construct-tree-Style-elements-0.json
rename to src/__tests__/tree-constructor/__file_snapshots__/construct-tree-Style-elements-0.json
index 407cd52..46122b2 100644
--- a/src/tree-constructor/__tests__/__file_snapshots__/construct-tree-Style-elements-0.json
+++ b/src/__tests__/tree-constructor/__file_snapshots__/construct-tree-Style-elements-0.json
@@ -36,8 +36,8 @@
"column": 0
},
"end": {
- "column": 8,
- "line": 7
+ "line": 7,
+ "column": 8
}
},
"attributes": [],
diff --git a/src/tree-constructor/__tests__/__file_snapshots__/construct-tree-Style-elements-attributes-0.json b/src/__tests__/tree-constructor/__file_snapshots__/construct-tree-Style-elements-attributes-0.json
similarity index 100%
rename from src/tree-constructor/__tests__/__file_snapshots__/construct-tree-Style-elements-attributes-0.json
rename to src/__tests__/tree-constructor/__file_snapshots__/construct-tree-Style-elements-attributes-0.json
diff --git a/src/tree-constructor/__tests__/__file_snapshots__/construct-tree-Svg-0.json b/src/__tests__/tree-constructor/__file_snapshots__/construct-tree-Svg-0.json
similarity index 96%
rename from src/tree-constructor/__tests__/__file_snapshots__/construct-tree-Svg-0.json
rename to src/__tests__/tree-constructor/__file_snapshots__/construct-tree-Svg-0.json
index 3068804..76773a0 100644
--- a/src/tree-constructor/__tests__/__file_snapshots__/construct-tree-Svg-0.json
+++ b/src/__tests__/tree-constructor/__file_snapshots__/construct-tree-Svg-0.json
@@ -17,8 +17,8 @@
"column": 0
},
"end": {
- "column": 56,
- "line": 1
+ "line": 1,
+ "column": 56
}
},
"attributes": [
@@ -34,8 +34,8 @@
"column": 5
},
"end": {
- "column": 39,
- "line": 1
+ "line": 1,
+ "column": 39
}
},
"key": {
@@ -127,8 +127,8 @@
"column": 40
},
"end": {
- "column": 50,
- "line": 1
+ "line": 1,
+ "column": 50
}
},
"attributes": [],
diff --git a/src/tree-constructor/__tests__/__file_snapshots__/construct-tree-Tag-register-0.json b/src/__tests__/tree-constructor/__file_snapshots__/construct-tree-Tags-register-0.json
similarity index 100%
rename from src/tree-constructor/__tests__/__file_snapshots__/construct-tree-Tag-register-0.json
rename to src/__tests__/tree-constructor/__file_snapshots__/construct-tree-Tags-register-0.json
diff --git a/src/tree-constructor/__tests__/__file_snapshots__/construct-tree-Templates-Attributes-Key-0.json b/src/__tests__/tree-constructor/__file_snapshots__/construct-tree-Templates-attributes-key-0.json
similarity index 67%
rename from src/tree-constructor/__tests__/__file_snapshots__/construct-tree-Templates-Attributes-Key-0.json
rename to src/__tests__/tree-constructor/__file_snapshots__/construct-tree-Templates-attributes-key-0.json
index 0adbbec..1042bf5 100644
--- a/src/tree-constructor/__tests__/__file_snapshots__/construct-tree-Templates-Attributes-Key-0.json
+++ b/src/__tests__/tree-constructor/__file_snapshots__/construct-tree-Templates-attributes-key-0.json
@@ -17,8 +17,8 @@
"column": 0
},
"end": {
- "column": 18,
- "line": 1
+ "line": 1,
+ "column": 18
}
},
"attributes": [
@@ -57,23 +57,59 @@
],
"parts": [
{
- "loc": {
- "end": {
- "column": 11,
- "line": 1
- },
- "start": {
- "column": 5,
- "line": 1
- }
- },
+ "type": "Template",
"range": [
5,
11
],
- "type": "Template",
+ "loc": {
+ "start": {
+ "line": 1,
+ "column": 5
+ },
+ "end": {
+ "line": 1,
+ "column": 11
+ }
+ },
"value": "${key}",
- "partOf": "AttributeKey"
+ "partOf": "AttributeKey",
+ "open": {
+ "type": "OpenTemplate",
+ "range": [
+ 5,
+ 7
+ ],
+ "loc": {
+ "start": {
+ "line": 1,
+ "column": 5
+ },
+ "end": {
+ "line": 1,
+ "column": 7
+ }
+ },
+ "value": "${"
+ },
+ "close": {
+ "type": "CloseTemplate",
+ "range": [
+ 10,
+ 11
+ ],
+ "loc": {
+ "start": {
+ "line": 1,
+ "column": 10
+ },
+ "end": {
+ "line": 1,
+ "column": 11
+ }
+ },
+ "value": "}"
+ }
}
]
}
diff --git a/src/tree-constructor/__tests__/__file_snapshots__/construct-tree-Templates-Attributes-Value-Bare-0.json b/src/__tests__/tree-constructor/__file_snapshots__/construct-tree-Templates-attributes-value-bare-0.json
similarity index 97%
rename from src/tree-constructor/__tests__/__file_snapshots__/construct-tree-Templates-Attributes-Value-Bare-0.json
rename to src/__tests__/tree-constructor/__file_snapshots__/construct-tree-Templates-attributes-value-bare-0.json
index b75c83b..7684fac 100644
--- a/src/tree-constructor/__tests__/__file_snapshots__/construct-tree-Templates-Attributes-Value-Bare-0.json
+++ b/src/__tests__/tree-constructor/__file_snapshots__/construct-tree-Templates-attributes-value-bare-0.json
@@ -77,7 +77,6 @@
"parts": [
{
"type": "Template",
- "partOf": "AttributeValue",
"range": [
8,
13
@@ -92,7 +91,8 @@
"column": 13
}
},
- "value": "${id}"
+ "value": "${id}",
+ "partOf": "AttributeValue"
}
]
}
diff --git a/src/tree-constructor/__tests__/__file_snapshots__/construct-tree-Templates-Attributes-Value-Wrapped-0.json b/src/__tests__/tree-constructor/__file_snapshots__/construct-tree-Templates-attributes-value-wrapped-0.json
similarity index 98%
rename from src/tree-constructor/__tests__/__file_snapshots__/construct-tree-Templates-Attributes-Value-Wrapped-0.json
rename to src/__tests__/tree-constructor/__file_snapshots__/construct-tree-Templates-attributes-value-wrapped-0.json
index 4dd0507..74d5e3c 100644
--- a/src/tree-constructor/__tests__/__file_snapshots__/construct-tree-Templates-Attributes-Value-Wrapped-0.json
+++ b/src/__tests__/tree-constructor/__file_snapshots__/construct-tree-Templates-attributes-value-wrapped-0.json
@@ -95,7 +95,6 @@
"parts": [
{
"type": "Template",
- "partOf": "AttributeValue",
"range": [
9,
14
@@ -110,7 +109,8 @@
"column": 14
}
},
- "value": "${id}"
+ "value": "${id}",
+ "partOf": "AttributeValue"
}
]
},
diff --git a/src/tree-constructor/__tests__/__file_snapshots__/construct-tree-Templates-Attributes-Value-Wrapped-2-0.json b/src/__tests__/tree-constructor/__file_snapshots__/construct-tree-Templates-attributes-value-wrapped-2-0.json
similarity index 94%
rename from src/tree-constructor/__tests__/__file_snapshots__/construct-tree-Templates-Attributes-Value-Wrapped-2-0.json
rename to src/__tests__/tree-constructor/__file_snapshots__/construct-tree-Templates-attributes-value-wrapped-2-0.json
index 738c8d2..d5effd5 100644
--- a/src/tree-constructor/__tests__/__file_snapshots__/construct-tree-Templates-Attributes-Value-Wrapped-2-0.json
+++ b/src/__tests__/tree-constructor/__file_snapshots__/construct-tree-Templates-attributes-value-wrapped-2-0.json
@@ -109,11 +109,10 @@
"column": 16
}
},
- "partOf": "AttributeValue",
- "value": "one "
+ "value": "one ",
+ "partOf": "AttributeValue"
},
{
- "partOf": "AttributeValue",
"type": "Template",
"range": [
16,
@@ -129,7 +128,8 @@
"column": 22
}
},
- "value": "${two}"
+ "value": "${two}",
+ "partOf": "AttributeValue"
},
{
"type": "Part",
@@ -147,11 +147,10 @@
"column": 23
}
},
- "partOf": "AttributeValue",
- "value": " "
+ "value": " ",
+ "partOf": "AttributeValue"
},
{
- "partOf": "AttributeValue",
"type": "Template",
"range": [
23,
@@ -167,7 +166,8 @@
"column": 31
}
},
- "value": "${three}"
+ "value": "${three}",
+ "partOf": "AttributeValue"
}
]
},
diff --git a/src/tree-constructor/__tests__/__file_snapshots__/construct-tree-Templates-Comment-0.json b/src/__tests__/tree-constructor/__file_snapshots__/construct-tree-Templates-comment-0.json
similarity index 97%
rename from src/tree-constructor/__tests__/__file_snapshots__/construct-tree-Templates-Comment-0.json
rename to src/__tests__/tree-constructor/__file_snapshots__/construct-tree-Templates-comment-0.json
index 8c64455..34a9d5f 100644
--- a/src/tree-constructor/__tests__/__file_snapshots__/construct-tree-Templates-Comment-0.json
+++ b/src/__tests__/tree-constructor/__file_snapshots__/construct-tree-Templates-comment-0.json
@@ -59,8 +59,6 @@
"parts": [
{
"type": "Template",
- "partOf": "CommentContent",
- "value": "${comment}",
"range": [
4,
14
@@ -74,7 +72,9 @@
"line": 1,
"column": 14
}
- }
+ },
+ "value": "${comment}",
+ "partOf": "CommentContent"
}
]
},
diff --git a/src/tree-constructor/__tests__/__file_snapshots__/construct-tree-Templates-Content-End-0.json b/src/__tests__/tree-constructor/__file_snapshots__/construct-tree-Templates-content-end-0.json
similarity index 88%
rename from src/tree-constructor/__tests__/__file_snapshots__/construct-tree-Templates-Content-End-0.json
rename to src/__tests__/tree-constructor/__file_snapshots__/construct-tree-Templates-content-end-0.json
index 92366c3..5ed6895 100644
--- a/src/tree-constructor/__tests__/__file_snapshots__/construct-tree-Templates-Content-End-0.json
+++ b/src/__tests__/tree-constructor/__file_snapshots__/construct-tree-Templates-content-end-0.json
@@ -24,21 +24,21 @@
],
"parts": [
{
- "loc": {
- "end": {
- "column": 10,
- "line": 1
- },
- "start": {
- "column": 0,
- "line": 1
- }
- },
+ "type": "Template",
"range": [
0,
10
],
- "type": "Template",
+ "loc": {
+ "start": {
+ "line": 1,
+ "column": 0
+ },
+ "end": {
+ "line": 1,
+ "column": 10
+ }
+ },
"value": "${content}",
"partOf": "Text"
}
diff --git a/src/tree-constructor/__tests__/__file_snapshots__/construct-tree-Templates-Data-0.json b/src/__tests__/tree-constructor/__file_snapshots__/construct-tree-Templates-data-0.json
similarity index 97%
rename from src/tree-constructor/__tests__/__file_snapshots__/construct-tree-Templates-Data-0.json
rename to src/__tests__/tree-constructor/__file_snapshots__/construct-tree-Templates-data-0.json
index a2ec1a0..74fe6a9 100644
--- a/src/tree-constructor/__tests__/__file_snapshots__/construct-tree-Templates-Data-0.json
+++ b/src/__tests__/tree-constructor/__file_snapshots__/construct-tree-Templates-data-0.json
@@ -43,8 +43,6 @@
"parts": [
{
"type": "Template",
- "partOf": "Text",
- "value": "${children}",
"range": [
5,
16
@@ -58,7 +56,9 @@
"line": 1,
"column": 16
}
- }
+ },
+ "value": "${children}",
+ "partOf": "Text"
}
]
}
diff --git a/src/tree-constructor/__tests__/__file_snapshots__/construct-tree-Templates-Script-Content-0.json b/src/__tests__/tree-constructor/__file_snapshots__/construct-tree-Templates-script-content-0.json
similarity index 100%
rename from src/tree-constructor/__tests__/__file_snapshots__/construct-tree-Templates-Script-Content-0.json
rename to src/__tests__/tree-constructor/__file_snapshots__/construct-tree-Templates-script-content-0.json
index 7823ee7..ee5c02f 100644
--- a/src/tree-constructor/__tests__/__file_snapshots__/construct-tree-Templates-Script-Content-0.json
+++ b/src/__tests__/tree-constructor/__file_snapshots__/construct-tree-Templates-script-content-0.json
@@ -78,7 +78,6 @@
"parts": [
{
"type": "Template",
- "value": "${content}",
"range": [
8,
18
@@ -93,6 +92,7 @@
"column": 18
}
},
+ "value": "${content}",
"partOf": "ScriptTagContent"
}
]
diff --git a/src/tree-constructor/__tests__/__file_snapshots__/construct-tree-Templates-Style-Content-0.json b/src/__tests__/tree-constructor/__file_snapshots__/construct-tree-Templates-style-content-0.json
similarity index 100%
rename from src/tree-constructor/__tests__/__file_snapshots__/construct-tree-Templates-Style-Content-0.json
rename to src/__tests__/tree-constructor/__file_snapshots__/construct-tree-Templates-style-content-0.json
index 78a2881..b7aa2fe 100644
--- a/src/tree-constructor/__tests__/__file_snapshots__/construct-tree-Templates-Style-Content-0.json
+++ b/src/__tests__/tree-constructor/__file_snapshots__/construct-tree-Templates-style-content-0.json
@@ -78,7 +78,6 @@
"parts": [
{
"type": "Template",
- "value": "${content}",
"range": [
7,
17
@@ -93,6 +92,7 @@
"column": 17
}
},
+ "value": "${content}",
"partOf": "StyleTagContent"
}
]
diff --git a/src/tree-constructor/__tests__/__file_snapshots__/construct-tree-Void-tags-0.json b/src/__tests__/tree-constructor/__file_snapshots__/construct-tree-Void-tags-0.json
similarity index 100%
rename from src/tree-constructor/__tests__/__file_snapshots__/construct-tree-Void-tags-0.json
rename to src/__tests__/tree-constructor/__file_snapshots__/construct-tree-Void-tags-0.json
diff --git a/src/__tests__/tree-constructor/construct-tree.spec.ts b/src/__tests__/tree-constructor/construct-tree.spec.ts
new file mode 100644
index 0000000..3b9043c
--- /dev/null
+++ b/src/__tests__/tree-constructor/construct-tree.spec.ts
@@ -0,0 +1,77 @@
+import { constructTree } from "../../tree-constructor/construct-tree";
+
+import ATTRIBUTES_APOSTROPHE_INPUT from "../tokenizer/__file_snapshots__/Tokenizer-attributes-apostrophe.html-0.json";
+import ATTRIBUTES_BARE_INPUT from "../tokenizer/__file_snapshots__/Tokenizer-attributes-bare.html-0.json";
+import ATTRIBUTES_BARE_WRONG_QUOTE_INPUT from "../tokenizer/__file_snapshots__/Tokenizer-attributes-bare-wrong-quote.html-0.json";
+import ATTRIBUTES_EMPTY_INPUT from "../tokenizer/__file_snapshots__/Tokenizer-attributes-empty.html-0.json";
+import ATTRIBUTES_MULTILINE_INPUT from "../tokenizer/__file_snapshots__/Tokenizer-attributes-multiline.html-0.json";
+import ATTRIBUTES_QUOTE_INPUT from "../tokenizer/__file_snapshots__/Tokenizer-attributes-quote.html-0.json";
+import COMMENTS_INPUT from "../tokenizer/__file_snapshots__/Tokenizer-comments.html-0.json";
+import CUSTOM_ELEMENTS_INPUT from "../tokenizer/__file_snapshots__/Tokenizer-custom-elements.html-0.json";
+import CUSTOM_TAG_RAW_CONTENT from "../tokenizer/__file_snapshots__/Tokenizer-custom-tag-raw-content.html-0.json";
+import DOCTYPES_INPUT from "../tokenizer/__file_snapshots__/Tokenizer-doctypes.html-0.json";
+import EMPTY_INPUT from "../tokenizer/__file_snapshots__/Tokenizer-empty.html-0.json";
+import NESTED_TAGS_INPUT from "../tokenizer/__file_snapshots__/Tokenizer-nested-tags.html-0.json";
+import OPENING_CLOSING_TEXT_INPUT from "../tokenizer/__file_snapshots__/Tokenizer-opening-closing-text.html-0.json";
+import SCRIPT_ELEMENTS_INPUT from "../tokenizer/__file_snapshots__/Tokenizer-script-elements.html-0.json";
+import SCRIPT_ELEMENTS_ATTRIBUTES_INPUT from "../tokenizer/__file_snapshots__/Tokenizer-script-elements-attributes.html-0.json";
+import STYLE_ELEMENTS_INPUT from "../tokenizer/__file_snapshots__/Tokenizer-style-elements.html-0.json";
+import STYLE_ELEMENTS_ATTRIBUTES_INPUT from "../tokenizer/__file_snapshots__/Tokenizer-style-elements-attributes.html-0.json";
+import SVG_INPUT from "../tokenizer/__file_snapshots__/Tokenizer-svg.html-0.json";
+import TAGS_REGISTER_INPUT from "../tokenizer/__file_snapshots__/Tokenizer-tags-register.html-0.json";
+import TEMPLATE_ATTRIBUTES_KEY from "../tokenizer/__file_snapshots__/Tokenizer-templates-attributes-key.html-0.json";
+import TEMPLATE_ATTRIBUTES_VALUE_BARE from "../tokenizer/__file_snapshots__/Tokenizer-templates-attributes-value-bare.html-0.json";
+import TEMPLATE_ATTRIBUTES_VALUE_WRAPPED from "../tokenizer/__file_snapshots__/Tokenizer-templates-attributes-value-wrapped.html-0.json";
+import TEMPLATE_ATTRIBUTES_VALUE_WRAPPED_2 from "../tokenizer/__file_snapshots__/Tokenizer-templates-attributes-value-wrapped-2.html-0.json";
+import TEMPLATE_COMMENT from "../tokenizer/__file_snapshots__/Tokenizer-templates-comment.html-0.json";
+import TEMPLATE_CONTENT_END from "../tokenizer/__file_snapshots__/Tokenizer-templates-content-end.html-0.json";
+import TEMPLATE_DATA from "../tokenizer/__file_snapshots__/Tokenizer-templates-data.html-0.json";
+import TEMPLATE_SCRIPT_CONTENT from "../tokenizer/__file_snapshots__/Tokenizer-templates-script-content.html-0.json";
+import TEMPLATE_STYLE_CONTENT from "../tokenizer/__file_snapshots__/Tokenizer-templates-style-content.html-0.json";
+import VOID_TAGS_INPUT from "../tokenizer/__file_snapshots__/Tokenizer-void-tags.html-0.json";
+import { clearParent } from "../../utils";
+import { toMatchFile } from "jest-file-snapshot";
+
+expect.extend({ toMatchFile });
+
+describe("construct-tree", () => {
+ test.each([
+ ["Attributes apostrophe", ATTRIBUTES_APOSTROPHE_INPUT],
+ ["Attributes bare", ATTRIBUTES_BARE_INPUT],
+ ["Attributes bare wrong quote", ATTRIBUTES_BARE_WRONG_QUOTE_INPUT],
+ ["Attributes empty", ATTRIBUTES_EMPTY_INPUT],
+ ["Attributes multiline", ATTRIBUTES_MULTILINE_INPUT],
+ ["Attributes quote", ATTRIBUTES_QUOTE_INPUT],
+ ["Comments", COMMENTS_INPUT],
+ ["Custom elements", CUSTOM_ELEMENTS_INPUT],
+ ["Custom tag raw content", CUSTOM_TAG_RAW_CONTENT],
+ ["Doctypes", DOCTYPES_INPUT],
+ ["Empty", EMPTY_INPUT],
+ ["Nested tags", NESTED_TAGS_INPUT],
+ ["Opening closing text", OPENING_CLOSING_TEXT_INPUT],
+ ["Script elements", SCRIPT_ELEMENTS_INPUT],
+ ["Script elements attributes", SCRIPT_ELEMENTS_ATTRIBUTES_INPUT],
+ ["Style elements", STYLE_ELEMENTS_INPUT],
+ ["Style elements attributes", STYLE_ELEMENTS_ATTRIBUTES_INPUT],
+ ["Svg", SVG_INPUT],
+ ["Tags register", TAGS_REGISTER_INPUT],
+ ["Templates attributes key", TEMPLATE_ATTRIBUTES_KEY],
+ ["Templates attributes value bare", TEMPLATE_ATTRIBUTES_VALUE_BARE],
+ ["Templates attributes value wrapped", TEMPLATE_ATTRIBUTES_VALUE_WRAPPED],
+ [
+ "Templates attributes value wrapped 2",
+ TEMPLATE_ATTRIBUTES_VALUE_WRAPPED_2,
+ ],
+ ["Templates comment", TEMPLATE_COMMENT],
+ ["Templates content end", TEMPLATE_CONTENT_END],
+ ["Templates data", TEMPLATE_DATA],
+ ["Templates script content", TEMPLATE_SCRIPT_CONTENT],
+ ["Templates style content", TEMPLATE_STYLE_CONTENT],
+ ["Void tags", VOID_TAGS_INPUT],
+ ])("%s", (_name: string, inputTokens: any) => {
+ const { ast } = constructTree(inputTokens);
+ expect(JSON.stringify(clearParent(ast), null, 2)).toMatchFile(undefined, {
+ fileExtension: ".json",
+ });
+ });
+});
diff --git a/src/tokenizer/__tests__/__output__/attributes-apostrophe.ts b/src/tokenizer/__tests__/__output__/attributes-apostrophe.ts
deleted file mode 100644
index fe5ea7c..0000000
--- a/src/tokenizer/__tests__/__output__/attributes-apostrophe.ts
+++ /dev/null
@@ -1,620 +0,0 @@
-import { TokenTypes } from "../../../constants";
-
-export default [
- {
- type: TokenTypes.OpenTagStart,
- value: "",
- range: [4, 5],
- loc: {
- start: {
- line: 1,
- column: 4,
- },
- end: {
- line: 1,
- column: 5,
- },
- },
- },
- {
- type: TokenTypes.Text,
- value: "\n ",
- range: [5, 8],
- loc: {
- start: {
- line: 1,
- column: 5,
- },
- end: {
- line: 2,
- column: 2,
- },
- },
- parts: [],
- },
- {
- type: TokenTypes.OpenTagStart,
- value: "
",
- range: [44, 54],
- loc: {
- start: {
- line: 2,
- column: 38,
- },
- end: {
- line: 2,
- column: 48,
- },
- },
- parts: [],
- },
- {
- type: TokenTypes.AttributeValueWrapperEnd,
- value: "'",
- range: [54, 55],
- loc: {
- start: {
- line: 2,
- column: 48,
- },
- end: {
- line: 2,
- column: 49,
- },
- },
- },
- {
- type: TokenTypes.OpenTagEnd,
- value: ">",
- range: [55, 56],
- loc: {
- start: {
- line: 2,
- column: 49,
- },
- end: {
- line: 2,
- column: 50,
- },
- },
- },
- {
- type: TokenTypes.Text,
- value: "\n some text\n\n ",
- range: [56, 76],
- loc: {
- start: {
- line: 2,
- column: 50,
- },
- end: {
- line: 5,
- column: 4,
- },
- },
- parts: [],
- },
- {
- type: TokenTypes.OpenTagStart,
- value: "",
- range: [80, 81],
- loc: {
- start: {
- line: 5,
- column: 8,
- },
- end: {
- line: 5,
- column: 9,
- },
- },
- },
- {
- type: TokenTypes.Text,
- value: "\n another text\n\n ",
- range: [81, 108],
- loc: {
- start: {
- line: 5,
- column: 9,
- },
- end: {
- line: 8,
- column: 6,
- },
- },
- parts: [],
- },
- {
- type: TokenTypes.OpenTagStart,
- value: "test",
- range: [145, 157],
- loc: {
- start: {
- line: 9,
- column: 21,
- },
- end: {
- line: 9,
- column: 33,
- },
- },
- parts: [],
- },
- {
- type: TokenTypes.AttributeValueWrapperEnd,
- value: "'",
- range: [157, 158],
- loc: {
- start: {
- line: 9,
- column: 33,
- },
- end: {
- line: 9,
- column: 34,
- },
- },
- },
- {
- type: TokenTypes.AttributeKey,
- value: "with-spaces",
- range: [167, 178],
- loc: {
- start: {
- line: 10,
- column: 8,
- },
- end: {
- line: 10,
- column: 19,
- },
- },
- parts: [],
- },
- {
- type: TokenTypes.AttributeAssignment,
- value: "=",
- range: [181, 182],
- loc: {
- start: {
- line: 10,
- column: 22,
- },
- end: {
- line: 10,
- column: 23,
- },
- },
- },
- {
- type: TokenTypes.AttributeValueWrapperStart,
- value: "'",
- range: [184, 185],
- loc: {
- start: {
- line: 10,
- column: 25,
- },
- end: {
- line: 10,
- column: 26,
- },
- },
- },
- {
- type: TokenTypes.AttributeValue,
- value: "spaces test",
- range: [185, 196],
- loc: {
- start: {
- line: 10,
- column: 26,
- },
- end: {
- column: 37,
- line: 10,
- },
- },
- parts: [],
- },
- {
- type: TokenTypes.AttributeValueWrapperEnd,
- value: "'",
- range: [196, 197],
- loc: {
- start: {
- line: 10,
- column: 37,
- },
- end: {
- line: 10,
- column: 38,
- },
- },
- },
- {
- type: TokenTypes.OpenTagEnd,
- value: ">",
- range: [204, 205],
- loc: {
- start: {
- column: 6,
- line: 11,
- },
- end: {
- line: 11,
- column: 7,
- },
- },
- },
- {
- type: TokenTypes.Text,
- value: "\n custom element\n text\n ",
- range: [205, 248],
- loc: {
- start: {
- column: 7,
- line: 11,
- },
- end: {
- column: 6,
- line: 14,
- },
- },
- parts: [],
- },
- {
- type: TokenTypes.CloseTag,
- value: " ",
- range: [248, 265],
- loc: {
- start: {
- column: 6,
- line: 14,
- },
- end: {
- column: 23,
- line: 14,
- },
- },
- },
- {
- type: TokenTypes.Text,
- value: "\n ",
- range: [265, 270],
- loc: {
- start: {
- line: 14,
- column: 23,
- },
- end: {
- line: 15,
- column: 4,
- },
- },
- parts: [],
- },
- {
- type: TokenTypes.CloseTag,
- value: "
",
- range: [270, 276],
- loc: {
- start: {
- column: 4,
- line: 15,
- },
- end: {
- line: 15,
- column: 10,
- },
- },
- },
- {
- type: TokenTypes.Text,
- value: "\n ",
- range: [276, 279],
- loc: {
- start: {
- line: 15,
- column: 10,
- },
- end: {
- line: 16,
- column: 2,
- },
- },
- parts: [],
- },
- {
- type: TokenTypes.CloseTag,
- value: " ",
- range: [279, 286],
- loc: {
- start: {
- line: 16,
- column: 2,
- },
- end: {
- line: 16,
- column: 9,
- },
- },
- },
- {
- type: TokenTypes.Text,
- value: "\n",
- range: [286, 287],
- loc: {
- start: {
- line: 16,
- column: 9,
- },
- end: {
- line: 17,
- column: 0,
- },
- },
- parts: [],
- },
- {
- type: TokenTypes.CloseTag,
- value: "
",
- range: [287, 293],
- loc: {
- start: {
- line: 17,
- column: 0,
- },
- end: {
- line: 17,
- column: 6,
- },
- },
- },
- {
- type: TokenTypes.Text,
- value: "\n",
- range: [293, 294],
- loc: {
- start: {
- line: 17,
- column: 6,
- },
- end: {
- line: 18,
- column: 0,
- },
- },
- parts: [],
- },
-];
diff --git a/src/tokenizer/__tests__/__output__/attributes-bare-wrong-quote.ts b/src/tokenizer/__tests__/__output__/attributes-bare-wrong-quote.ts
deleted file mode 100644
index a31d235..0000000
--- a/src/tokenizer/__tests__/__output__/attributes-bare-wrong-quote.ts
+++ /dev/null
@@ -1,99 +0,0 @@
-import { TokenTypes } from "../../../constants";
-import { AnyToken } from "../../../types";
-
-const OUTPUT: AnyToken[] = [
- {
- type: TokenTypes.OpenTagStart,
- value: "",
- range: [18, 19],
- loc: {
- start: {
- line: 1,
- column: 18,
- },
- end: {
- line: 1,
- column: 19,
- },
- },
- },
- {
- type: TokenTypes.CloseTag,
- value: " ",
- range: [19, 23],
- loc: {
- start: {
- line: 1,
- column: 19,
- },
- end: {
- line: 1,
- column: 23,
- },
- },
- },
-];
-
-export default OUTPUT;
diff --git a/src/tokenizer/__tests__/__output__/attributes-bare.ts b/src/tokenizer/__tests__/__output__/attributes-bare.ts
deleted file mode 100644
index 17a7261..0000000
--- a/src/tokenizer/__tests__/__output__/attributes-bare.ts
+++ /dev/null
@@ -1,454 +0,0 @@
-import { TokenTypes } from "../../../constants";
-
-export default [
- {
- type: TokenTypes.OpenTagStart,
- value: "",
- range: [37, 38],
- loc: {
- start: {
- line: 1,
- column: 37,
- },
- end: {
- line: 1,
- column: 38,
- },
- },
- },
- {
- type: TokenTypes.CloseTag,
- value: "
",
- range: [38, 44],
- loc: {
- start: {
- line: 1,
- column: 38,
- },
- end: {
- line: 1,
- column: 44,
- },
- },
- },
- {
- type: TokenTypes.Text,
- value: "\n\n",
- range: [44, 46],
- loc: {
- start: {
- line: 1,
- column: 44,
- },
- end: {
- line: 3,
- column: 0,
- },
- },
- parts: [],
- },
- {
- type: TokenTypes.OpenTagStart,
- value: "",
- range: [73, 74],
- loc: {
- start: {
- line: 3,
- column: 27,
- },
- end: {
- line: 3,
- column: 28,
- },
- },
- },
- {
- type: TokenTypes.Text,
- value: "\n some text\n\n ",
- range: [74, 90],
- loc: {
- start: {
- line: 3,
- column: 28,
- },
- end: {
- line: 6,
- column: 2,
- },
- },
- parts: [],
- },
- {
- type: TokenTypes.OpenTagStart,
- value: "",
- range: [137, 138],
- loc: {
- start: {
- line: 8,
- column: 2,
- },
- end: {
- line: 8,
- column: 3,
- },
- },
- },
- {
- type: TokenTypes.Text,
- value: "\n custom element\n text\n ",
- range: [138, 169],
- loc: {
- start: {
- line: 8,
- column: 3,
- },
- end: {
- line: 11,
- column: 2,
- },
- },
- parts: [],
- },
- {
- type: TokenTypes.CloseTag,
- value: " ",
- range: [169, 186],
- loc: {
- start: {
- line: 11,
- column: 2,
- },
- end: {
- line: 11,
- column: 19,
- },
- },
- },
- {
- type: TokenTypes.Text,
- value: "\n",
- range: [186, 187],
- loc: {
- start: {
- line: 11,
- column: 19,
- },
- end: {
- line: 12,
- column: 0,
- },
- },
- parts: [],
- },
- {
- type: TokenTypes.CloseTag,
- value: " ",
- range: [187, 194],
- loc: {
- start: {
- line: 12,
- column: 0,
- },
- end: {
- line: 12,
- column: 7,
- },
- },
- },
- {
- type: TokenTypes.Text,
- value: "\n",
- range: [194, 195],
- loc: {
- start: {
- line: 12,
- column: 7,
- },
- end: {
- line: 13,
- column: 0,
- },
- },
- parts: [],
- },
-];
diff --git a/src/tokenizer/__tests__/__output__/attributes-empty.ts b/src/tokenizer/__tests__/__output__/attributes-empty.ts
deleted file mode 100644
index b764c72..0000000
--- a/src/tokenizer/__tests__/__output__/attributes-empty.ts
+++ /dev/null
@@ -1,160 +0,0 @@
-import { TokenTypes } from "../../../constants";
-import { AnyToken } from "../../../types";
-
-const OUTPUT: AnyToken[] = [
- {
- type: TokenTypes.OpenTagStart,
- value: "",
- range: [6, 7],
- loc: {
- start: {
- line: 1,
- column: 6,
- },
- end: {
- line: 1,
- column: 7,
- },
- },
- },
- {
- type: TokenTypes.Text,
- value: "\n some text\n\n ",
- range: [7, 23],
- loc: {
- start: {
- line: 1,
- column: 7,
- },
- end: {
- line: 4,
- column: 2,
- },
- },
- parts: [],
- },
- {
- type: TokenTypes.OpenTagStart,
- value: "",
- range: [42, 43],
- loc: {
- start: {
- line: 6,
- column: 2,
- },
- end: {
- line: 6,
- column: 3,
- },
- },
- },
- {
- type: TokenTypes.Text,
- value: "\n custom element\n text\n ",
- range: [43, 74],
- loc: {
- start: {
- line: 6,
- column: 3,
- },
- end: {
- line: 9,
- column: 2,
- },
- },
- parts: [],
- },
- {
- type: TokenTypes.CloseTag,
- value: " ",
- range: [74, 91],
- loc: {
- start: {
- line: 9,
- column: 2,
- },
- end: {
- line: 9,
- column: 19,
- },
- },
- },
- {
- type: TokenTypes.Text,
- value: "\n",
- range: [91, 92],
- loc: {
- start: {
- line: 9,
- column: 19,
- },
- end: {
- line: 10,
- column: 0,
- },
- },
- parts: [],
- },
- {
- type: TokenTypes.CloseTag,
- value: " ",
- range: [92, 99],
- loc: {
- start: {
- line: 10,
- column: 0,
- },
- end: {
- line: 10,
- column: 7,
- },
- },
- },
- {
- type: TokenTypes.Text,
- value: "\n",
- range: [99, 100],
- loc: {
- start: {
- line: 10,
- column: 7,
- },
- end: {
- line: 11,
- column: 0,
- },
- },
- parts: [],
- },
-];
-export default OUTPUT;
diff --git a/src/tokenizer/__tests__/__output__/attributes-multiline-crlf.ts b/src/tokenizer/__tests__/__output__/attributes-multiline-crlf.ts
deleted file mode 100644
index 0420c8c..0000000
--- a/src/tokenizer/__tests__/__output__/attributes-multiline-crlf.ts
+++ /dev/null
@@ -1,253 +0,0 @@
-import { TokenTypes } from "../../../constants";
-import { AnyToken } from "../../../types";
-
-const OUTPUT: AnyToken[] = [
- {
- type: TokenTypes.OpenTagStart,
- range: [0, 4],
- loc: {
- start: {
- column: 0,
- line: 1,
- },
- end: {
- column: 4,
- line: 1,
- },
- },
- value: "",
- range: [41, 42],
- loc: {
- start: {
- line: 5,
- column: 0,
- },
- end: {
- line: 5,
- column: 1,
- },
- },
- },
- {
- type: TokenTypes.Text,
- value: "\r\n",
- range: [42, 44],
- loc: {
- start: {
- line: 5,
- column: 1,
- },
- end: {
- line: 6,
- column: 0,
- },
- },
- parts: [],
- },
- {
- type: TokenTypes.CloseTag,
- value: "
",
- range: [44, 50],
- loc: {
- start: {
- line: 6,
- column: 0,
- },
- end: {
- line: 6,
- column: 6,
- },
- },
- },
- {
- type: TokenTypes.Text,
- value: "\r\n",
- range: [50, 52],
- loc: {
- start: {
- line: 6,
- column: 6,
- },
- end: {
- line: 7,
- column: 0,
- },
- },
- parts: [],
- },
-];
-export default OUTPUT;
diff --git a/src/tokenizer/__tests__/__output__/attributes-quote.ts b/src/tokenizer/__tests__/__output__/attributes-quote.ts
deleted file mode 100644
index b00812e..0000000
--- a/src/tokenizer/__tests__/__output__/attributes-quote.ts
+++ /dev/null
@@ -1,623 +0,0 @@
-import { TokenTypes } from "../../../constants";
-import { AnyToken } from "../../../types";
-
-const OUTPUT: AnyToken[] = [
- {
- type: TokenTypes.OpenTagStart,
- value: "",
- range: [4, 5],
- loc: {
- start: {
- line: 1,
- column: 4,
- },
- end: {
- line: 1,
- column: 5,
- },
- },
- },
- {
- type: TokenTypes.Text,
- value: "\n ",
- range: [5, 8],
- loc: {
- start: {
- line: 1,
- column: 5,
- },
- end: {
- line: 2,
- column: 2,
- },
- },
- parts: [],
- },
- {
- type: TokenTypes.OpenTagStart,
- value: "
",
- range: [44, 54],
- loc: {
- start: {
- line: 2,
- column: 38,
- },
- end: {
- line: 2,
- column: 48,
- },
- },
- parts: [],
- },
- {
- type: TokenTypes.AttributeValueWrapperEnd,
- value: '"',
- range: [54, 55],
- loc: {
- start: {
- line: 2,
- column: 48,
- },
- end: {
- line: 2,
- column: 49,
- },
- },
- },
- {
- type: TokenTypes.OpenTagEnd,
- value: ">",
- range: [55, 56],
- loc: {
- start: {
- line: 2,
- column: 49,
- },
- end: {
- line: 2,
- column: 50,
- },
- },
- },
- {
- type: TokenTypes.Text,
- value: "\n some text\n\n ",
- range: [56, 76],
- loc: {
- start: {
- line: 2,
- column: 50,
- },
- end: {
- line: 5,
- column: 4,
- },
- },
- parts: [],
- },
- {
- type: TokenTypes.OpenTagStart,
- value: "",
- range: [80, 81],
- loc: {
- start: {
- line: 5,
- column: 8,
- },
- end: {
- line: 5,
- column: 9,
- },
- },
- },
- {
- type: TokenTypes.Text,
- value: "\n another text\n\n ",
- range: [81, 108],
- loc: {
- start: {
- line: 5,
- column: 9,
- },
- end: {
- line: 8,
- column: 6,
- },
- },
- parts: [],
- },
- {
- type: TokenTypes.OpenTagStart,
- value: "test",
- range: [145, 157],
- loc: {
- start: {
- line: 9,
- column: 21,
- },
- end: {
- line: 9,
- column: 33,
- },
- },
- parts: [],
- },
- {
- type: TokenTypes.AttributeValueWrapperEnd,
- value: '"',
- range: [157, 158],
- loc: {
- start: {
- line: 9,
- column: 33,
- },
- end: {
- line: 9,
- column: 34,
- },
- },
- },
- {
- type: TokenTypes.AttributeKey,
- value: "with-spaces",
- range: [167, 178],
- loc: {
- start: {
- line: 10,
- column: 8,
- },
- end: {
- line: 10,
- column: 19,
- },
- },
- parts: [],
- },
- {
- type: TokenTypes.AttributeAssignment,
- value: "=",
- range: [181, 182],
- loc: {
- start: {
- line: 10,
- column: 22,
- },
- end: {
- line: 10,
- column: 23,
- },
- },
- },
- {
- type: TokenTypes.AttributeValueWrapperStart,
- value: '"',
- range: [184, 185],
- loc: {
- start: {
- line: 10,
- column: 25,
- },
- end: {
- line: 10,
- column: 26,
- },
- },
- },
- {
- type: TokenTypes.AttributeValue,
- value: "spaces test",
- range: [185, 196],
- loc: {
- start: {
- line: 10,
- column: 26,
- },
- end: {
- line: 10,
- column: 37,
- },
- },
- parts: [],
- },
- {
- type: TokenTypes.AttributeValueWrapperEnd,
- value: '"',
- range: [196, 197],
- loc: {
- start: {
- line: 10,
- column: 37,
- },
- end: {
- line: 10,
- column: 38,
- },
- },
- },
- {
- type: TokenTypes.OpenTagEnd,
- value: ">",
- range: [204, 205],
- loc: {
- start: {
- line: 11,
- column: 6,
- },
- end: {
- line: 11,
- column: 7,
- },
- },
- },
- {
- type: TokenTypes.Text,
- value: "\n custom element\n text\n ",
- range: [205, 248],
- loc: {
- start: {
- line: 11,
- column: 7,
- },
- end: {
- line: 14,
- column: 6,
- },
- },
- parts: [],
- },
- {
- type: TokenTypes.CloseTag,
- value: " ",
- range: [248, 265],
- loc: {
- start: {
- line: 14,
- column: 6,
- },
- end: {
- line: 14,
- column: 23,
- },
- },
- },
- {
- type: TokenTypes.Text,
- value: "\n ",
- range: [265, 270],
- loc: {
- start: {
- line: 14,
- column: 23,
- },
- end: {
- line: 15,
- column: 4,
- },
- },
- parts: [],
- },
- {
- type: TokenTypes.CloseTag,
- value: "
",
- range: [270, 276],
- loc: {
- start: {
- line: 15,
- column: 4,
- },
- end: {
- line: 15,
- column: 10,
- },
- },
- },
- {
- type: TokenTypes.Text,
- value: "\n ",
- range: [276, 279],
- loc: {
- start: {
- line: 15,
- column: 10,
- },
- end: {
- line: 16,
- column: 2,
- },
- },
- parts: [],
- },
- {
- type: TokenTypes.CloseTag,
- value: " ",
- range: [279, 286],
- loc: {
- start: {
- line: 16,
- column: 2,
- },
- end: {
- line: 16,
- column: 9,
- },
- },
- },
- {
- type: TokenTypes.Text,
- value: "\n",
- range: [286, 287],
- loc: {
- start: {
- line: 16,
- column: 9,
- },
- end: {
- line: 17,
- column: 0,
- },
- },
- parts: [],
- },
- {
- type: TokenTypes.CloseTag,
- value: "
",
- range: [287, 293],
- loc: {
- start: {
- line: 17,
- column: 0,
- },
- end: {
- line: 17,
- column: 6,
- },
- },
- },
- {
- type: TokenTypes.Text,
- value: "\n",
- range: [293, 294],
- loc: {
- start: {
- line: 17,
- column: 6,
- },
- end: {
- line: 18,
- column: 0,
- },
- },
- parts: [],
- },
-];
-
-export default OUTPUT;
diff --git a/src/tokenizer/__tests__/__output__/comments.ts b/src/tokenizer/__tests__/__output__/comments.ts
deleted file mode 100644
index ddb1131..0000000
--- a/src/tokenizer/__tests__/__output__/comments.ts
+++ /dev/null
@@ -1,471 +0,0 @@
-import { TokenTypes } from "../../../constants";
-import { AnyToken } from "../../../types";
-
-const OUTPUT: AnyToken[] = [
- {
- type: TokenTypes.CommentOpen,
- value: "",
- range: [18, 21],
- loc: {
- start: {
- column: 18,
- line: 1,
- },
- end: {
- line: 1,
- column: 21,
- },
- },
- },
- {
- type: TokenTypes.Text,
- value: "\n\n",
- range: [21, 23],
- loc: {
- start: {
- line: 1,
- column: 21,
- },
- end: {
- line: 3,
- column: 0,
- },
- },
- parts: [],
- },
- {
- type: TokenTypes.OpenTagStart,
- value: "",
- range: [27, 28],
- loc: {
- start: {
- line: 3,
- column: 4,
- },
- end: {
- line: 3,
- column: 5,
- },
- },
- },
- {
- type: TokenTypes.Text,
- value: "\n ",
- range: [28, 31],
- loc: {
- start: {
- line: 3,
- column: 5,
- },
- end: {
- line: 4,
- column: 2,
- },
- },
- parts: [],
- },
- {
- type: TokenTypes.OpenTagStart,
- value: "",
- range: [36, 37],
- loc: {
- start: {
- line: 4,
- column: 7,
- },
- end: {
- line: 4,
- column: 8,
- },
- },
- },
- {
- type: TokenTypes.Text,
- value: "\n ",
- range: [37, 42],
- loc: {
- start: {
- line: 4,
- column: 8,
- },
- end: {
- line: 5,
- column: 4,
- },
- },
- parts: [],
- },
- {
- type: TokenTypes.CommentOpen,
- value: "",
- range: [57, 60],
- loc: {
- start: {
- line: 5,
- column: 19,
- },
- end: {
- line: 5,
- column: 22,
- },
- },
- },
- {
- type: TokenTypes.Text,
- value: "\n ",
- range: [60, 63],
- loc: {
- start: {
- line: 5,
- column: 22,
- },
- end: {
- line: 6,
- column: 2,
- },
- },
- parts: [],
- },
- {
- type: TokenTypes.CloseTag,
- value: " ",
- range: [63, 70],
- loc: {
- start: {
- line: 6,
- column: 2,
- },
- end: {
- line: 6,
- column: 9,
- },
- },
- },
- {
- type: TokenTypes.Text,
- value: "\n\n ",
- range: [70, 74],
- loc: {
- start: {
- line: 6,
- column: 9,
- },
- end: {
- line: 8,
- column: 2,
- },
- },
- parts: [],
- },
- {
- type: TokenTypes.CommentOpen,
- value: "",
- range: [98, 101],
- loc: {
- start: {
- line: 13,
- column: 2,
- },
- end: {
- line: 13,
- column: 5,
- },
- },
- },
- {
- type: TokenTypes.Text,
- value: "\n",
- range: [101, 102],
- loc: {
- start: {
- line: 13,
- column: 5,
- },
- end: {
- line: 14,
- column: 0,
- },
- },
- parts: [],
- },
- {
- type: TokenTypes.CloseTag,
- value: "
",
- range: [102, 108],
- loc: {
- start: {
- line: 14,
- column: 0,
- },
- end: {
- line: 14,
- column: 6,
- },
- },
- },
- {
- type: TokenTypes.Text,
- value: "\n\n",
- range: [108, 110],
- loc: {
- start: {
- line: 14,
- column: 6,
- },
- end: {
- line: 16,
- column: 0,
- },
- },
- parts: [],
- },
- {
- type: TokenTypes.CommentOpen,
- value: "",
- range: [132, 135],
- loc: {
- start: {
- line: 18,
- column: 8,
- },
- end: {
- line: 18,
- column: 11,
- },
- },
- },
- {
- type: TokenTypes.Text,
- value: "\n\n",
- range: [135, 137],
- loc: {
- start: {
- line: 18,
- column: 11,
- },
- end: {
- line: 20,
- column: 0,
- },
- },
- parts: [],
- },
- {
- type: TokenTypes.CommentOpen,
- value: "",
- range: [171, 174],
- loc: {
- start: {
- line: 20,
- column: 34,
- },
- end: {
- line: 20,
- column: 37,
- },
- },
- },
- {
- type: TokenTypes.Text,
- value: "\n",
- range: [174, 175],
- loc: {
- start: {
- line: 20,
- column: 37,
- },
- end: {
- line: 21,
- column: 0,
- },
- },
- parts: [],
- },
-];
-
-export default OUTPUT;
diff --git a/src/tokenizer/__tests__/__output__/custom-elements.ts b/src/tokenizer/__tests__/__output__/custom-elements.ts
deleted file mode 100644
index 30adf5a..0000000
--- a/src/tokenizer/__tests__/__output__/custom-elements.ts
+++ /dev/null
@@ -1,161 +0,0 @@
-import { TokenTypes } from "../../../constants";
-import { AnyToken } from "../../../types";
-
-const OUTPUT: AnyToken[] = [
- {
- type: TokenTypes.OpenTagStart,
- value: "",
- range: [11, 12],
- loc: {
- start: {
- line: 1,
- column: 11,
- },
- end: {
- line: 1,
- column: 12,
- },
- },
- },
- {
- type: TokenTypes.Text,
- value: "\n some text\n\n ",
- range: [12, 28],
- loc: {
- start: {
- column: 12,
- line: 1,
- },
- end: {
- line: 4,
- column: 2,
- },
- },
- parts: [],
- },
- {
- type: TokenTypes.OpenTagStart,
- value: "",
- range: [39, 40],
- loc: {
- start: {
- line: 4,
- column: 13,
- },
- end: {
- line: 4,
- column: 14,
- },
- },
- },
- {
- type: TokenTypes.Text,
- value: "\n another text\n ",
- range: [40, 60],
- loc: {
- start: {
- column: 14,
- line: 4,
- },
- end: {
- line: 6,
- column: 2,
- },
- },
- parts: [],
- },
- {
- type: TokenTypes.CloseTag,
- value: " ",
- range: [60, 73],
- loc: {
- start: {
- line: 6,
- column: 2,
- },
- end: {
- line: 6,
- column: 15,
- },
- },
- },
- {
- type: TokenTypes.Text,
- value: "\n",
- range: [73, 74],
- loc: {
- start: {
- line: 6,
- column: 15,
- },
- end: {
- line: 7,
- column: 0,
- },
- },
- parts: [],
- },
- {
- type: TokenTypes.CloseTag,
- value: " ",
- range: [74, 87],
- loc: {
- start: {
- column: 0,
- line: 7,
- },
- end: {
- line: 7,
- column: 13,
- },
- },
- },
- {
- type: TokenTypes.Text,
- value: "\n",
- range: [87, 88],
- loc: {
- start: {
- line: 7,
- column: 13,
- },
- end: {
- line: 8,
- column: 0,
- },
- },
- parts: [],
- },
-];
-
-export default OUTPUT;
diff --git a/src/tokenizer/__tests__/__output__/custom-tag-raw-content.ts b/src/tokenizer/__tests__/__output__/custom-tag-raw-content.ts
deleted file mode 100644
index 3bd1882..0000000
--- a/src/tokenizer/__tests__/__output__/custom-tag-raw-content.ts
+++ /dev/null
@@ -1,161 +0,0 @@
-import { TokenTypes } from "../../../constants";
-import { AnyToken } from "../../../types";
-
-const OUTPUT: AnyToken[] = [
- {
- type: TokenTypes.OpenTagStart,
- value: "",
- range: [18, 19],
- loc: {
- start: {
- column: 18,
- line: 1,
- },
- end: {
- line: 1,
- column: 19,
- },
- },
- },
- {
- type: TokenTypes.RawContent,
- value: `
-# Hello, world!
-
-\`\`\`cpp{4-6,9}
-#include
-
-class Example {
- Example() {
- std::cout << "Hello, world!" << std::endl;
- }
-
- Example(std::string name) {
- std::cout << "Hello, " << name << std::endl;
- }
-};
-\`\`\`
-`,
- range: [19, 260],
- loc: {
- start: {
- column: 19,
- line: 1,
- },
- end: {
- line: 17,
- column: 0,
- },
- },
- parts: [],
- },
- {
- type: TokenTypes.CloseTag,
- value: " ",
- range: [260, 271],
- loc: {
- start: {
- column: 0,
- line: 17,
- },
- end: {
- line: 17,
- column: 11,
- },
- },
- },
-];
-
-export default OUTPUT;
diff --git a/src/tokenizer/__tests__/__output__/doctypes.ts b/src/tokenizer/__tests__/__output__/doctypes.ts
deleted file mode 100644
index 2c0d6fe..0000000
--- a/src/tokenizer/__tests__/__output__/doctypes.ts
+++ /dev/null
@@ -1,642 +0,0 @@
-import { TokenTypes } from "../../../constants";
-import { AnyToken } from "../../../types";
-
-const OUTPUT: AnyToken[] = [
- {
- type: TokenTypes.DoctypeOpen,
- value: "",
- range: [9, 10],
- loc: {
- start: {
- line: 1,
- column: 9,
- },
- end: {
- line: 1,
- column: 10,
- },
- },
- },
- {
- type: TokenTypes.Text,
- value: "\n\n",
- range: [10, 12],
- loc: {
- start: {
- line: 1,
- column: 10,
- },
- end: {
- line: 3,
- column: 0,
- },
- },
- parts: [],
- },
- {
- type: TokenTypes.DoctypeOpen,
- value: "",
- range: [21, 22],
- loc: {
- start: {
- line: 3,
- column: 9,
- },
- end: {
- line: 3,
- column: 10,
- },
- },
- },
- {
- type: TokenTypes.Text,
- value: "\n\n",
- range: [22, 24],
- loc: {
- start: {
- line: 3,
- column: 10,
- },
- end: {
- line: 5,
- column: 0,
- },
- },
- parts: [],
- },
- {
- type: TokenTypes.DoctypeOpen,
- value: "",
- range: [65, 66],
- loc: {
- start: {
- line: 5,
- column: 41,
- },
- end: {
- line: 5,
- column: 42,
- },
- },
- },
- {
- type: TokenTypes.Text,
- value: "\n\n",
- range: [66, 68],
- loc: {
- start: {
- line: 5,
- column: 42,
- },
- end: {
- line: 7,
- column: 0,
- },
- },
- parts: [],
- },
- {
- type: TokenTypes.DoctypeOpen,
- value: "",
- range: [89, 90],
- loc: {
- start: {
- line: 7,
- column: 21,
- },
- end: {
- line: 7,
- column: 22,
- },
- },
- },
- {
- type: TokenTypes.Text,
- value: "\n\n",
- range: [90, 92],
- loc: {
- start: {
- line: 7,
- column: 22,
- },
- end: {
- line: 9,
- column: 0,
- },
- },
- parts: [],
- },
- {
- type: TokenTypes.DoctypeOpen,
- value: "",
- range: [192, 193],
- loc: {
- start: {
- line: 9,
- column: 100,
- },
- end: {
- line: 9,
- column: 101,
- },
- },
- },
- {
- type: TokenTypes.Text,
- value: "\n\n",
- range: [193, 195],
- loc: {
- start: {
- line: 9,
- column: 101,
- },
- end: {
- line: 11,
- column: 0,
- },
- },
- parts: [],
- },
- {
- type: TokenTypes.DoctypeOpen,
- value: "",
- range: [302, 303],
- loc: {
- start: {
- line: 15,
- column: 0,
- },
- end: {
- line: 15,
- column: 1,
- },
- },
- },
- {
- type: TokenTypes.Text,
- value: "\n",
- range: [303, 304],
- loc: {
- start: {
- line: 15,
- column: 1,
- },
- end: {
- line: 16,
- column: 0,
- },
- },
- parts: [],
- },
-];
-export default OUTPUT;
diff --git a/src/tokenizer/__tests__/__output__/empty.ts b/src/tokenizer/__tests__/__output__/empty.ts
deleted file mode 100644
index d6d1738..0000000
--- a/src/tokenizer/__tests__/__output__/empty.ts
+++ /dev/null
@@ -1 +0,0 @@
-export default [];
diff --git a/src/tokenizer/__tests__/__output__/nested-tags.ts b/src/tokenizer/__tests__/__output__/nested-tags.ts
deleted file mode 100644
index ca92fd7..0000000
--- a/src/tokenizer/__tests__/__output__/nested-tags.ts
+++ /dev/null
@@ -1,238 +0,0 @@
-import { TokenTypes } from "../../../constants";
-import { AnyToken } from "../../../types";
-
-const OUTPUT: AnyToken[] = [
- {
- type: TokenTypes.OpenTagStart,
- value: "",
- range: [4, 5],
- loc: {
- start: {
- line: 1,
- column: 4,
- },
- end: {
- line: 1,
- column: 5,
- },
- },
- },
- {
- type: TokenTypes.Text,
- value: "\n ",
- range: [5, 8],
- loc: {
- start: {
- line: 1,
- column: 5,
- },
- end: {
- line: 2,
- column: 2,
- },
- },
- parts: [],
- },
- {
- type: TokenTypes.OpenTagStart,
- value: "",
- range: [13, 14],
- loc: {
- start: {
- line: 2,
- column: 7,
- },
- end: {
- line: 2,
- column: 8,
- },
- },
- },
- {
- type: TokenTypes.Text,
- value: "\n some text\n\n ",
- range: [14, 34],
- loc: {
- start: {
- line: 2,
- column: 8,
- },
- end: {
- line: 5,
- column: 4,
- },
- },
- parts: [],
- },
- {
- type: TokenTypes.OpenTagStart,
- value: "",
- range: [39, 40],
- loc: {
- start: {
- line: 5,
- column: 9,
- },
- end: {
- line: 5,
- column: 10,
- },
- },
- },
- {
- type: TokenTypes.Text,
- value: "\n another text\n ",
- range: [40, 64],
- loc: {
- start: {
- column: 10,
- line: 5,
- },
- end: {
- line: 7,
- column: 4,
- },
- },
- parts: [],
- },
- {
- type: TokenTypes.CloseTag,
- value: " ",
- range: [64, 71],
- loc: {
- start: {
- line: 7,
- column: 4,
- },
- end: {
- line: 7,
- column: 11,
- },
- },
- },
- {
- type: TokenTypes.Text,
- value: "\n ",
- range: [71, 74],
- loc: {
- start: {
- line: 7,
- column: 11,
- },
- end: {
- line: 8,
- column: 2,
- },
- },
- parts: [],
- },
- {
- type: TokenTypes.CloseTag,
- value: " ",
- range: [74, 81],
- loc: {
- start: {
- line: 8,
- column: 2,
- },
- end: {
- line: 8,
- column: 9,
- },
- },
- },
- {
- type: TokenTypes.Text,
- value: "\n",
- range: [81, 82],
- loc: {
- start: {
- line: 8,
- column: 9,
- },
- end: {
- line: 9,
- column: 0,
- },
- },
- parts: [],
- },
- {
- type: TokenTypes.CloseTag,
- value: "
",
- range: [82, 88],
- loc: {
- start: {
- line: 9,
- column: 0,
- },
- end: {
- line: 9,
- column: 6,
- },
- },
- },
- {
- type: TokenTypes.Text,
- value: "\n",
- range: [88, 89],
- loc: {
- start: {
- line: 9,
- column: 6,
- },
- end: {
- line: 10,
- column: 0,
- },
- },
- parts: [],
- },
-];
-
-export default OUTPUT;
diff --git a/src/tokenizer/__tests__/__output__/opening-closing-text.ts b/src/tokenizer/__tests__/__output__/opening-closing-text.ts
deleted file mode 100644
index 993d998..0000000
--- a/src/tokenizer/__tests__/__output__/opening-closing-text.ts
+++ /dev/null
@@ -1,84 +0,0 @@
-import { TokenTypes } from "../../../constants";
-import { AnyToken } from "../../../types";
-
-const OUTPUT: AnyToken[] = [
- {
- type: TokenTypes.Text,
- value: "opening text\n\n",
- range: [0, 14],
- loc: {
- start: {
- line: 1,
- column: 0,
- },
- end: {
- line: 3,
- column: 0,
- },
- },
- parts: [],
- },
- {
- type: TokenTypes.OpenTagStart,
- value: "",
- range: [18, 19],
- loc: {
- start: {
- line: 3,
- column: 4,
- },
- end: {
- line: 3,
- column: 5,
- },
- },
- },
- {
- type: TokenTypes.CloseTag,
- value: "
",
- range: [19, 25],
- loc: {
- start: {
- line: 3,
- column: 5,
- },
- end: {
- line: 3,
- column: 11,
- },
- },
- },
- {
- type: TokenTypes.Text,
- value: "\n\nclosing text\n",
- range: [25, 40],
- loc: {
- start: {
- line: 3,
- column: 11,
- },
- end: {
- line: 6,
- column: 0,
- },
- },
- parts: [],
- },
-];
-
-export default OUTPUT;
diff --git a/src/tokenizer/__tests__/__output__/script-elements-attributes.ts b/src/tokenizer/__tests__/__output__/script-elements-attributes.ts
deleted file mode 100644
index 340e095..0000000
--- a/src/tokenizer/__tests__/__output__/script-elements-attributes.ts
+++ /dev/null
@@ -1,655 +0,0 @@
-import { TokenTypes } from "../../../constants";
-import { AnyToken } from "../../../types";
-
-const OUTPUT: AnyToken[] = [
- {
- type: TokenTypes.OpenTagStart,
- value: "",
- range: [4, 5],
- loc: {
- start: {
- line: 1,
- column: 4,
- },
- end: {
- line: 1,
- column: 5,
- },
- },
- },
- {
- type: TokenTypes.Text,
- value: "\n dummy content\n\n ",
- range: [5, 25],
- loc: {
- start: {
- line: 1,
- column: 5,
- },
- end: {
- line: 4,
- column: 2,
- },
- },
- parts: [],
- },
- {
- type: TokenTypes.OpenScriptTagStart,
- value: "",
- range: [109, 118],
- loc: {
- start: {
- line: 6,
- column: 2,
- },
- end: {
- line: 6,
- column: 11,
- },
- },
- },
- {
- type: TokenTypes.Text,
- value: "\n\n ",
- range: [118, 122],
- loc: {
- start: {
- line: 6,
- column: 11,
- },
- end: {
- line: 8,
- column: 2,
- },
- },
- parts: [],
- },
- {
- type: TokenTypes.OpenScriptTagStart,
- value: "",
- range: [218, 227],
- loc: {
- start: {
- column: 2,
- line: 14,
- },
- end: {
- line: 14,
- column: 11,
- },
- },
- },
- {
- type: TokenTypes.Text,
- value: "\n",
- range: [227, 228],
- loc: {
- start: {
- line: 14,
- column: 11,
- },
- end: {
- line: 15,
- column: 0,
- },
- },
- parts: [],
- },
- {
- type: TokenTypes.CloseTag,
- value: "
",
- range: [228, 234],
- loc: {
- start: {
- line: 15,
- column: 0,
- },
- end: {
- line: 15,
- column: 6,
- },
- },
- },
- {
- type: TokenTypes.Text,
- value: "\n\n",
- range: [234, 236],
- loc: {
- start: {
- line: 15,
- column: 6,
- },
- end: {
- line: 17,
- column: 0,
- },
- },
- parts: [],
- },
- {
- type: TokenTypes.OpenScriptTagStart,
- value: "",
- range: [298, 307],
- loc: {
- start: {
- line: 19,
- column: 0,
- },
- end: {
- line: 19,
- column: 9,
- },
- },
- },
- {
- type: TokenTypes.Text,
- value: "\n",
- range: [307, 308],
- loc: {
- start: {
- line: 19,
- column: 9,
- },
- end: {
- line: 20,
- column: 0,
- },
- },
- parts: [],
- },
-];
-
-export default OUTPUT;
diff --git a/src/tokenizer/__tests__/__output__/script-elements.ts b/src/tokenizer/__tests__/__output__/script-elements.ts
deleted file mode 100644
index 2103153..0000000
--- a/src/tokenizer/__tests__/__output__/script-elements.ts
+++ /dev/null
@@ -1,176 +0,0 @@
-import { TokenTypes } from "../../../constants";
-import { AnyToken } from "../../../types";
-
-const OUTPUT: AnyToken[] = [
- {
- type: TokenTypes.Text,
- value: "opening text\n\n",
- range: [0, 14],
- loc: {
- start: {
- line: 1,
- column: 0,
- },
- end: {
- line: 3,
- column: 0,
- },
- },
- parts: [],
- },
- {
- type: TokenTypes.OpenTagStart,
- value: "",
- range: [18, 19],
- loc: {
- start: {
- line: 3,
- column: 4,
- },
- end: {
- line: 3,
- column: 5,
- },
- },
- },
- {
- type: TokenTypes.Text,
- value: "\n ",
- range: [19, 22],
- loc: {
- start: {
- line: 3,
- column: 5,
- },
- end: {
- line: 4,
- column: 2,
- },
- },
- parts: [],
- },
- {
- type: TokenTypes.OpenScriptTagStart,
- value: "",
- range: [53, 62],
- loc: {
- start: {
- line: 6,
- column: 2,
- },
- end: {
- line: 6,
- column: 11,
- },
- },
- },
- {
- type: TokenTypes.Text,
- value: "\n",
- range: [62, 63],
- loc: {
- start: {
- line: 6,
- column: 11,
- },
- end: {
- line: 7,
- column: 0,
- },
- },
- parts: [],
- },
- {
- type: TokenTypes.CloseTag,
- value: "
",
- range: [63, 69],
- loc: {
- start: {
- line: 7,
- column: 0,
- },
- end: {
- line: 7,
- column: 6,
- },
- },
- },
- {
- type: TokenTypes.Text,
- value: "\n\nclosing text\n",
- range: [69, 84],
- loc: {
- start: {
- line: 7,
- column: 6,
- },
- end: {
- line: 10,
- column: 0,
- },
- },
- parts: [],
- },
-];
-export default OUTPUT;
diff --git a/src/tokenizer/__tests__/__output__/style-elements-attributes.ts b/src/tokenizer/__tests__/__output__/style-elements-attributes.ts
deleted file mode 100644
index fc02295..0000000
--- a/src/tokenizer/__tests__/__output__/style-elements-attributes.ts
+++ /dev/null
@@ -1,500 +0,0 @@
-import { TokenTypes } from "../../../constants";
-import { AnyToken } from "../../../types";
-
-const OUTPUT: AnyToken[] = [
- {
- type: TokenTypes.OpenStyleTagStart,
- value: "",
- range: [85, 93],
- loc: {
- start: {
- line: 5,
- column: 0,
- },
- end: {
- line: 5,
- column: 8,
- },
- },
- },
- {
- type: TokenTypes.Text,
- value: "\n\n",
- range: [93, 95],
- loc: {
- start: {
- column: 8,
- line: 5,
- },
- end: {
- line: 7,
- column: 0,
- },
- },
- parts: [],
- },
- {
- type: TokenTypes.OpenTagStart,
- value: "",
- range: [99, 100],
- loc: {
- start: {
- line: 7,
- column: 4,
- },
- end: {
- line: 7,
- column: 5,
- },
- },
- },
- {
- type: TokenTypes.Text,
- value: "\n ",
- range: [100, 103],
- loc: {
- start: {
- column: 5,
- line: 7,
- },
- end: {
- line: 8,
- column: 2,
- },
- },
- parts: [],
- },
- {
- type: TokenTypes.OpenStyleTagStart,
- value: "",
- range: [213, 221],
- loc: {
- start: {
- line: 17,
- column: 2,
- },
- end: {
- line: 17,
- column: 10,
- },
- },
- },
- {
- type: TokenTypes.Text,
- value: "\n",
- range: [221, 222],
- loc: {
- start: {
- line: 17,
- column: 10,
- },
- end: {
- line: 18,
- column: 0,
- },
- },
- parts: [],
- },
- {
- type: TokenTypes.CloseTag,
- value: "
",
- range: [222, 228],
- loc: {
- start: {
- line: 18,
- column: 0,
- },
- end: {
- line: 18,
- column: 6,
- },
- },
- },
- {
- type: TokenTypes.Text,
- value: "\n",
- range: [228, 229],
- loc: {
- start: {
- line: 18,
- column: 6,
- },
- end: {
- line: 19,
- column: 0,
- },
- },
- parts: [],
- },
-];
-export default OUTPUT;
diff --git a/src/tokenizer/__tests__/__output__/style-elements.ts b/src/tokenizer/__tests__/__output__/style-elements.ts
deleted file mode 100644
index c68f288..0000000
--- a/src/tokenizer/__tests__/__output__/style-elements.ts
+++ /dev/null
@@ -1,254 +0,0 @@
-import { TokenTypes } from "../../../constants";
-import { AnyToken } from "../../../types";
-
-const OUTPUT: AnyToken[] = [
- {
- type: TokenTypes.Text,
- value: "opening text\n\n",
- range: [0, 14],
- loc: {
- start: {
- line: 1,
- column: 0,
- },
- end: {
- line: 3,
- column: 0,
- },
- },
- parts: [],
- },
- {
- type: TokenTypes.OpenStyleTagStart,
- value: "",
- range: [64, 72],
- loc: {
- start: {
- column: 0,
- line: 7,
- },
- end: {
- column: 8,
- line: 7,
- },
- },
- },
- {
- type: TokenTypes.Text,
- value: "\n\n",
- range: [72, 74],
- loc: {
- start: {
- column: 8,
- line: 7,
- },
- end: {
- line: 9,
- column: 0,
- },
- },
- parts: [],
- },
- {
- type: TokenTypes.OpenTagStart,
- value: "",
- range: [78, 79],
- loc: {
- start: {
- column: 4,
- line: 9,
- },
- end: {
- line: 9,
- column: 5,
- },
- },
- },
- {
- type: TokenTypes.Text,
- value: "\n ",
- range: [79, 82],
- loc: {
- start: {
- line: 9,
- column: 5,
- },
- end: {
- line: 10,
- column: 2,
- },
- },
- parts: [],
- },
- {
- type: TokenTypes.OpenStyleTagStart,
- value: "",
- range: [138, 146],
- loc: {
- start: {
- line: 14,
- column: 2,
- },
- end: {
- line: 14,
- column: 10,
- },
- },
- },
- {
- type: TokenTypes.Text,
- value: "\n",
- range: [146, 147],
- loc: {
- start: {
- line: 14,
- column: 10,
- },
- end: {
- line: 15,
- column: 0,
- },
- },
- parts: [],
- },
- {
- type: TokenTypes.CloseTag,
- value: "
",
- range: [147, 153],
- loc: {
- start: {
- line: 15,
- column: 0,
- },
- end: {
- line: 15,
- column: 6,
- },
- },
- },
- {
- type: TokenTypes.Text,
- value: "\n\nclosing text\n",
- range: [153, 168],
- loc: {
- start: {
- column: 6,
- line: 15,
- },
- end: {
- line: 18,
- column: 0,
- },
- },
- parts: [],
- },
-];
-
-export default OUTPUT;
diff --git a/src/tokenizer/__tests__/__output__/svg.ts b/src/tokenizer/__tests__/__output__/svg.ts
deleted file mode 100644
index 734ca24..0000000
--- a/src/tokenizer/__tests__/__output__/svg.ts
+++ /dev/null
@@ -1,159 +0,0 @@
-import { TokenTypes } from "../../../constants";
-import { AnyToken } from "../../../types";
-
-const OUTPUT: AnyToken[] = [
- {
- type: TokenTypes.OpenTagStart,
- value: "",
- range: [39, 40],
- loc: {
- end: {
- column: 40,
- line: 1,
- },
- start: {
- column: 39,
- line: 1,
- },
- },
- },
- {
- type: TokenTypes.OpenTagStart,
- value: " ",
- range: [48, 50],
- loc: {
- end: {
- column: 50,
- line: 1,
- },
- start: {
- column: 48,
- line: 1,
- },
- },
- },
- {
- type: TokenTypes.CloseTag,
- value: " ",
- range: [50, 56],
- loc: {
- end: {
- column: 56,
- line: 1,
- },
- start: {
- column: 50,
- line: 1,
- },
- },
- },
-];
-
-export default OUTPUT;
diff --git a/src/tokenizer/__tests__/__output__/tags-register.ts b/src/tokenizer/__tests__/__output__/tags-register.ts
deleted file mode 100644
index c720254..0000000
--- a/src/tokenizer/__tests__/__output__/tags-register.ts
+++ /dev/null
@@ -1,818 +0,0 @@
-import { TokenTypes } from "../../../constants";
-import { AnyToken } from "../../../types";
-
-const OUTPUT: AnyToken[] = [
- {
- type: TokenTypes.OpenTagStart,
- value: "",
- range: [4, 5],
- loc: {
- start: {
- line: 1,
- column: 4,
- },
- end: {
- line: 1,
- column: 5,
- },
- },
- },
- {
- type: TokenTypes.Text,
- value: "\n",
- range: [5, 6],
- loc: {
- start: {
- line: 1,
- column: 5,
- },
- end: {
- line: 2,
- column: 0,
- },
- },
- parts: [],
- },
- {
- type: TokenTypes.CloseTag,
- value: "
",
- range: [6, 12],
- loc: {
- start: {
- line: 2,
- column: 0,
- },
- end: {
- line: 2,
- column: 6,
- },
- },
- },
- {
- type: TokenTypes.Text,
- value: "\n\n",
- range: [12, 14],
- loc: {
- start: {
- line: 2,
- column: 6,
- },
- end: {
- line: 4,
- column: 0,
- },
- },
- parts: [],
- },
- {
- type: TokenTypes.OpenTagStart,
- value: "",
- range: [18, 19],
- loc: {
- start: {
- line: 4,
- column: 4,
- },
- end: {
- line: 4,
- column: 5,
- },
- },
- },
- {
- type: TokenTypes.CloseTag,
- value: "
",
- range: [19, 25],
- loc: {
- start: {
- line: 4,
- column: 5,
- },
- end: {
- line: 4,
- column: 11,
- },
- },
- },
- {
- type: TokenTypes.Text,
- value: "\n\n",
- range: [25, 27],
- loc: {
- start: {
- line: 4,
- column: 11,
- },
- end: {
- line: 6,
- column: 0,
- },
- },
- parts: [],
- },
- {
- type: TokenTypes.OpenTagStart,
- value: "",
- range: [32, 33],
- loc: {
- start: {
- line: 6,
- column: 5,
- },
- end: {
- line: 6,
- column: 6,
- },
- },
- },
- {
- type: TokenTypes.Text,
- value: "\n",
- range: [33, 34],
- loc: {
- start: {
- line: 6,
- column: 6,
- },
- end: {
- line: 7,
- column: 0,
- },
- },
- parts: [],
- },
- {
- type: TokenTypes.CloseTag,
- value: " ",
- range: [34, 41],
- loc: {
- start: {
- line: 7,
- column: 0,
- },
- end: {
- line: 7,
- column: 7,
- },
- },
- },
- {
- type: TokenTypes.Text,
- value: "\n\n",
- range: [41, 43],
- loc: {
- start: {
- line: 7,
- column: 7,
- },
- end: {
- line: 9,
- column: 0,
- },
- },
- parts: [],
- },
- {
- type: TokenTypes.OpenTagStart,
- value: "",
- range: [48, 49],
- loc: {
- start: {
- line: 9,
- column: 5,
- },
- end: {
- line: 9,
- column: 6,
- },
- },
- },
- {
- type: TokenTypes.CloseTag,
- value: " ",
- range: [49, 56],
- loc: {
- start: {
- line: 9,
- column: 6,
- },
- end: {
- line: 9,
- column: 13,
- },
- },
- },
- {
- type: TokenTypes.Text,
- value: "\n\n",
- range: [56, 58],
- loc: {
- start: {
- line: 9,
- column: 13,
- },
- end: {
- line: 11,
- column: 0,
- },
- },
- parts: [],
- },
- {
- type: TokenTypes.OpenScriptTagStart,
- value: "",
- range: [66, 75],
- loc: {
- start: {
- column: 8,
- line: 11,
- },
- end: {
- line: 11,
- column: 17,
- },
- },
- },
- {
- type: TokenTypes.Text,
- value: "\n",
- range: [75, 76],
- loc: {
- start: {
- line: 11,
- column: 17,
- },
- end: {
- line: 12,
- column: 0,
- },
- },
- parts: [],
- },
- {
- type: TokenTypes.OpenScriptTagStart,
- value: "",
- range: [85, 94],
- loc: {
- start: {
- line: 13,
- column: 0,
- },
- end: {
- line: 13,
- column: 9,
- },
- },
- },
- {
- type: TokenTypes.Text,
- value: "\n",
- range: [94, 95],
- loc: {
- start: {
- line: 13,
- column: 9,
- },
- end: {
- line: 14,
- column: 0,
- },
- },
- parts: [],
- },
- {
- type: TokenTypes.OpenScriptTagStart,
- value: "",
- range: [103, 112],
- loc: {
- start: {
- line: 14,
- column: 8,
- },
- end: {
- line: 14,
- column: 17,
- },
- },
- },
- {
- type: TokenTypes.Text,
- value: "\n",
- range: [112, 113],
- loc: {
- start: {
- column: 17,
- line: 14,
- },
- end: {
- line: 15,
- column: 0,
- },
- },
- parts: [],
- },
- {
- type: TokenTypes.OpenScriptTagStart,
- value: "",
- range: [122, 131],
- loc: {
- start: {
- line: 16,
- column: 0,
- },
- end: {
- line: 16,
- column: 9,
- },
- },
- },
- {
- type: TokenTypes.Text,
- value: "\n\n",
- range: [131, 133],
- loc: {
- start: {
- line: 16,
- column: 9,
- },
- end: {
- line: 18,
- column: 0,
- },
- },
- parts: [],
- },
- {
- type: TokenTypes.OpenStyleTagStart,
- value: "",
- range: [140, 148],
- loc: {
- start: {
- line: 18,
- column: 7,
- },
- end: {
- line: 18,
- column: 15,
- },
- },
- },
- {
- type: TokenTypes.Text,
- value: "\n",
- range: [148, 149],
- loc: {
- start: {
- line: 18,
- column: 15,
- },
- end: {
- line: 19,
- column: 0,
- },
- },
- parts: [],
- },
- {
- type: TokenTypes.OpenStyleTagStart,
- value: "",
- range: [157, 165],
- loc: {
- start: {
- line: 20,
- column: 0,
- },
- end: {
- line: 20,
- column: 8,
- },
- },
- },
- {
- type: TokenTypes.Text,
- value: "\n",
- range: [165, 166],
- loc: {
- start: {
- line: 20,
- column: 8,
- },
- end: {
- line: 21,
- column: 0,
- },
- },
- parts: [],
- },
- {
- type: TokenTypes.OpenStyleTagStart,
- value: "",
- range: [173, 181],
- loc: {
- start: {
- line: 21,
- column: 7,
- },
- end: {
- line: 21,
- column: 15,
- },
- },
- },
- {
- type: TokenTypes.Text,
- value: "\n",
- range: [181, 182],
- loc: {
- start: {
- line: 21,
- column: 15,
- },
- end: {
- line: 22,
- column: 0,
- },
- },
- parts: [],
- },
- {
- type: TokenTypes.OpenStyleTagStart,
- value: "",
- range: [189, 197],
- loc: {
- start: {
- line: 22,
- column: 7,
- },
- end: {
- line: 22,
- column: 15,
- },
- },
- },
- {
- type: TokenTypes.Text,
- value: "\n",
- range: [197, 198],
- loc: {
- start: {
- line: 22,
- column: 15,
- },
- end: {
- line: 23,
- column: 0,
- },
- },
- parts: [],
- },
-];
-export default OUTPUT;
diff --git a/src/tokenizer/__tests__/__output__/templates-attributes-key-wrapper.ts b/src/tokenizer/__tests__/__output__/templates-attributes-key-wrapper.ts
deleted file mode 100644
index 3be53ae..0000000
--- a/src/tokenizer/__tests__/__output__/templates-attributes-key-wrapper.ts
+++ /dev/null
@@ -1,110 +0,0 @@
-export default [
- {
- loc: {
- end: {
- column: 4,
- line: 1,
- },
- start: {
- column: 0,
- line: 1,
- },
- },
- range: [0, 4],
- type: "OpenTagStart",
- value: "",
- },
- {
- loc: {
- end: {
- column: 18,
- line: 1,
- },
- start: {
- column: 12,
- line: 1,
- },
- },
- range: [12, 18],
- type: "CloseTag",
- value: "
",
- },
-];
diff --git a/src/tokenizer/__tests__/__output__/templates-attributes-key.ts b/src/tokenizer/__tests__/__output__/templates-attributes-key.ts
deleted file mode 100644
index ab6b819..0000000
--- a/src/tokenizer/__tests__/__output__/templates-attributes-key.ts
+++ /dev/null
@@ -1,82 +0,0 @@
-export default [
- {
- loc: {
- end: {
- column: 4,
- line: 1,
- },
- start: {
- column: 0,
- line: 1,
- },
- },
- range: [0, 4],
- type: "OpenTagStart",
- value: "",
- },
- {
- loc: {
- end: {
- column: 18,
- line: 1,
- },
- start: {
- column: 12,
- line: 1,
- },
- },
- range: [12, 18],
- type: "CloseTag",
- value: "
",
- },
-];
diff --git a/src/tokenizer/__tests__/__output__/templates-attributes-value-bare.ts b/src/tokenizer/__tests__/__output__/templates-attributes-value-bare.ts
deleted file mode 100644
index 729b1d4..0000000
--- a/src/tokenizer/__tests__/__output__/templates-attributes-value-bare.ts
+++ /dev/null
@@ -1,74 +0,0 @@
-import { TokenTypes } from "../../../constants";
-import { AnyToken } from "../../../types";
-
-const OUTPUT: AnyToken[] = [
- {
- type: TokenTypes.OpenTagStart,
- value: "",
- },
- {
- type: TokenTypes.CloseTag,
- range: [14, 20],
- loc: {
- start: { line: 1, column: 14 },
- end: { line: 1, column: 20 },
- },
- value: "
",
- },
-];
-
-export default OUTPUT;
diff --git a/src/tokenizer/__tests__/__output__/templates-attributes-value-wrapped-2.ts b/src/tokenizer/__tests__/__output__/templates-attributes-value-wrapped-2.ts
deleted file mode 100644
index 5a41b4a..0000000
--- a/src/tokenizer/__tests__/__output__/templates-attributes-value-wrapped-2.ts
+++ /dev/null
@@ -1,122 +0,0 @@
-import { TokenTypes } from "../../../constants";
-import { AnyToken } from "../../../types";
-
-const OUTPUT: AnyToken[] = [
- {
- type: TokenTypes.OpenTagStart,
- value: "",
- },
- {
- type: TokenTypes.CloseTag,
- range: [33, 39],
- loc: {
- start: { line: 1, column: 33 },
- end: { line: 1, column: 39 },
- },
- value: "
",
- },
-];
-
-export default OUTPUT;
diff --git a/src/tokenizer/__tests__/__output__/templates-attributes-value-wrapped.ts b/src/tokenizer/__tests__/__output__/templates-attributes-value-wrapped.ts
deleted file mode 100644
index 200fda3..0000000
--- a/src/tokenizer/__tests__/__output__/templates-attributes-value-wrapped.ts
+++ /dev/null
@@ -1,92 +0,0 @@
-import { TokenTypes } from "../../../constants";
-import { AnyToken } from "../../../types";
-
-const OUTPUT: AnyToken[] = [
- {
- type: TokenTypes.OpenTagStart,
- value: "",
- },
- {
- type: TokenTypes.CloseTag,
- range: [16, 22],
- loc: {
- start: { line: 1, column: 16 },
- end: { line: 1, column: 22 },
- },
- value: "
",
- },
-];
-
-export default OUTPUT;
diff --git a/src/tokenizer/__tests__/__output__/templates-comment.ts b/src/tokenizer/__tests__/__output__/templates-comment.ts
deleted file mode 100644
index 2863acc..0000000
--- a/src/tokenizer/__tests__/__output__/templates-comment.ts
+++ /dev/null
@@ -1,47 +0,0 @@
-import { TokenTypes } from "../../../constants";
-import { AnyToken } from "../../../types";
-
-const OUTPUT: AnyToken[] = [
- {
- type: TokenTypes.CommentOpen,
- value: "",
- range: [14, 17],
- loc: {
- start: { line: 1, column: 14 },
- end: { line: 1, column: 17 },
- },
- },
-];
-export default OUTPUT;
diff --git a/src/tokenizer/__tests__/__output__/templates-content-end.ts b/src/tokenizer/__tests__/__output__/templates-content-end.ts
deleted file mode 100644
index 4e3272c..0000000
--- a/src/tokenizer/__tests__/__output__/templates-content-end.ts
+++ /dev/null
@@ -1,41 +0,0 @@
-import { TokenTypes } from "../../../constants";
-import { AnyToken } from "../../../types";
-
-const OUTPUT: AnyToken[] = [
- {
- loc: {
- end: {
- column: 10,
- line: 1,
- },
- start: {
- column: 0,
- line: 1,
- },
- },
- range: [0, 10],
- type: TokenTypes.Text,
- value: "${content}",
- parts: [
- {
- loc: {
- end: {
- column: 10,
- line: 1,
- },
- start: {
- column: 0,
- line: 1,
- },
- },
- range: [0, 10],
- type: TokenTypes.Template,
- value: "${content}",
- partOf: TokenTypes.Text,
- open: undefined,
- close: undefined,
- },
- ],
- },
-];
-export default OUTPUT;
diff --git a/src/tokenizer/__tests__/__output__/templates-data.ts b/src/tokenizer/__tests__/__output__/templates-data.ts
deleted file mode 100644
index 37a1307..0000000
--- a/src/tokenizer/__tests__/__output__/templates-data.ts
+++ /dev/null
@@ -1,55 +0,0 @@
-import { TokenTypes } from "../../../constants";
-import { AnyToken } from "../../../types";
-
-const OUTPUT: AnyToken[] = [
- {
- type: TokenTypes.OpenTagStart,
- value: "",
- range: [4, 5],
- loc: {
- start: { line: 1, column: 4 },
- end: { line: 1, column: 5 },
- },
- },
- {
- type: TokenTypes.Text,
- value: "${children}",
- range: [5, 16],
- loc: {
- start: { line: 1, column: 5 },
- end: { line: 1, column: 16 },
- },
- parts: [
- {
- type: TokenTypes.Template,
- partOf: TokenTypes.Text,
- value: "${children}",
- range: [5, 16],
- loc: {
- start: { line: 1, column: 5 },
- end: { line: 1, column: 16 },
- },
- },
- ],
- },
- {
- type: TokenTypes.CloseTag,
- value: "
",
- range: [16, 22],
- loc: {
- start: { line: 1, column: 16 },
- end: { line: 1, column: 22 },
- },
- },
-];
-
-export default OUTPUT;
diff --git a/src/tokenizer/__tests__/__output__/templates-script-content.ts b/src/tokenizer/__tests__/__output__/templates-script-content.ts
deleted file mode 100644
index 9c02cb1..0000000
--- a/src/tokenizer/__tests__/__output__/templates-script-content.ts
+++ /dev/null
@@ -1,56 +0,0 @@
-import { TokenTypes } from "../../../constants";
-import { AnyToken } from "../../../types";
-
-const OUTPUT: AnyToken[] = [
- {
- type: TokenTypes.OpenScriptTagStart,
- value: "",
- range: [18, 27],
- loc: {
- start: { line: 1, column: 18 },
- end: { line: 1, column: 27 },
- },
- },
-];
-export default OUTPUT;
diff --git a/src/tokenizer/__tests__/__output__/templates-style-content.ts b/src/tokenizer/__tests__/__output__/templates-style-content.ts
deleted file mode 100644
index c69e396..0000000
--- a/src/tokenizer/__tests__/__output__/templates-style-content.ts
+++ /dev/null
@@ -1,54 +0,0 @@
-import { TokenTypes } from "../../../constants";
-import { AnyToken } from "../../../types";
-
-const OUTPUT: AnyToken[] = [
- {
- type: TokenTypes.OpenStyleTagStart,
- value: "",
- range: [17, 25],
- loc: {
- start: { line: 1, column: 17 },
- end: { line: 1, column: 25 },
- },
- },
-];
-export default OUTPUT;
diff --git a/src/tokenizer/__tests__/__output__/void-tags.ts b/src/tokenizer/__tests__/__output__/void-tags.ts
deleted file mode 100644
index c823574..0000000
--- a/src/tokenizer/__tests__/__output__/void-tags.ts
+++ /dev/null
@@ -1,83 +0,0 @@
-import { TokenTypes } from "../../../constants";
-import { AnyToken } from "../../../types";
-
-const OUTPUT: AnyToken[] = [
- {
- type: TokenTypes.OpenTagStart,
- value: " ",
- range: [5, 7],
- loc: {
- start: {
- line: 1,
- column: 5,
- },
- end: {
- line: 1,
- column: 7,
- },
- },
- },
- {
- type: TokenTypes.Text,
- value: "\n\n",
- range: [7, 9],
- loc: {
- start: {
- line: 1,
- column: 7,
- },
- end: {
- line: 3,
- column: 0,
- },
- },
- parts: [],
- },
- {
- type: TokenTypes.OpenTagStart,
- value: " ",
- range: [14, 16],
- loc: {
- start: {
- line: 4,
- column: 0,
- },
- end: {
- line: 4,
- column: 2,
- },
- },
- },
-];
-
-export default OUTPUT;
diff --git a/src/tokenizer/__tests__/tokenize.spec.ts b/src/tokenizer/__tests__/tokenize.spec.ts
deleted file mode 100644
index 91e02a2..0000000
--- a/src/tokenizer/__tests__/tokenize.spec.ts
+++ /dev/null
@@ -1,233 +0,0 @@
-import * as fs from "fs";
-import * as path from "path";
-import { tokenize, TokenizeOptions } from "../tokenize";
-import OPENING_CLOSING_TEXT from "./__output__/opening-closing-text";
-import NESTED_TAGS from "./__output__/nested-tags";
-import COMMENTS from "./__output__/comments";
-import ATTRIBUTES_EMPTY from "./__output__/attributes-empty";
-import ATTRIBUTES_BARE from "./__output__/attributes-bare";
-import ATTRIBUTES_APOSTROPHE from "./__output__/attributes-apostrophe";
-import ATTRIBUTES_QUOTE from "./__output__/attributes-quote";
-import CUSTOM_ELEMENTS from "./__output__/custom-elements";
-import DOCTYPES from "./__output__/doctypes";
-import SCRIPT_ELEMENTS_ATTRIBUTES from "./__output__/script-elements-attributes";
-import SCRIPT_ELEMENTS from "./__output__/script-elements";
-import STYLE_ELEMENTS_ATTRIBUTES from "./__output__/style-elements-attributes";
-import STYLE_ELEMENTS from "./__output__/style-elements";
-import TAGS_REGISTER from "./__output__/tags-register";
-import VOID_TAGS from "./__output__/void-tags";
-import EMPTY from "./__output__/empty";
-import SVG from "./__output__/svg";
-import ATTRIBUTES_MULTILINE_CRLF from "./__output__/attributes-multiline-crlf";
-import ATTRIBUTES_BARE_WRONG_QUOTE from "./__output__/attributes-bare-wrong-quote";
-import TEMPLATE_ATTRIBUTES_KEY from "./__output__/templates-attributes-key";
-import TEMPLATE_ATTRIBUTES_KEY_WRAPPER from "./__output__/templates-attributes-key-wrapper";
-import TEMPLATE_ATTRIBUTES_VALUE_BARE from "./__output__/templates-attributes-value-bare";
-import TEMPLATE_ATTRIBUTES_VALUE_WRAPPED from "./__output__/templates-attributes-value-wrapped";
-import TEMPLATE_ATTRIBUTES_VALUE_WRAPPED_2 from "./__output__/templates-attributes-value-wrapped-2";
-import TEMPLATE_DATA from "./__output__/templates-data";
-import TEMPLATE_COMMENT from "./__output__/templates-comment";
-import TEMPLATE_SCRIPT_CONTENT from "./__output__/templates-script-content";
-import TEMPLATE_STYLE_CONTENT from "./__output__/templates-style-content";
-import TEMPLATE_CONTENT_END from "./__output__/templates-content-end";
-import CUSTOM_TAG_RAW_CONTENT from "./__output__/custom-tag-raw-content";
-import { defaultTokenAdapter } from "../../token-adapter";
-import { Range, TemplateInfo } from "../../types";
-
-describe("tokenize", () => {
- test.each([
- [
- "Attributes apostrophe",
- "attributes-apostrophe.html",
- ATTRIBUTES_APOSTROPHE,
- null,
- null,
- ],
- ["Attributes bare", "attributes-bare.html", ATTRIBUTES_BARE, null, null],
- [
- "Attributes bare wrong quotes",
- "attributes-bare-wrong-quote.html",
- ATTRIBUTES_BARE_WRONG_QUOTE,
- null,
- null,
- ],
- ["Attributes empty", "attributes-empty.html", ATTRIBUTES_EMPTY, null, null],
- ["Attributes quote", "attributes-quote.html", ATTRIBUTES_QUOTE, null, null],
- ["Comments", "comments.html", COMMENTS, null, null],
- ["Custom elements", "custom-elements.html", CUSTOM_ELEMENTS, null, null],
- ["Doctypes", "doctypes.html", DOCTYPES, null, null],
- ["Nested tags", "nested-tags.html", NESTED_TAGS, null, null],
- [
- "Opening and closing text",
- "opening-closing-text.html",
- OPENING_CLOSING_TEXT,
- null,
- null,
- ],
- [
- "Script elements attributes",
- "script-elements-attributes.html",
- SCRIPT_ELEMENTS_ATTRIBUTES,
- null,
- null,
- ],
- ["Script element", "script-elements.html", SCRIPT_ELEMENTS, null, null],
- ["Tags register", "tags-register.html", TAGS_REGISTER, null, null],
- [
- "Style elements attributes",
- "style-elements-attributes.html",
- STYLE_ELEMENTS_ATTRIBUTES,
- null,
- null,
- ],
- ["Style elements", "style-elements.html", STYLE_ELEMENTS, null, null],
- ["Void tags", "void-tags.html", VOID_TAGS, null, null],
- ["Empty", "empty.html", EMPTY, null, null],
- ["Svg", "svg.html", SVG, null, null],
- [
- "Attributes multiline CRLF",
- "attributes-multiline.html",
- ATTRIBUTES_MULTILINE_CRLF,
- (html: string) => {
- return html.replace(/\n/gi, "\r\n");
- },
- null,
- ],
- [
- "Template Attributes Key",
- "templates-attributes-key.html",
- TEMPLATE_ATTRIBUTES_KEY,
- null,
- {
- templateInfos: [[5, 11]] as Range[],
- },
- ],
- [
- "Template Attributes Key (wrapper)",
- "templates-attributes-key.html",
- TEMPLATE_ATTRIBUTES_KEY_WRAPPER,
- null,
- {
- templateInfos: [
- {
- open: [5, 7],
- close: [10, 11],
- },
- ] as TemplateInfo[],
- },
- ],
- [
- "Template Attributes Value Bare",
- "templates-attributes-value-bare.html",
- TEMPLATE_ATTRIBUTES_VALUE_BARE,
- null,
- {
- templateInfos: [[8, 13]] as Range[],
- },
- ],
- [
- "Template Attributes Value Wrapped",
- "templates-attributes-value-wrapped.html",
- TEMPLATE_ATTRIBUTES_VALUE_WRAPPED,
- null,
- {
- templateInfos: [[9, 14]] as Range[],
- },
- ],
- [
- "Template Attributes Value Wrapped 2",
- "templates-attributes-value-wrapped-2.html",
- TEMPLATE_ATTRIBUTES_VALUE_WRAPPED_2,
- null,
- {
- templateInfos: [
- [16, 22],
- [23, 31],
- ] as Range[],
- },
- ],
- [
- "Templates Data",
- "templates-data.html",
- TEMPLATE_DATA,
- null,
- {
- templateInfos: [[5, 16]] as Range[],
- },
- ],
- [
- "Templates Comment",
- "templates-comment.html",
- TEMPLATE_COMMENT,
- null,
- {
- templateInfos: [[4, 14]] as Range[],
- },
- ],
- [
- "Templates Script Content",
- "templates-script-content.html",
- TEMPLATE_SCRIPT_CONTENT,
- null,
- {
- templateInfos: [[8, 18]] as Range[],
- },
- ],
- [
- "Templates Style Content",
- "templates-style-content.html",
- TEMPLATE_STYLE_CONTENT,
- null,
- {
- templateInfos: [[7, 17]] as Range[],
- },
- ],
- [
- "Templates Content End",
- "templates-content-end.html",
- TEMPLATE_CONTENT_END,
- null,
- {
- templateInfos: [[0, 10]] as Range[],
- },
- ],
- [
- "Custom Tag Raw Content",
- "custom-tag-raw-content.html",
- CUSTOM_TAG_RAW_CONTENT,
- null,
- {
- rawContentTags: ["markdown"],
- },
- ],
- ])(
- "%s",
- (
- name,
- input,
- output,
- process: null | ((html: string) => string) = null,
- options: TokenizeOptions | null = null
- ) => {
- const inputPath = path.join(__dirname, "__input__", input);
- let html = fs.readFileSync(inputPath, "utf-8");
- if (process) {
- html = process(html);
- }
- const { tokens } = tokenize(html, defaultTokenAdapter, options || {});
- expect(tokens).toEqual(output);
- }
- );
-
- it("parsing error", () => {
- const html = fs.readFileSync(
- path.join(__dirname, "__input__", "parsing-error-no-open-end.html"),
- "utf-8"
- );
- expect(() =>
- tokenize(html, defaultTokenAdapter)
- ).toThrowErrorMatchingInlineSnapshot(
- `"Unexpected end of tag. Expected '>' to close the opening tag. (2:2)"`
- );
- });
-});
diff --git a/src/tree-constructor/__tests__/construct-tree.spec.ts b/src/tree-constructor/__tests__/construct-tree.spec.ts
deleted file mode 100644
index 851dfa6..0000000
--- a/src/tree-constructor/__tests__/construct-tree.spec.ts
+++ /dev/null
@@ -1,89 +0,0 @@
-import { constructTree } from "../construct-tree";
-
-import OPENING_CLOSING_TEXT_INPUT from "../../tokenizer/__tests__/__output__/opening-closing-text";
-
-import NESTED_TAGS_INPUT from "../../tokenizer/__tests__/__output__/nested-tags";
-
-import VOID_TAGS_INPUT from "../../tokenizer/__tests__/__output__/void-tags";
-
-import SCRIPT_ELEMENTS_INPUT from "../../tokenizer/__tests__/__output__/script-elements";
-
-import CUSTOM_ELEMENTS_INPUT from "../../tokenizer/__tests__/__output__/custom-elements";
-
-import DOCTYPES_INPUT from "../../tokenizer/__tests__/__output__/doctypes";
-
-import STYLE_ELEMENTS_INPUT from "../../tokenizer/__tests__/__output__/style-elements";
-
-import COMMENTS_INPUT from "../../tokenizer/__tests__/__output__/comments";
-
-import STYLE_ELEMENTS_ATTRIBUTES_INPUT from "../../tokenizer/__tests__/__output__/style-elements-attributes";
-
-import TAGS_REGISTER_INPUT from "../../tokenizer/__tests__/__output__/tags-register";
-
-import ATTRIBUTES_APOSTROPHE_INPUT from "../../tokenizer/__tests__/__output__/attributes-apostrophe";
-
-import ATTRIBUTES_EMPTY_INPUT from "../../tokenizer/__tests__/__output__/attributes-empty";
-
-import SCRIPT_ELEMENTS_ATTRIBUTES_INPUT from "../../tokenizer/__tests__/__output__/script-elements-attributes";
-
-import EMPTY_INPUT from "../../tokenizer/__tests__/__output__/empty";
-
-import SVG_INPUT from "../../tokenizer/__tests__/__output__/svg";
-
-import ATTRIBUTES_MULTILINE_CRLF_INPUT from "../../tokenizer/__tests__/__output__/attributes-multiline-crlf";
-
-import ATTRIBUTES_BARE_WRONG_QUOTE_INPUT from "../../tokenizer/__tests__/__output__/attributes-bare-wrong-quote";
-
-import TEMPLATE_ATTRIBUTES_KEY from "../../tokenizer/__tests__/__output__/templates-attributes-key";
-import TEMPLATE_ATTRIBUTES_VALUE_BARE from "../../tokenizer/__tests__/__output__/templates-attributes-value-bare";
-import TEMPLATE_ATTRIBUTES_VALUE_WRAPPED from "../../tokenizer/__tests__/__output__/templates-attributes-value-wrapped";
-import TEMPLATE_ATTRIBUTES_VALUE_WRAPPED_2 from "../../tokenizer/__tests__/__output__/templates-attributes-value-wrapped-2";
-import TEMPLATE_DATA from "../../tokenizer/__tests__/__output__/templates-data";
-import TEMPLATE_COMMENT from "../../tokenizer/__tests__/__output__/templates-comment";
-import TEMPLATE_SCRIPT_CONTENT from "../../tokenizer/__tests__/__output__/templates-script-content";
-import TEMPLATE_STYLE_CONTENT from "../../tokenizer/__tests__/__output__/templates-style-content";
-import TEMPLATE_CONTENT_END from "../../tokenizer/__tests__/__output__/templates-content-end";
-import CUSTOM_TAG_RAW_CONTENT from "../../tokenizer/__tests__/__output__/custom-tag-raw-content";
-import { clearParent } from "../../utils";
-import { toMatchFile } from "jest-file-snapshot";
-
-expect.extend({ toMatchFile });
-describe("construct-tree", () => {
- test.each([
- ["Attributes apostrophe", ATTRIBUTES_APOSTROPHE_INPUT],
- ["Attributes empty", ATTRIBUTES_EMPTY_INPUT],
- ["Attributes bare wrong quote", ATTRIBUTES_BARE_WRONG_QUOTE_INPUT],
- ["Comments", COMMENTS_INPUT],
- ["Opening closing text", OPENING_CLOSING_TEXT_INPUT],
- ["Void tags", VOID_TAGS_INPUT],
- ["Script elements", SCRIPT_ELEMENTS_INPUT],
- ["Script elements attributes", SCRIPT_ELEMENTS_ATTRIBUTES_INPUT],
- ["Nested tags", NESTED_TAGS_INPUT],
- ["Custom elements", CUSTOM_ELEMENTS_INPUT],
- ["Doctypes", DOCTYPES_INPUT],
- ["Style elements", STYLE_ELEMENTS_INPUT],
- ["Style elements attributes", STYLE_ELEMENTS_ATTRIBUTES_INPUT],
- ["Tag register", TAGS_REGISTER_INPUT],
- ["Empty", EMPTY_INPUT],
- ["Svg", SVG_INPUT],
- ["Attributes multiline (CRLF)", ATTRIBUTES_MULTILINE_CRLF_INPUT],
- ["Templates Attributes Key", TEMPLATE_ATTRIBUTES_KEY],
- ["Templates Attributes Value Bare", TEMPLATE_ATTRIBUTES_VALUE_BARE],
- ["Templates Attributes Value Wrapped", TEMPLATE_ATTRIBUTES_VALUE_WRAPPED],
- [
- "Templates Attributes Value Wrapped 2",
- TEMPLATE_ATTRIBUTES_VALUE_WRAPPED_2,
- ],
- ["Templates Data", TEMPLATE_DATA],
- ["Templates Comment", TEMPLATE_COMMENT],
- ["Templates Script Content", TEMPLATE_SCRIPT_CONTENT],
- ["Templates Style Content", TEMPLATE_STYLE_CONTENT],
- ["Templates Content End", TEMPLATE_CONTENT_END],
- ["Custom Tag Raw Content", CUSTOM_TAG_RAW_CONTENT],
- ])("%s", (name: string, inputTokens: any) => {
- const { ast } = constructTree(inputTokens);
- expect(JSON.stringify(clearParent(ast), null, 2)).toMatchFile(undefined, {
- fileExtension: ".json",
- });
- });
-});
diff --git a/tsconfig.json b/tsconfig.json
index 3ca154e..b231ce0 100644
--- a/tsconfig.json
+++ b/tsconfig.json
@@ -6,7 +6,8 @@
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"rootDir": "src",
- "skipLibCheck": true
+ "skipLibCheck": true,
+ "resolveJsonModule": true
},
"exclude": ["website"]
}