Skip to content

Commit

Permalink
Fixed HTML context detection with <html> tags.
Browse files Browse the repository at this point in the history
  • Loading branch information
aantron committed Feb 6, 2016
1 parent df2dafb commit c8d4332
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/html_parser.ml
Expand Up @@ -15,6 +15,7 @@ let detect_context tokens throw k =
| _, `Char c when not @@ is_whitespace c -> k (`Fragment "body")
| _, `Char _ -> scan ()
| _, `EOF -> k (`Fragment "body")
| _, `Start {name = "html"} -> k `Document
| _, `Start {name = "head" | "body" | "frameset"} ->
k (`Fragment "html")
| _, `Start {name =
Expand Down
8 changes: 8 additions & 0 deletions test/test_html_parser.ml
Expand Up @@ -519,6 +519,14 @@ let tests = [
expect ~context:None "<p>foo</p>"
[ 1, 1, S (start_element "p");
1, 4, S (`Text ["foo"]);
1, 7, S `End_element];

expect ~context:None "<html></html>"
[ 1, 1, S (start_element "html");
1, 7, S (start_element "head");
1, 7, S `End_element;
1, 7, S (start_element "body");
1, 7, S `End_element;
1, 7, S `End_element]);

("html.parser.foreign-context" >:: fun _ ->
Expand Down

0 comments on commit c8d4332

Please sign in to comment.