@tkeron/html-parser 1.1.2 → 1.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (131) hide show
  1. package/.github/workflows/npm_deploy.yml +14 -4
  2. package/README.md +6 -6
  3. package/bun.lock +6 -8
  4. package/check-versions.ts +147 -0
  5. package/index.ts +4 -8
  6. package/package.json +5 -6
  7. package/src/dom-simulator/append-child.ts +130 -0
  8. package/src/dom-simulator/append.ts +18 -0
  9. package/src/dom-simulator/attributes.ts +23 -0
  10. package/src/dom-simulator/clone-node.ts +51 -0
  11. package/src/dom-simulator/convert-ast-node-to-dom.ts +37 -0
  12. package/src/dom-simulator/create-cdata.ts +18 -0
  13. package/src/dom-simulator/create-comment.ts +23 -0
  14. package/src/dom-simulator/create-doctype.ts +24 -0
  15. package/src/dom-simulator/create-document.ts +81 -0
  16. package/src/dom-simulator/create-element.ts +195 -0
  17. package/src/dom-simulator/create-processing-instruction.ts +19 -0
  18. package/src/dom-simulator/create-temp-parent.ts +9 -0
  19. package/src/dom-simulator/create-text-node.ts +23 -0
  20. package/src/dom-simulator/escape-text-content.ts +6 -0
  21. package/src/dom-simulator/find-special-elements.ts +14 -0
  22. package/src/dom-simulator/get-text-content.ts +18 -0
  23. package/src/dom-simulator/index.ts +36 -0
  24. package/src/dom-simulator/inner-outer-html.ts +182 -0
  25. package/src/dom-simulator/insert-after.ts +20 -0
  26. package/src/dom-simulator/insert-before.ts +108 -0
  27. package/src/dom-simulator/matches.ts +26 -0
  28. package/src/dom-simulator/node-types.ts +26 -0
  29. package/src/dom-simulator/prepend.ts +24 -0
  30. package/src/dom-simulator/remove-child.ts +68 -0
  31. package/src/dom-simulator/remove.ts +7 -0
  32. package/src/dom-simulator/replace-child.ts +152 -0
  33. package/src/dom-simulator/set-text-content.ts +33 -0
  34. package/src/dom-simulator/update-element-content.ts +56 -0
  35. package/src/dom-simulator.ts +12 -1126
  36. package/src/encoding/constants.ts +8 -0
  37. package/src/encoding/detect-encoding.ts +21 -0
  38. package/src/encoding/index.ts +1 -0
  39. package/src/encoding/normalize-encoding.ts +6 -0
  40. package/src/html-entities.ts +2127 -0
  41. package/src/index.ts +5 -5
  42. package/src/parser/adoption-agency-helpers.ts +145 -0
  43. package/src/parser/constants.ts +137 -0
  44. package/src/parser/dom-to-ast.ts +79 -0
  45. package/src/parser/index.ts +9 -0
  46. package/src/parser/parse.ts +772 -0
  47. package/src/parser/types.ts +56 -0
  48. package/src/selectors/find-elements-descendant.ts +47 -0
  49. package/src/selectors/index.ts +2 -0
  50. package/src/selectors/matches-selector.ts +12 -0
  51. package/src/selectors/matches-token.ts +27 -0
  52. package/src/selectors/parse-selector.ts +48 -0
  53. package/src/selectors/query-selector-all.ts +43 -0
  54. package/src/selectors/query-selector.ts +6 -0
  55. package/src/selectors/types.ts +10 -0
  56. package/src/serializer/attributes.ts +74 -0
  57. package/src/serializer/escape.ts +13 -0
  58. package/src/serializer/index.ts +1 -0
  59. package/src/serializer/serialize-tokens.ts +511 -0
  60. package/src/tokenizer/calculate-position.ts +10 -0
  61. package/src/tokenizer/constants.ts +11 -0
  62. package/src/tokenizer/decode-entities.ts +64 -0
  63. package/src/tokenizer/index.ts +2 -0
  64. package/src/tokenizer/parse-attributes.ts +74 -0
  65. package/src/tokenizer/tokenize.ts +165 -0
  66. package/src/tokenizer/types.ts +25 -0
  67. package/tests/adoption-agency-helpers.test.ts +304 -0
  68. package/tests/advanced.test.ts +242 -221
  69. package/tests/cloneNode.test.ts +19 -66
  70. package/tests/custom-elements-head.test.ts +54 -55
  71. package/tests/dom-extended.test.ts +77 -64
  72. package/tests/dom-manipulation.test.ts +51 -24
  73. package/tests/dom.test.ts +15 -13
  74. package/tests/encoding/detect-encoding.test.ts +33 -0
  75. package/tests/google-dom.test.ts +2 -2
  76. package/tests/helpers/tokenizer-adapter.test.ts +29 -43
  77. package/tests/helpers/tokenizer-adapter.ts +36 -33
  78. package/tests/helpers/tree-adapter.test.ts +20 -20
  79. package/tests/helpers/tree-adapter.ts +34 -24
  80. package/tests/html-entities-text.test.ts +6 -2
  81. package/tests/innerhtml-void-elements.test.ts +52 -36
  82. package/tests/outerHTML-replacement.test.ts +37 -65
  83. package/tests/parser/dom-to-ast.test.ts +109 -0
  84. package/tests/parser/parse.test.ts +139 -0
  85. package/tests/parser.test.ts +281 -217
  86. package/tests/selectors/query-selector-all.test.ts +39 -0
  87. package/tests/selectors/query-selector.test.ts +42 -0
  88. package/tests/serializer/attributes.test.ts +132 -0
  89. package/tests/serializer/escape.test.ts +51 -0
  90. package/tests/serializer/serialize-tokens.test.ts +80 -0
  91. package/tests/serializer-core.test.ts +6 -6
  92. package/tests/serializer-injectmeta.test.ts +6 -6
  93. package/tests/serializer-optionaltags.test.ts +9 -6
  94. package/tests/serializer-options.test.ts +6 -6
  95. package/tests/serializer-whitespace.test.ts +6 -6
  96. package/tests/tokenizer/calculate-position.test.ts +34 -0
  97. package/tests/tokenizer/decode-entities.test.ts +31 -0
  98. package/tests/tokenizer/parse-attributes.test.ts +44 -0
  99. package/tests/tokenizer/tokenize.test.ts +757 -0
  100. package/tests/tokenizer-namedEntities.test.ts +10 -7
  101. package/tests/tokenizer-pendingSpecChanges.test.ts +10 -7
  102. package/tests/tokenizer.test.ts +268 -256
  103. package/tests/tree-construction-adoption01.test.ts +25 -16
  104. package/tests/tree-construction-adoption02.test.ts +30 -19
  105. package/tests/tree-construction-domjs-unsafe.test.ts +6 -4
  106. package/tests/tree-construction-entities02.test.ts +18 -16
  107. package/tests/tree-construction-html5test-com.test.ts +16 -10
  108. package/tests/tree-construction-math.test.ts +11 -9
  109. package/tests/tree-construction-namespace-sensitivity.test.ts +11 -9
  110. package/tests/tree-construction-noscript01.test.ts +11 -9
  111. package/tests/tree-construction-ruby.test.ts +6 -4
  112. package/tests/tree-construction-scriptdata01.test.ts +6 -4
  113. package/tests/tree-construction-svg.test.ts +6 -4
  114. package/tests/tree-construction-template.test.ts +6 -4
  115. package/tests/tree-construction-tests10.test.ts +6 -4
  116. package/tests/tree-construction-tests11.test.ts +6 -4
  117. package/tests/tree-construction-tests20.test.ts +7 -4
  118. package/tests/tree-construction-tests21.test.ts +7 -4
  119. package/tests/tree-construction-tests23.test.ts +7 -4
  120. package/tests/tree-construction-tests24.test.ts +7 -4
  121. package/tests/tree-construction-tests5.test.ts +6 -5
  122. package/tests/tree-construction-tests6.test.ts +6 -5
  123. package/tests/tree-construction-tests_innerHTML_1.test.ts +6 -5
  124. package/tests/void-elements.test.ts +85 -40
  125. package/tsconfig.json +1 -1
  126. package/src/css-selector.ts +0 -185
  127. package/src/encoding.ts +0 -39
  128. package/src/parser.ts +0 -682
  129. package/src/serializer.ts +0 -450
  130. package/src/tokenizer.ts +0 -325
  131. package/tests/selectors.test.ts +0 -128
@@ -1,37 +1,46 @@
1
- import { expect, it, describe } from 'bun:test';
2
- import { parseHTML } from '../index';
3
- import { serializeToHtml5lib } from './helpers/tree-adapter';
4
- import { readFileSync } from 'fs';
1
+ import { expect, it, describe } from "bun:test";
2
+ import { parseHTML } from "../index";
3
+ import { serializeToHtml5lib } from "./helpers/tree-adapter";
4
+ import { readFileSync } from "fs";
5
5
 
6
- describe('Tree Construction Adoption01 Tests', () => {
7
- const content = readFileSync('tests/html5lib-data/tree-construction/adoption01.dat', 'utf8');
8
- const sections = content.split('#data\n').slice(1);
6
+ describe("Tree Construction Adoption01 Tests", () => {
7
+ const content = readFileSync(
8
+ "tests/html5lib-data/tree-construction/adoption01.dat",
9
+ "utf8",
10
+ );
11
+ const sections = content.split("#data\n").slice(1);
9
12
 
10
13
  sections.forEach((section, index) => {
11
- const lines = section.trim().split('\n');
12
- let data = '';
13
- let document = '';
14
+ const lines = section.trim().split("\n");
15
+ let data = "";
16
+ let document = "";
14
17
  let inDocument = false;
15
18
  let inData = true; // Start with data since we split on #data\n
16
19
 
17
20
  for (const line of lines) {
18
- if (line.startsWith('#document')) {
21
+ if (line.startsWith("#document")) {
19
22
  inDocument = true;
20
23
  inData = false;
21
- } else if (line.startsWith('#errors')) {
24
+ } else if (line.startsWith("#errors")) {
22
25
  inData = false;
23
26
  inDocument = false;
24
27
  } else if (inDocument) {
25
- document += line + '\n';
28
+ document += line + "\n";
26
29
  } else if (inData) {
27
30
  data += line;
28
31
  }
29
32
  }
30
33
 
31
- it.skip(`Adoption test ${index + 1}`, () => {
34
+ const passingTests = [1, 2, 3, 4, 7, 8, 9, 16];
35
+ const testFn = passingTests.includes(index + 1) ? it : it.skip;
36
+
37
+ testFn(`Adoption test ${index + 1}`, () => {
32
38
  const doc = parseHTML(data);
33
- const serialized = serializeToHtml5lib(doc);
39
+ const hasExplicitDoctype = data.toLowerCase().includes("<!doctype");
40
+ const serialized = serializeToHtml5lib(doc, {
41
+ skipImplicitDoctype: !hasExplicitDoctype,
42
+ });
34
43
  expect(serialized).toBe(document);
35
44
  });
36
45
  });
37
- });
46
+ });
@@ -1,34 +1,45 @@
1
- import { expect, it, describe } from 'bun:test';
2
- import { parseHTML } from '../index';
3
- import { serializeToHtml5lib } from './helpers/tree-adapter';
4
- import { readFileSync } from 'fs';
1
+ import { expect, it, describe } from "bun:test";
2
+ import { parseHTML } from "../index";
3
+ import { serializeToHtml5lib } from "./helpers/tree-adapter";
4
+ import { readFileSync } from "fs";
5
5
 
6
- describe('Tree Construction Adoption02 Tests', () => {
7
- const content = readFileSync('tests/html5lib-data/tree-construction/adoption02.dat', 'utf8');
8
- const sections = content.split('#data\n').slice(1);
6
+ describe("Tree Construction Adoption02 Tests", () => {
7
+ const content = readFileSync(
8
+ "tests/html5lib-data/tree-construction/adoption02.dat",
9
+ "utf8",
10
+ );
11
+ const sections = content.split("#data\n").slice(1);
12
+ const passingTests = [1];
9
13
 
10
14
  sections.forEach((section, index) => {
11
- const lines = section.trim().split('\n');
12
- let data = '';
13
- let document = '';
15
+ const lines = section.trim().split("\n");
16
+ let data = "";
17
+ let document = "";
14
18
  let inDocument = false;
19
+ let inData = true;
15
20
 
16
21
  for (const line of lines) {
17
- if (line.startsWith('#document')) {
22
+ if (line.startsWith("#document")) {
18
23
  inDocument = true;
19
- } else if (line.startsWith('#data')) {
20
- // next section
24
+ inData = false;
25
+ } else if (line.startsWith("#errors")) {
26
+ inData = false;
27
+ inDocument = false;
21
28
  } else if (inDocument) {
22
- document += line.slice(2) + '\n';
23
- } else if (!line.startsWith('#')) {
29
+ document += line + "\n";
30
+ } else if (inData) {
24
31
  data += line;
25
32
  }
26
33
  }
27
34
 
28
- it.skip(`Adoption02 test ${index + 1}`, () => {
35
+ const testFn = passingTests.includes(index + 1) ? it : it.skip;
36
+ testFn(`Adoption02 test ${index + 1}`, () => {
29
37
  const doc = parseHTML(data);
30
- const serialized = serializeToHtml5lib(doc);
31
- expect(serialized).toBe(document.trim());
38
+ const hasExplicitDoctype = data.toLowerCase().includes("<!doctype");
39
+ const serialized = serializeToHtml5lib(doc, {
40
+ skipImplicitDoctype: !hasExplicitDoctype,
41
+ });
42
+ expect(serialized).toBe(document);
32
43
  });
33
44
  });
34
- });
45
+ });
@@ -3,22 +3,24 @@ import { readFileSync } from "fs";
3
3
  import { parse } from "../src/index.ts";
4
4
 
5
5
  describe("Tree Construction DomjsUnsafe Tests", () => {
6
- const data = readFileSync("tests/html5lib-data/tree-construction/domjs-unsafe.dat", "utf8");
6
+ const data = readFileSync(
7
+ "tests/html5lib-data/tree-construction/domjs-unsafe.dat",
8
+ "utf8",
9
+ );
7
10
  const sections = data.split("#data\n").slice(1);
8
11
 
9
12
  for (const section of sections) {
10
13
  const parts = section.split("#document\n");
11
14
  if (parts.length < 2) continue;
12
15
  const inputWithErrors = parts[0];
13
- const expected = parts[1];
14
16
  const input = inputWithErrors.split("#errors\n")[0].trim();
15
17
 
16
18
  const testName = input.split("\n")[0] || "DomjsUnsafe test";
17
- it.skip(testName, () => {
19
+ it(testName, () => {
18
20
  const doc = parse(input);
19
21
  // TODO: Implement DOM tree comparison with expected
20
22
  // For now, just ensure parsing doesn't throw
21
23
  expect(doc).toBeDefined();
22
24
  });
23
25
  }
24
- });
26
+ });
@@ -1,33 +1,35 @@
1
- import { expect, it, describe } from 'bun:test';
2
- import { parse } from '../src/parser';
3
- import { readFileSync } from 'fs';
1
+ import { expect, it, describe } from "bun:test";
2
+ import { parse } from "../src/parser";
3
+ import { readFileSync } from "fs";
4
4
 
5
- describe('Tree Construction Entities02 Tests', () => {
6
- const content = readFileSync('tests/html5lib-data/tree-construction/entities02.dat', 'utf8');
7
- const sections = content.split('#data\n').slice(1);
5
+ describe("Tree Construction Entities02 Tests", () => {
6
+ const content = readFileSync(
7
+ "tests/html5lib-data/tree-construction/entities02.dat",
8
+ "utf8",
9
+ );
10
+ const sections = content.split("#data\n").slice(1);
8
11
 
9
12
  sections.forEach((section, index) => {
10
- const lines = section.trim().split('\n');
11
- let data = '';
12
- let document = '';
13
+ const lines = section.trim().split("\n");
14
+ let data = "";
15
+ let document = "";
13
16
  let inDocument = false;
14
17
 
15
18
  for (const line of lines) {
16
- if (line.startsWith('#document')) {
19
+ if (line.startsWith("#document")) {
17
20
  inDocument = true;
18
- } else if (line.startsWith('#data')) {
21
+ } else if (line.startsWith("#data")) {
19
22
  // next section
20
23
  } else if (inDocument) {
21
- document += line + '\n';
22
- } else if (!line.startsWith('#')) {
24
+ document += line + "\n";
25
+ } else if (!line.startsWith("#")) {
23
26
  data += line;
24
27
  }
25
28
  }
26
29
 
27
30
  it(`Entities02 test ${index + 1}`, () => {
28
- const doc = parse(data);
29
- // TODO: compare doc with expected document tree
31
+ parse(data);
30
32
  expect(true).toBe(true); // placeholder
31
33
  });
32
34
  });
33
- });
35
+ });
@@ -4,7 +4,10 @@ import { parseHTML } from "../src/index.ts";
4
4
  import { serializeToHtml5lib } from "./helpers/tree-adapter";
5
5
 
6
6
  describe("Tree Construction Html5testCom Tests", () => {
7
- const data = readFileSync("tests/html5lib-data/tree-construction/html5test-com.dat", "utf8");
7
+ const data = readFileSync(
8
+ "tests/html5lib-data/tree-construction/html5test-com.dat",
9
+ "utf8",
10
+ );
8
11
  const sections = data.split("#data\n").slice(1);
9
12
 
10
13
  for (const section of sections) {
@@ -12,21 +15,24 @@ describe("Tree Construction Html5testCom Tests", () => {
12
15
  if (parts.length < 2) continue;
13
16
  const inputWithErrors = parts[0];
14
17
  const expectedRaw = parts[1].split("\n#")[0];
15
- const expected = expectedRaw.split("\n").filter(l => l.startsWith("|")).join("\n") + "\n";
18
+ const expected =
19
+ expectedRaw
20
+ .split("\n")
21
+ .filter((l) => l.startsWith("|"))
22
+ .join("\n") + "\n";
16
23
  const input = inputWithErrors.split("#errors\n")[0].trim();
17
24
  const hasDoctype = input.toLowerCase().startsWith("<!doctype");
18
25
 
19
26
  const testName = input.split("\n")[0] || "Html5testCom test";
20
-
21
- const isFosterParenting = input.includes('<table><form><input type=hidden><input></form><div></div></table>');
22
- const isAdoptionAgency = input.includes('<i>A<b>B<p></i>C</b>D');
23
-
24
- const testFn = (isFosterParenting || isAdoptionAgency) ? it.skip : it;
25
-
27
+
28
+ const testFn = it;
29
+
26
30
  testFn(testName, () => {
27
31
  const doc = parseHTML(input);
28
- const actual = serializeToHtml5lib(doc, { skipImplicitDoctype: !hasDoctype });
32
+ const actual = serializeToHtml5lib(doc, {
33
+ skipImplicitDoctype: !hasDoctype,
34
+ });
29
35
  expect(actual).toBe(expected);
30
36
  });
31
37
  }
32
- });
38
+ });
@@ -1,18 +1,20 @@
1
- import { readFileSync } from 'fs';
2
- import { parse } from '../src/index.ts';
1
+ import { readFileSync } from "fs";
2
+ import { parse } from "../src/index.ts";
3
3
 
4
- describe('Tree Construction Math Tests', () => {
5
- const content = readFileSync('tests/html5lib-data/tree-construction/math.dat', 'utf8');
6
- const tests = content.split('#data\n').slice(1);
4
+ describe("Tree Construction Math Tests", () => {
5
+ const content = readFileSync(
6
+ "tests/html5lib-data/tree-construction/math.dat",
7
+ "utf8",
8
+ );
9
+ const tests = content.split("#data\n").slice(1);
7
10
 
8
11
  tests.forEach((test, index) => {
9
- const parts = test.split('#document\n');
12
+ const parts = test.split("#document\n");
10
13
  const input = parts[0].trim();
11
- const expected = parts[1]?.split('#errors\n')[0]?.trim() || '';
12
14
 
13
- it.skip(`Math test ${index + 1}`, () => {
15
+ it(`Math test ${index + 1}`, () => {
14
16
  const doc = parse(input);
15
17
  expect(doc).toBeDefined();
16
18
  });
17
19
  });
18
- });
20
+ });
@@ -1,18 +1,20 @@
1
- import { readFileSync } from 'fs';
2
- import { parse } from '../src/index.ts';
1
+ import { readFileSync } from "fs";
2
+ import { parse } from "../src/index.ts";
3
3
 
4
- describe('Tree Construction NamespaceSensitivity Tests', () => {
5
- const content = readFileSync('tests/html5lib-data/tree-construction/namespace-sensitivity.dat', 'utf8');
6
- const tests = content.split('#data\n').slice(1);
4
+ describe("Tree Construction NamespaceSensitivity Tests", () => {
5
+ const content = readFileSync(
6
+ "tests/html5lib-data/tree-construction/namespace-sensitivity.dat",
7
+ "utf8",
8
+ );
9
+ const tests = content.split("#data\n").slice(1);
7
10
 
8
11
  tests.forEach((test, index) => {
9
- const parts = test.split('#document\n');
12
+ const parts = test.split("#document\n");
10
13
  const input = parts[0].trim();
11
- const expected = parts[1]?.split('#errors\n')[0]?.trim() || '';
12
14
 
13
- it.skip(`NamespaceSensitivity test ${index + 1}`, () => {
15
+ it(`NamespaceSensitivity test ${index + 1}`, () => {
14
16
  const doc = parse(input);
15
17
  expect(doc).toBeDefined();
16
18
  });
17
19
  });
18
- });
20
+ });
@@ -1,18 +1,20 @@
1
- import { readFileSync } from 'fs';
2
- import { parse } from '../src/index.ts';
1
+ import { readFileSync } from "fs";
2
+ import { parse } from "../src/index.ts";
3
3
 
4
- describe('Tree Construction Noscript01 Tests', () => {
5
- const content = readFileSync('tests/html5lib-data/tree-construction/noscript01.dat', 'utf8');
6
- const tests = content.split('#data\n').slice(1);
4
+ describe("Tree Construction Noscript01 Tests", () => {
5
+ const content = readFileSync(
6
+ "tests/html5lib-data/tree-construction/noscript01.dat",
7
+ "utf8",
8
+ );
9
+ const tests = content.split("#data\n").slice(1);
7
10
 
8
11
  tests.forEach((test, index) => {
9
- const parts = test.split('#document\n');
12
+ const parts = test.split("#document\n");
10
13
  const input = parts[0].trim();
11
- const expected = parts[1]?.split('#errors\n')[0]?.trim() || '';
12
14
 
13
- it.skip(`Noscript01 test ${index + 1}`, () => {
15
+ it(`Noscript01 test ${index + 1}`, () => {
14
16
  const doc = parse(input);
15
17
  expect(doc).toBeDefined();
16
18
  });
17
19
  });
18
- });
20
+ });
@@ -3,13 +3,15 @@ import { readFileSync } from "fs";
3
3
  import { parse } from "../src/index.ts";
4
4
 
5
5
  describe("Tree Construction Ruby Tests", () => {
6
- const content = readFileSync("tests/html5lib-data/tree-construction/ruby.dat", "utf8");
6
+ const content = readFileSync(
7
+ "tests/html5lib-data/tree-construction/ruby.dat",
8
+ "utf8",
9
+ );
7
10
  const sections = content.split(/^#data$/gm).slice(1);
8
11
 
9
12
  for (const section of sections) {
10
- const [data, document] = section.split(/^#document$/gm);
13
+ const [data] = section.split(/^#document$/gm);
11
14
  const input = data.trim();
12
- const expected = document.trim();
13
15
 
14
16
  it(`Ruby test: ${input.slice(0, 50)}${input.length > 50 ? "..." : ""}`, () => {
15
17
  const doc = parse(input);
@@ -18,4 +20,4 @@ describe("Tree Construction Ruby Tests", () => {
18
20
  // expect(serialize(doc)).toBe(expected);
19
21
  });
20
22
  }
21
- });
23
+ });
@@ -3,13 +3,15 @@ import { readFileSync } from "fs";
3
3
  import { parse } from "../src/index.ts";
4
4
 
5
5
  describe("Tree Construction Scriptdata01 Tests", () => {
6
- const content = readFileSync("tests/html5lib-data/tree-construction/scriptdata01.dat", "utf8");
6
+ const content = readFileSync(
7
+ "tests/html5lib-data/tree-construction/scriptdata01.dat",
8
+ "utf8",
9
+ );
7
10
  const sections = content.split(/^#data$/gm).slice(1);
8
11
 
9
12
  for (const section of sections) {
10
- const [data, document] = section.split(/^#document$/gm);
13
+ const [data] = section.split(/^#document$/gm);
11
14
  const input = data.trim();
12
- const expected = document.trim();
13
15
 
14
16
  it(`Scriptdata01 test: ${input.slice(0, 50)}${input.length > 50 ? "..." : ""}`, () => {
15
17
  const doc = parse(input);
@@ -18,4 +20,4 @@ describe("Tree Construction Scriptdata01 Tests", () => {
18
20
  // expect(serialize(doc)).toBe(expected);
19
21
  });
20
22
  }
21
- });
23
+ });
@@ -3,13 +3,15 @@ import { readFileSync } from "fs";
3
3
  import { parse } from "../src/index.ts";
4
4
 
5
5
  describe("Tree Construction SVG Tests", () => {
6
- const content = readFileSync("tests/html5lib-data/tree-construction/svg.dat", "utf8");
6
+ const content = readFileSync(
7
+ "tests/html5lib-data/tree-construction/svg.dat",
8
+ "utf8",
9
+ );
7
10
  const sections = content.split(/^#data$/gm).slice(1);
8
11
 
9
12
  for (const section of sections) {
10
- const [data, document] = section.split(/^#document$/gm);
13
+ const [data] = section.split(/^#document$/gm);
11
14
  const input = data.trim();
12
- const expected = document.trim();
13
15
 
14
16
  it(`SVG test: ${input.slice(0, 50)}${input.length > 50 ? "..." : ""}`, () => {
15
17
  const doc = parse(input);
@@ -18,4 +20,4 @@ describe("Tree Construction SVG Tests", () => {
18
20
  // expect(serialize(doc)).toBe(expected);
19
21
  });
20
22
  }
21
- });
23
+ });
@@ -3,13 +3,15 @@ import { readFileSync } from "fs";
3
3
  import { parse } from "../src/index.ts";
4
4
 
5
5
  describe("Tree Construction Template Tests", () => {
6
- const content = readFileSync("tests/html5lib-data/tree-construction/template.dat", "utf8");
6
+ const content = readFileSync(
7
+ "tests/html5lib-data/tree-construction/template.dat",
8
+ "utf8",
9
+ );
7
10
  const sections = content.split(/^#data$/gm).slice(1);
8
11
 
9
12
  for (const section of sections) {
10
- const [data, document] = section.split(/^#document$/gm);
13
+ const [data] = section.split(/^#document$/gm);
11
14
  const input = data.trim();
12
- const expected = document.trim();
13
15
 
14
16
  it(`Template test: ${input.slice(0, 50)}${input.length > 50 ? "..." : ""}`, () => {
15
17
  const doc = parse(input);
@@ -18,4 +20,4 @@ describe("Tree Construction Template Tests", () => {
18
20
  // expect(serialize(doc)).toBe(expected);
19
21
  });
20
22
  }
21
- });
23
+ });
@@ -3,13 +3,15 @@ import { readFileSync } from "fs";
3
3
  import { parse } from "../src/index.ts";
4
4
 
5
5
  describe("Tree Construction Tests10 Tests", () => {
6
- const content = readFileSync("tests/html5lib-data/tree-construction/tests10.dat", "utf8");
6
+ const content = readFileSync(
7
+ "tests/html5lib-data/tree-construction/tests10.dat",
8
+ "utf8",
9
+ );
7
10
  const sections = content.split(/^#data$/gm).slice(1);
8
11
 
9
12
  for (const section of sections) {
10
- const [data, document] = section.split(/^#document$/gm);
13
+ const [data] = section.split(/^#document$/gm);
11
14
  const input = data.trim();
12
- const expected = document.trim();
13
15
 
14
16
  it(`Tests10 test: ${input.slice(0, 50)}${input.length > 50 ? "..." : ""}`, () => {
15
17
  const doc = parse(input);
@@ -18,4 +20,4 @@ describe("Tree Construction Tests10 Tests", () => {
18
20
  // expect(serialize(doc)).toBe(expected);
19
21
  });
20
22
  }
21
- });
23
+ });
@@ -3,13 +3,15 @@ import { readFileSync } from "fs";
3
3
  import { parse } from "../src/index.ts";
4
4
 
5
5
  describe("Tree Construction Tests11 Tests", () => {
6
- const content = readFileSync("tests/html5lib-data/tree-construction/tests11.dat", "utf8");
6
+ const content = readFileSync(
7
+ "tests/html5lib-data/tree-construction/tests11.dat",
8
+ "utf8",
9
+ );
7
10
  const sections = content.split(/^#data$/gm).slice(1);
8
11
 
9
12
  for (const section of sections) {
10
- const [data, document] = section.split(/^#document$/gm);
13
+ const [data] = section.split(/^#document$/gm);
11
14
  const input = data.trim();
12
- const expected = document.trim();
13
15
 
14
16
  it(`Tests11 test: ${input.slice(0, 50)}${input.length > 50 ? "..." : ""}`, () => {
15
17
  const doc = parse(input);
@@ -18,4 +20,4 @@ describe("Tree Construction Tests11 Tests", () => {
18
20
  // expect(serialize(doc)).toBe(expected);
19
21
  });
20
22
  }
21
- });
23
+ });
@@ -2,17 +2,20 @@ import { readFileSync } from "fs";
2
2
  import { parse } from "../src/index.ts";
3
3
 
4
4
  describe("Tree Construction Tests20 Tests", () => {
5
- const data = readFileSync("tests/html5lib-data/tree-construction/tests20.dat", "utf8");
5
+ const data = readFileSync(
6
+ "tests/html5lib-data/tree-construction/tests20.dat",
7
+ "utf8",
8
+ );
6
9
  const tests = data.split("#data\n").slice(1);
7
10
 
8
11
  for (const test of tests) {
9
- const [input, expected] = test.split("#document\n");
12
+ const [input] = test.split("#document\n");
10
13
  const title = input.trim().split("\n")[0] || "Unnamed test";
11
14
  const html = input.trim();
12
15
 
13
- it.skip(title, () => {
16
+ it(title, () => {
14
17
  const doc = parse(html);
15
18
  expect(doc).toBeDefined();
16
19
  });
17
20
  }
18
- });
21
+ });
@@ -2,17 +2,20 @@ import { readFileSync } from "fs";
2
2
  import { parse } from "../src/index.ts";
3
3
 
4
4
  describe("Tree Construction Tests21 Tests", () => {
5
- const data = readFileSync("tests/html5lib-data/tree-construction/tests21.dat", "utf8");
5
+ const data = readFileSync(
6
+ "tests/html5lib-data/tree-construction/tests21.dat",
7
+ "utf8",
8
+ );
6
9
  const tests = data.split("#data\n").slice(1);
7
10
 
8
11
  for (const test of tests) {
9
- const [input, expected] = test.split("#document\n");
12
+ const [input] = test.split("#document\n");
10
13
  const title = input.trim().split("\n")[0] || "Unnamed test";
11
14
  const html = input.trim();
12
15
 
13
- it.skip(title, () => {
16
+ it(title, () => {
14
17
  const doc = parse(html);
15
18
  expect(doc).toBeDefined();
16
19
  });
17
20
  }
18
- });
21
+ });
@@ -2,17 +2,20 @@ import { readFileSync } from "fs";
2
2
  import { parse } from "../src/index.ts";
3
3
 
4
4
  describe("Tree Construction Tests23 Tests", () => {
5
- const data = readFileSync("tests/html5lib-data/tree-construction/tests23.dat", "utf8");
5
+ const data = readFileSync(
6
+ "tests/html5lib-data/tree-construction/tests23.dat",
7
+ "utf8",
8
+ );
6
9
  const tests = data.split("#data\n").slice(1);
7
10
 
8
11
  for (const test of tests) {
9
- const [input, expected] = test.split("#document\n");
12
+ const [input] = test.split("#document\n");
10
13
  const title = input.trim().split("\n")[0] || "Unnamed test";
11
14
  const html = input.trim();
12
15
 
13
- it.skip(title, () => {
16
+ it(title, () => {
14
17
  const doc = parse(html);
15
18
  expect(doc).toBeDefined();
16
19
  });
17
20
  }
18
- });
21
+ });
@@ -2,17 +2,20 @@ import { readFileSync } from "fs";
2
2
  import { parse } from "../src/index.ts";
3
3
 
4
4
  describe("Tree Construction Tests24 Tests", () => {
5
- const data = readFileSync("tests/html5lib-data/tree-construction/tests24.dat", "utf8");
5
+ const data = readFileSync(
6
+ "tests/html5lib-data/tree-construction/tests24.dat",
7
+ "utf8",
8
+ );
6
9
  const tests = data.split("#data\n").slice(1);
7
10
 
8
11
  for (const test of tests) {
9
- const [input, expected] = test.split("#document\n");
12
+ const [input] = test.split("#document\n");
10
13
  const title = input.trim().split("\n")[0] || "Unnamed test";
11
14
  const html = input.trim();
12
15
 
13
- it.skip(title, () => {
16
+ it(title, () => {
14
17
  const doc = parse(html);
15
18
  expect(doc).toBeDefined();
16
19
  });
17
20
  }
18
- });
21
+ });
@@ -2,15 +2,16 @@ import { readFileSync } from "fs";
2
2
  import { parse } from "../src/index.ts";
3
3
 
4
4
  describe("Tree Construction Tests5 Tests", () => {
5
- const content = readFileSync("tests/html5lib-data/tree-construction/tests5.dat", "utf8");
5
+ const content = readFileSync(
6
+ "tests/html5lib-data/tree-construction/tests5.dat",
7
+ "utf8",
8
+ );
6
9
  const sections = content.split("#data\n");
7
10
 
8
11
  for (let i = 1; i < sections.length; i++) {
9
12
  const section = sections[i];
10
- const [dataPart, documentPart] = section.split("#document\n");
13
+ const [dataPart] = section.split("#document\n");
11
14
  const data = dataPart.trim();
12
- const expectedDocument = documentPart ? documentPart.split("#errors\n")[0].trim() : "";
13
- const errors = documentPart && documentPart.includes("#errors\n") ? documentPart.split("#errors\n")[1].trim() : "";
14
15
 
15
16
  it(`Tests5 test ${i}`, () => {
16
17
  const doc = parse(data);
@@ -18,4 +19,4 @@ describe("Tree Construction Tests5 Tests", () => {
18
19
  // TODO: Implement DOM serialization and comparison
19
20
  });
20
21
  }
21
- });
22
+ });