-9
test/adoption_test.ml
-9
test/adoption_test.ml
···
1
-
open Bytesrw
2
-
3
-
module Parser = Html5rw_parser
4
-
5
-
let () =
6
-
print_endline "=== Test: <a><svg><tr><input></a> ===";
7
-
let result = Parser.parse (Bytes.Reader.of_string "<a><svg><tr><input></a>") in
8
-
print_endline (Html5rw_dom.to_test_format (Parser.root result));
9
-
print_newline ()
-12
test/debug2.ml
-12
test/debug2.ml
···
1
-
open Bytesrw
2
-
3
-
module Parser = Html5rw_parser
4
-
module Dom = Html5rw_dom
5
-
6
-
let () =
7
-
(* Test adoption agency *)
8
-
let input = "<p><b>One<p>Two" in
9
-
let result = Parser.parse ~collect_errors:true (Bytes.Reader.of_string input) in
10
-
print_endline ("Input: " ^ input);
11
-
print_endline "Result:";
12
-
print_endline (Dom.to_test_format (Parser.root result))
-12
test/debug_fragment.ml
-12
test/debug_fragment.ml
···
1
-
open Bytesrw
2
-
3
-
module Parser = Html5rw_parser
4
-
module Dom = Html5rw_dom
5
-
6
-
let () =
7
-
(* Simple table test *)
8
-
let input = "<table><th>" in
9
-
let result = Parser.parse ~collect_errors:true (Bytes.Reader.of_string input) in
10
-
print_endline ("Input: " ^ input);
11
-
print_endline "Result:";
12
-
print_endline (Dom.to_test_format (Parser.root result))
-28
test/debug_svg.ml
-28
test/debug_svg.ml
···
1
-
open Bytesrw
2
-
3
-
module Parser = Html5rw_parser
4
-
module Dom = Html5rw_dom
5
-
6
-
let rec print_tree depth node =
7
-
let indent = String.make (depth * 2) ' ' in
8
-
Printf.printf "%s%s (ns=%s)\n" indent node.Dom.name
9
-
(match node.Dom.namespace with Some ns -> ns | None -> "html");
10
-
List.iter (print_tree (depth + 1)) node.Dom.children
11
-
12
-
let () =
13
-
(* SVG fragment test *)
14
-
let input = "<svg><tr><td><title><tr>" in
15
-
let context = Parser.make_fragment_context ~tag_name:"td" () in
16
-
let result = Parser.parse ~collect_errors:true ~fragment_context:context (Bytes.Reader.of_string input) in
17
-
print_endline ("Input: " ^ input);
18
-
print_endline "Tree structure:";
19
-
print_tree 0 (Parser.root result);
20
-
print_endline "";
21
-
print_endline "Result:";
22
-
print_endline (Dom.to_test_format (Parser.root result));
23
-
print_endline "";
24
-
print_endline "Expected:";
25
-
print_endline "| <svg svg>";
26
-
print_endline "| <svg tr>";
27
-
print_endline "| <svg td>";
28
-
print_endline "| <svg title>"
-20
test/debug_title.ml
-20
test/debug_title.ml
···
1
-
open Bytesrw
2
-
3
-
module Parser = Html5rw_parser
4
-
module Dom = Html5rw_dom
5
-
6
-
let () =
7
-
let input = "<!doctype html><title> <!-- </title>--> x" in
8
-
let result = Parser.parse ~collect_errors:true (Bytes.Reader.of_string input) in
9
-
print_endline ("Input: " ^ input);
10
-
print_endline "Result:";
11
-
print_endline (Dom.to_test_format (Parser.root result));
12
-
print_endline "";
13
-
print_endline "Expected:";
14
-
print_endline "| <!DOCTYPE html>";
15
-
print_endline "| <html>";
16
-
print_endline "| <head>";
17
-
print_endline "| <title>";
18
-
print_endline "| \" <!-- \"";
19
-
print_endline "| <body>";
20
-
print_endline "| \"--> x\""
-90
test/dune
-90
test/dune
···
41
41
(glob_files ../html5lib-tests/serializer/*.test))
42
42
(action
43
43
(run %{exe:test_serializer.exe} ../html5lib-tests/serializer)))
44
-
45
-
(executable
46
-
(name debug_fragment)
47
-
(libraries bytesrw html5rw.parser html5rw.dom))
48
-
49
-
(executable
50
-
(name debug_svg)
51
-
(libraries bytesrw html5rw.parser html5rw.dom))
52
-
53
-
(executable
54
-
(name test_table)
55
-
(libraries bytesrw html5rw.parser html5rw.dom))
56
-
57
-
(executable
58
-
(name test_debug)
59
-
(libraries bytesrw html5rw.parser html5rw.dom))
60
-
61
-
(executable
62
-
(name test_frameset)
63
-
(libraries bytesrw html5rw.parser html5rw.dom))
64
-
65
-
(executable
66
-
(name test_whitespace)
67
-
(libraries bytesrw html5rw.parser html5rw.dom))
68
-
69
-
(executable
70
-
(name test_mi)
71
-
(libraries bytesrw html5rw.parser html5rw.dom))
72
-
73
-
(executable
74
-
(name test_table_svg)
75
-
(libraries bytesrw html5rw.parser html5rw.dom))
76
-
(executable
77
-
(name quick_test)
78
-
(libraries bytesrw html5rw.parser html5rw.dom))
79
-
(executable
80
-
(name simple_test)
81
-
(libraries bytesrw html5rw.parser html5rw.dom))
82
-
(executable
83
-
(name html_frag_test)
84
-
(libraries bytesrw html5rw.parser html5rw.dom))
85
-
(executable
86
-
(name svg_frag_test)
87
-
(libraries bytesrw html5rw.parser html5rw.dom))
88
-
(executable
89
-
(name nobr_test)
90
-
(libraries bytesrw html5rw.parser html5rw.dom))
91
-
(executable
92
-
(name nobr_debug)
93
-
(libraries bytesrw html5rw.parser html5rw.dom))
94
-
(executable
95
-
(name select_debug)
96
-
(libraries bytesrw html5rw.parser html5rw.dom))
97
-
(executable
98
-
(name template_debug)
99
-
(libraries bytesrw html5rw.parser html5rw.dom))
100
-
(executable
101
-
(name template_debug2)
102
-
(libraries bytesrw html5rw.parser html5rw.dom))
103
-
(executable
104
-
(name script_eof_test)
105
-
(libraries bytesrw html5rw.parser html5rw.dom))
106
-
(executable
107
-
(name entity_test)
108
-
(libraries bytesrw html5rw.parser html5rw.dom))
109
-
(executable
110
-
(name entity_dup_test)
111
-
(libraries bytesrw html5rw.parser html5rw.dom))
112
-
(executable
113
-
(name script_attr_test)
114
-
(libraries bytesrw html5rw.parser html5rw.dom))
115
-
116
-
(executable
117
-
(name frag_debug)
118
-
(libraries bytesrw html5rw.parser html5rw.dom))
119
-
120
-
(executable
121
-
(name frag_debug2)
122
-
(libraries bytesrw html5rw.parser html5rw.dom))
123
-
124
-
(executable
125
-
(name frag_debug3)
126
-
(libraries bytesrw html5rw.parser html5rw.dom))
127
-
(executable (name adoption_test) (libraries bytesrw html5rw.parser html5rw.dom))
128
-
(executable (name template_debug3) (libraries bytesrw html5rw.parser html5rw.dom))
129
-
(executable (name template_debug4) (libraries bytesrw html5rw.parser html5rw.dom))
130
-
(executable (name ns_sens_test) (libraries bytesrw html5rw.parser html5rw.dom))
131
-
(executable (name debug2) (libraries bytesrw html5rw.parser html5rw.dom))
132
-
(executable (name debug_title) (libraries bytesrw html5rw.parser html5rw.dom))
133
-
(executable (name nobr_debug2) (libraries bytesrw html5rw.parser html5rw.dom))
-20
test/entity_dup_test.ml
-20
test/entity_dup_test.ml
···
1
-
open Bytesrw
2
-
3
-
module Parser = Html5rw_parser
4
-
module Dom = Html5rw_dom
5
-
6
-
let () =
7
-
print_endline "=== Test: &AMp; ===";
8
-
let input = "&AMp;" in
9
-
print_endline ("Input: " ^ input);
10
-
let result = Parser.parse ~collect_errors:true (Bytes.Reader.of_string input) in
11
-
print_endline "Result:";
12
-
print_endline (Dom.to_test_format (Parser.root result));
13
-
print_endline "";
14
-
15
-
print_endline "=== Test: & ===";
16
-
let input = "&" in
17
-
print_endline ("Input: " ^ input);
18
-
let result = Parser.parse ~collect_errors:true (Bytes.Reader.of_string input) in
19
-
print_endline "Result:";
20
-
print_endline (Dom.to_test_format (Parser.root result))
-28
test/entity_test.ml
-28
test/entity_test.ml
···
1
-
open Bytesrw
2
-
3
-
module Parser = Html5rw_parser
4
-
module Dom = Html5rw_dom
5
-
6
-
let () =
7
-
print_endline "=== Test 1: Single & ===";
8
-
let input = "&" in
9
-
print_endline ("Input: " ^ input);
10
-
let result = Parser.parse ~collect_errors:true (Bytes.Reader.of_string input) in
11
-
print_endline "Result:";
12
-
print_endline (Dom.to_test_format (Parser.root result));
13
-
print_endline "";
14
-
15
-
print_endline "=== Test 2: - (decimal ref) ===";
16
-
let input = "-" in
17
-
print_endline ("Input: " ^ input);
18
-
let result = Parser.parse ~collect_errors:true (Bytes.Reader.of_string input) in
19
-
print_endline "Result:";
20
-
print_endline (Dom.to_test_format (Parser.root result));
21
-
print_endline "";
22
-
23
-
print_endline "=== Test 3: &#X (hex ref incomplete) ===";
24
-
let input = "&#X" in
25
-
print_endline ("Input: " ^ input);
26
-
let result = Parser.parse ~collect_errors:true (Bytes.Reader.of_string input) in
27
-
print_endline "Result:";
28
-
print_endline (Dom.to_test_format (Parser.root result))
-39
test/frag_debug.ml
-39
test/frag_debug.ml
···
1
-
open Bytesrw
2
-
3
-
module Parser = Html5rw_parser
4
-
5
-
let () =
6
-
(* Test 77 - template with adoption agency *)
7
-
print_endline "=== Template test 77 ===";
8
-
print_endline "Input: <body><template><i><menu>Foo</i>";
9
-
let result = Html5rw_parser.parse (Bytes.Reader.of_string "<body><template><i><menu>Foo</i>") in
10
-
print_endline "Actual:";
11
-
print_endline (Html5rw_dom.to_test_format (Parser.root result));
12
-
print_newline ();
13
-
14
-
(* Simpler test - just template with content *)
15
-
print_endline "=== Simpler template test ===";
16
-
print_endline "Input: <template><i>X</i></template>";
17
-
let result = Html5rw_parser.parse (Bytes.Reader.of_string "<template><i>X</i></template>") in
18
-
print_endline (Html5rw_dom.to_test_format (Parser.root result));
19
-
print_newline ();
20
-
21
-
(* Test without template *)
22
-
print_endline "=== Without template ===";
23
-
print_endline "Input: <i><menu>Foo</i>";
24
-
let result = Html5rw_parser.parse (Bytes.Reader.of_string "<i><menu>Foo</i>") in
25
-
print_endline (Html5rw_dom.to_test_format (Parser.root result));
26
-
print_newline ();
27
-
28
-
(* Test 31 - foreignObject/math *)
29
-
print_endline "=== Test 31 - foreignObject ===";
30
-
print_endline "Input: <div><svg><path><foreignObject><math></div>a";
31
-
let result = Html5rw_parser.parse (Bytes.Reader.of_string "<div><svg><path><foreignObject><math></div>a") in
32
-
print_endline (Html5rw_dom.to_test_format (Parser.root result));
33
-
print_newline ();
34
-
35
-
(* namespace-sensitivity test *)
36
-
print_endline "=== Namespace sensitivity ===";
37
-
print_endline "Input: <body><table><tr><td><svg><td><foreignObject><span></td>Foo";
38
-
let result = Html5rw_parser.parse (Bytes.Reader.of_string "<body><table><tr><td><svg><td><foreignObject><span></td>Foo") in
39
-
print_endline (Html5rw_dom.to_test_format (Parser.root result))
-40
test/frag_debug2.ml
-40
test/frag_debug2.ml
···
1
-
open Bytesrw
2
-
3
-
module Parser = Html5rw_parser
4
-
5
-
let () =
6
-
(* Test: svg end tag handling *)
7
-
print_endline "=== Test: <div><svg></div> ===";
8
-
let result = Html5rw_parser.parse (Bytes.Reader.of_string "<div><svg></div>") in
9
-
print_endline (Html5rw_dom.to_test_format (Parser.root result));
10
-
print_newline ();
11
-
12
-
(* Test: foreignObject text integration *)
13
-
print_endline "=== Test: <div><svg><foreignObject></div> ===";
14
-
let result = Html5rw_parser.parse (Bytes.Reader.of_string "<div><svg><foreignObject></div>") in
15
-
print_endline (Html5rw_dom.to_test_format (Parser.root result));
16
-
print_newline ();
17
-
18
-
(* Test: math inside foreignObject with end tag *)
19
-
print_endline "=== Test: <div><svg><foreignObject><math></div>a ===";
20
-
let result = Html5rw_parser.parse (Bytes.Reader.of_string "<div><svg><foreignObject><math></div>a") in
21
-
print_endline (Html5rw_dom.to_test_format (Parser.root result));
22
-
print_newline ();
23
-
24
-
(* Without path element *)
25
-
print_endline "=== Test: <div><svg><foreignObject><b></div>text ===";
26
-
let result = Html5rw_parser.parse (Bytes.Reader.of_string "<div><svg><foreignObject><b></div>text") in
27
-
print_endline (Html5rw_dom.to_test_format (Parser.root result));
28
-
print_newline ();
29
-
30
-
(* Template adoption agency test *)
31
-
print_endline "=== Test: <template><b><menu>text</b> ===";
32
-
let result = Html5rw_parser.parse (Bytes.Reader.of_string "<template><b><menu>text</b>") in
33
-
print_endline (Html5rw_dom.to_test_format (Parser.root result));
34
-
print_newline ();
35
-
36
-
(* Without template for comparison *)
37
-
print_endline "=== Test: <b><menu>text</b> (no template) ===";
38
-
let result = Html5rw_parser.parse (Bytes.Reader.of_string "<b><menu>text</b>") in
39
-
print_endline (Html5rw_dom.to_test_format (Parser.root result));
40
-
print_newline ()
-34
test/frag_debug3.ml
-34
test/frag_debug3.ml
···
1
-
open Bytesrw
2
-
3
-
module Parser = Html5rw_parser
4
-
5
-
let () =
6
-
(* Simple svg with child *)
7
-
print_endline "=== Test: <svg><path></path></svg>text ===";
8
-
let result = Html5rw_parser.parse (Bytes.Reader.of_string "<svg><path></path></svg>text") in
9
-
print_endline (Html5rw_dom.to_test_format (Parser.root result));
10
-
print_newline ();
11
-
12
-
(* The failing test - foreignObject inside svg *)
13
-
print_endline "=== Test: <div><svg><path><foreignObject><math></div>a ===";
14
-
let result = Html5rw_parser.parse (Bytes.Reader.of_string "<div><svg><path><foreignObject><math></div>a") in
15
-
print_endline (Html5rw_dom.to_test_format (Parser.root result));
16
-
print_newline ();
17
-
18
-
(* Expected output for test 31:
19
-
<html>
20
-
<head>
21
-
<body>
22
-
<div>
23
-
<svg svg>
24
-
<svg path>
25
-
<svg foreignObject>
26
-
<math math>
27
-
"a"
28
-
*)
29
-
30
-
(* Simple svg structure *)
31
-
print_endline "=== Test: <svg><rect/><circle/></svg> ===";
32
-
let result = Html5rw_parser.parse (Bytes.Reader.of_string "<svg><rect/><circle/></svg>") in
33
-
print_endline (Html5rw_dom.to_test_format (Parser.root result));
34
-
print_newline ()
-10
test/html_frag_test.ml
-10
test/html_frag_test.ml
···
1
-
open Bytesrw
2
-
3
-
module Parser = Html5rw_parser
4
-
module Dom = Html5rw_dom
5
-
6
-
let () =
7
-
let input = "Hello" in
8
-
let context = Parser.make_fragment_context ~tag_name:"div" () in
9
-
let result = Parser.parse ~collect_errors:true ~fragment_context:context (Bytes.Reader.of_string input) in
10
-
print_endline (Dom.to_test_format (Parser.root result))
-22
test/nobr_debug.ml
-22
test/nobr_debug.ml
···
1
-
open Bytesrw
2
-
3
-
module Parser = Html5rw_parser
4
-
module Dom = Html5rw_dom
5
-
6
-
let rec print_tree indent node =
7
-
Printf.printf "%s%s (ns=%s, %d children)\n"
8
-
indent
9
-
node.Dom.name
10
-
(match node.Dom.namespace with Some s -> s | None -> "html")
11
-
(List.length node.Dom.children);
12
-
List.iter (print_tree (indent ^ " ")) node.Dom.children
13
-
14
-
let () =
15
-
let input = "<nobr>X" in
16
-
print_endline "Starting...";
17
-
let context = Parser.make_fragment_context ~tag_name:"path" ~namespace:(Some "svg") () in
18
-
let result = Parser.parse ~collect_errors:true ~fragment_context:context (Bytes.Reader.of_string input) in
19
-
print_endline "\nFinal tree structure:";
20
-
print_tree "" (Parser.root result);
21
-
print_endline "\nTest format:";
22
-
print_endline (Dom.to_test_format (Parser.root result))
-29
test/nobr_debug2.ml
-29
test/nobr_debug2.ml
···
1
-
(*---------------------------------------------------------------------------
2
-
Copyright (c) 2025 Anil Madhavapeddy <anil@recoil.org>. All rights reserved.
3
-
SPDX-License-Identifier: MIT
4
-
---------------------------------------------------------------------------*)
5
-
6
-
(* Test nobr element handling in SVG fragment context *)
7
-
8
-
open Bytesrw
9
-
10
-
module Parser = Html5rw_parser
11
-
module Dom = Html5rw_dom
12
-
13
-
let rec print_tree indent node =
14
-
Printf.printf "%s%s (ns=%s, %d children)\n"
15
-
indent
16
-
node.Dom.name
17
-
(match node.Dom.namespace with Some s -> s | None -> "html")
18
-
(List.length node.Dom.children);
19
-
List.iter (print_tree (indent ^ " ")) node.Dom.children
20
-
21
-
let () =
22
-
let input = "<nobr>X" in
23
-
print_endline "Starting...";
24
-
let context = Parser.make_fragment_context ~tag_name:"path" ~namespace:(Some "svg") () in
25
-
let result = Parser.parse ~collect_errors:true ~fragment_context:context (Bytes.Reader.of_string input) in
26
-
print_endline "\nFinal tree structure:";
27
-
print_tree "" (Parser.root result);
28
-
print_endline "\nTest format:";
29
-
print_endline (Dom.to_test_format (Parser.root result))
-13
test/nobr_test.ml
-13
test/nobr_test.ml
···
1
-
open Bytesrw
2
-
3
-
module Parser = Html5rw_parser
4
-
module Dom = Html5rw_dom
5
-
6
-
let () =
7
-
let input = "<nobr>X" in
8
-
print_endline "Starting...";
9
-
let context = Parser.make_fragment_context ~tag_name:"path" ~namespace:(Some "svg") () in
10
-
print_endline "Created context";
11
-
let result = Parser.parse ~collect_errors:true ~fragment_context:context (Bytes.Reader.of_string input) in
12
-
print_endline "Parsed";
13
-
print_endline (Dom.to_test_format (Parser.root result))
-35
test/ns_sens_test.ml
-35
test/ns_sens_test.ml
···
1
-
open Bytesrw
2
-
3
-
module Parser = Html5rw_parser
4
-
5
-
let () =
6
-
print_endline "=== Test: <body><table><tr><td><svg><td><foreignObject><span></td>Foo ===";
7
-
let result = Html5rw_parser.parse (Bytes.Reader.of_string "<body><table><tr><td><svg><td><foreignObject><span></td>Foo") in
8
-
print_endline (Html5rw_dom.to_test_format (Parser.root result));
9
-
print_newline ();
10
-
11
-
(* Expected:
12
-
<html>
13
-
<head>
14
-
<body>
15
-
"Foo"
16
-
<table>
17
-
<tbody>
18
-
<tr>
19
-
<td>
20
-
<svg svg>
21
-
<svg td>
22
-
<svg foreignObject>
23
-
<span>
24
-
*)
25
-
26
-
(* Let's also test simpler case *)
27
-
print_endline "=== Test: <table><td><svg><foreignObject></td>text ===";
28
-
let result = Html5rw_parser.parse (Bytes.Reader.of_string "<table><td><svg><foreignObject></td>text") in
29
-
print_endline (Html5rw_dom.to_test_format (Parser.root result));
30
-
print_newline ();
31
-
32
-
print_endline "=== Test: <table><td></td>text ===";
33
-
let result = Html5rw_parser.parse (Bytes.Reader.of_string "<table><td></td>text") in
34
-
print_endline (Html5rw_dom.to_test_format (Parser.root result));
35
-
print_newline ()
-10
test/quick_test.ml
-10
test/quick_test.ml
···
1
-
open Bytesrw
2
-
3
-
module Parser = Html5rw_parser
4
-
module Dom = Html5rw_dom
5
-
6
-
let () =
7
-
let input = "<nobr>X" in
8
-
let context = Parser.make_fragment_context ~tag_name:"path" ~namespace:(Some "svg") () in
9
-
let result = Parser.parse ~collect_errors:true ~fragment_context:context (Bytes.Reader.of_string input) in
10
-
print_endline (Dom.to_test_format (Parser.root result))
-22
test/script_attr_test.ml
-22
test/script_attr_test.ml
···
1
-
open Bytesrw
2
-
3
-
module Parser = Html5rw_parser
4
-
module Dom = Html5rw_dom
5
-
6
-
let () =
7
-
(* Test incomplete script tag with attribute *)
8
-
let input = "<!doctypehtml><scrIPt type=text/x-foobar;baz>X</SCRipt" in
9
-
print_endline "=== Test: script tag with attribute at incomplete end ===";
10
-
print_endline ("Input: " ^ input);
11
-
let result = Parser.parse ~collect_errors:true (Bytes.Reader.of_string input) in
12
-
print_endline "Result:";
13
-
print_endline (Dom.to_test_format (Parser.root result));
14
-
print_endline "";
15
-
16
-
(* Test simpler case *)
17
-
let input = "<script type=text>X</script>" in
18
-
print_endline "=== Test: Complete script tag with attribute ===";
19
-
print_endline ("Input: " ^ input);
20
-
let result = Parser.parse ~collect_errors:true (Bytes.Reader.of_string input) in
21
-
print_endline "Result:";
22
-
print_endline (Dom.to_test_format (Parser.root result))
-12
test/script_eof_test.ml
-12
test/script_eof_test.ml
···
1
-
open Bytesrw
2
-
3
-
module Parser = Html5rw_parser
4
-
module Dom = Html5rw_dom
5
-
6
-
let () =
7
-
(* Test incomplete script tag *)
8
-
let input = "<!doctype html><script><" in
9
-
print_endline ("Input: " ^ input);
10
-
let result = Parser.parse ~collect_errors:true (Bytes.Reader.of_string input) in
11
-
print_endline "Result:";
12
-
print_endline (Dom.to_test_format (Parser.root result))
-13
test/select_debug.ml
-13
test/select_debug.ml
···
1
-
open Bytesrw
2
-
3
-
module Parser = Html5rw_parser
4
-
module Dom = Html5rw_dom
5
-
6
-
let () =
7
-
let input = "<select><b><option><select><option></b></select>X" in
8
-
print_endline "Input:";
9
-
print_endline input;
10
-
print_endline "";
11
-
let result = Parser.parse ~collect_errors:true (Bytes.Reader.of_string input) in
12
-
print_endline "Result:";
13
-
print_endline (Dom.to_test_format (Parser.root result))
-9
test/simple_test.ml
-9
test/simple_test.ml
-13
test/svg_frag_test.ml
-13
test/svg_frag_test.ml
···
1
-
open Bytesrw
2
-
3
-
module Parser = Html5rw_parser
4
-
module Dom = Html5rw_dom
5
-
6
-
let () =
7
-
let input = "Hello" in
8
-
print_endline "Starting...";
9
-
let context = Parser.make_fragment_context ~tag_name:"path" ~namespace:(Some "svg") () in
10
-
print_endline "Created context";
11
-
let result = Parser.parse ~collect_errors:true ~fragment_context:context (Bytes.Reader.of_string input) in
12
-
print_endline "Parsed";
13
-
print_endline (Dom.to_test_format (Parser.root result))
-21
test/template_debug.ml
-21
test/template_debug.ml
···
1
-
open Bytesrw
2
-
3
-
module Parser = Html5rw_parser
4
-
module Dom = Html5rw_dom
5
-
6
-
let () =
7
-
(* Template test 45: div inside tr inside template *)
8
-
let input1 = "<body><template><tr><div></div></tr></template>" in
9
-
print_endline "=== Test 1 ===";
10
-
print_endline ("Input: " ^ input1);
11
-
let result1 = Parser.parse ~collect_errors:true (Bytes.Reader.of_string input1) in
12
-
print_endline "Result:";
13
-
print_endline (Dom.to_test_format (Parser.root result1));
14
-
15
-
(* Template test 91: select inside tbody inside nested template *)
16
-
let input2 = "<template><template><tbody><select>" in
17
-
print_endline "\n=== Test 2 ===";
18
-
print_endline ("Input: " ^ input2);
19
-
let result2 = Parser.parse ~collect_errors:true (Bytes.Reader.of_string input2) in
20
-
print_endline "Result:";
21
-
print_endline (Dom.to_test_format (Parser.root result2))
-13
test/template_debug2.ml
-13
test/template_debug2.ml
···
1
-
open Bytesrw
2
-
3
-
module Parser = Html5rw_parser
4
-
module Dom = Html5rw_dom
5
-
6
-
let () =
7
-
(* Test i then menu in template *)
8
-
let input = "<template><i><menu>Foo" in
9
-
print_endline "=== Test: i then menu in template ===";
10
-
print_endline ("Input: " ^ input);
11
-
let result = Parser.parse ~collect_errors:true (Bytes.Reader.of_string input) in
12
-
print_endline "Result:";
13
-
print_endline (Dom.to_test_format (Parser.root result))
-26
test/template_debug3.ml
-26
test/template_debug3.ml
···
1
-
open Bytesrw
2
-
3
-
module Parser = Html5rw_parser
4
-
5
-
let () =
6
-
print_endline "=== Test: <body><template><i><menu>Foo</i> ===";
7
-
let result = Html5rw_parser.parse (Bytes.Reader.of_string "<body><template><i><menu>Foo</i>") in
8
-
print_endline (Html5rw_dom.to_test_format (Parser.root result));
9
-
print_newline ();
10
-
11
-
(* Expected:
12
-
<html>
13
-
<head>
14
-
<body>
15
-
<template>
16
-
content
17
-
<i>
18
-
<menu>
19
-
<i>
20
-
"Foo"
21
-
*)
22
-
23
-
print_endline "=== Test: <i><menu>Foo</i> (without template) ===";
24
-
let result = Html5rw_parser.parse (Bytes.Reader.of_string "<i><menu>Foo</i>") in
25
-
print_endline (Html5rw_dom.to_test_format (Parser.root result));
26
-
print_newline ()
-29
test/template_debug4.ml
-29
test/template_debug4.ml
···
1
-
open Bytesrw
2
-
3
-
module Parser = Html5rw_parser
4
-
5
-
let () =
6
-
print_endline "=== Test: <template><svg><foo><template><foreignObject><div></template><div> ===";
7
-
let result = Html5rw_parser.parse (Bytes.Reader.of_string "<template><svg><foo><template><foreignObject><div></template><div>") in
8
-
print_endline (Html5rw_dom.to_test_format (Parser.root result));
9
-
print_newline ();
10
-
11
-
(* Expected:
12
-
<html>
13
-
<head>
14
-
<template>
15
-
content
16
-
<svg svg>
17
-
<svg foo>
18
-
<svg template>
19
-
<svg foreignObject>
20
-
<div>
21
-
<body>
22
-
<div>
23
-
*)
24
-
25
-
(* Let's also test what happens with just the SVG template *)
26
-
print_endline "=== Test: <svg><template><foreignObject><div></template>text ===";
27
-
let result = Html5rw_parser.parse (Bytes.Reader.of_string "<svg><template><foreignObject><div></template>text") in
28
-
print_endline (Html5rw_dom.to_test_format (Parser.root result));
29
-
print_newline ()
-14
test/test_debug.ml
-14
test/test_debug.ml
···
1
-
open Bytesrw
2
-
3
-
module Parser = Html5rw_parser
4
-
module Dom = Html5rw_dom
5
-
6
-
let test input =
7
-
print_endline ("Input: " ^ input);
8
-
let result = Parser.parse ~collect_errors:true (Bytes.Reader.of_string input) in
9
-
print_endline (Dom.to_test_format (Parser.root result));
10
-
print_endline ""
11
-
12
-
let () =
13
-
(* Frameset tests - exact test input *)
14
-
test "<frameset></frameset>\nfoo"
-15
test/test_frameset.ml
-15
test/test_frameset.ml
···
1
-
open Bytesrw
2
-
3
-
module Parser = Html5rw_parser
4
-
module Dom = Html5rw_dom
5
-
6
-
let () =
7
-
let input = "<param><frameset></frameset>" in
8
-
print_endline ("Input: " ^ input);
9
-
try
10
-
let result = Parser.parse ~collect_errors:true (Bytes.Reader.of_string input) in
11
-
print_endline "Tree:";
12
-
print_endline (Dom.to_test_format (Parser.root result))
13
-
with e ->
14
-
print_endline ("Exception: " ^ Printexc.to_string e);
15
-
Printexc.print_backtrace stdout
-11
test/test_mi.ml
-11
test/test_mi.ml
···
1
-
open Bytesrw
2
-
3
-
module Parser = Html5rw_parser
4
-
module Dom = Html5rw_dom
5
-
6
-
let () =
7
-
let input = "<!doctype html><p><math><mi><p><h1>" in
8
-
print_endline ("Input: " ^ input);
9
-
let result = Parser.parse ~collect_errors:true (Bytes.Reader.of_string input) in
10
-
print_endline "Tree:";
11
-
print_endline (Dom.to_test_format (Parser.root result))
-9
test/test_table.ml
-9
test/test_table.ml
···
1
-
open Bytesrw
2
-
3
-
module Parser = Html5rw_parser
4
-
module Dom = Html5rw_dom
5
-
let () =
6
-
let input = "<b><em><foo><foo><aside></b>" in
7
-
print_endline ("Input: " ^ input);
8
-
let result = Parser.parse ~collect_errors:true (Bytes.Reader.of_string input) in
9
-
print_endline (Dom.to_test_format (Parser.root result))
-11
test/test_table_svg.ml
-11
test/test_table_svg.ml
···
1
-
open Bytesrw
2
-
3
-
module Parser = Html5rw_parser
4
-
module Dom = Html5rw_dom
5
-
6
-
let () =
7
-
let input = "<table><tr><td><svg><desc><td></desc><circle>" in
8
-
print_endline ("Input: " ^ input);
9
-
let result = Parser.parse ~collect_errors:true (Bytes.Reader.of_string input) in
10
-
print_endline "Tree:";
11
-
print_endline (Dom.to_test_format (Parser.root result))
-11
test/test_whitespace.ml
-11
test/test_whitespace.ml
···
1
-
open Bytesrw
2
-
3
-
module Parser = Html5rw_parser
4
-
module Dom = Html5rw_dom
5
-
6
-
let () =
7
-
let input = "<style> <!-- </style> --> </style>x" in
8
-
print_endline ("Input: " ^ input);
9
-
let result = Parser.parse ~collect_errors:true (Bytes.Reader.of_string input) in
10
-
print_endline "Tree:";
11
-
print_endline (Dom.to_test_format (Parser.root result))