Commit ce7ff52a authored by Kim Nguyễn's avatar Kim Nguyễn
Browse files

Add HTML parser to the JSOO backend.

parent deb43e17
open Js_of_ocaml
open Cduce_core
let load_xml open_cb close_cb text_cb txt =
let load_xml_html mimetype open_cb close_cb text_cb txt =
let _DOMParser : (unit -> < .. > Js.t) Js.constr Js.optdef =
Js.Unsafe.(get global (Js.string "DOMParser"))
in
......@@ -11,7 +11,7 @@ let load_xml open_cb close_cb text_cb txt =
in
let parser = new%js _DOMParser () in
let txt = Js.string txt in
let mime_type = Js.string "text/xml" in
let mime_type = Js.string mimetype in
let dom : Dom.element Dom.document Js.t =
Js.Unsafe.(
meth_call parser "parseFromString" [| inject txt; inject mime_type |])
......@@ -86,9 +86,15 @@ let use () =
!content);
Load_xml.xml_parser := fun url ->
load_xml Load_xml.start_element_handler Load_xml.end_element_handler
load_xml_html "application/xml" Load_xml.start_element_handler Load_xml.end_element_handler
Load_xml.text_handler (Url.load_url url);
Load_xml.html_loader :=
Load_xml.mk_load_xml
(fun url -> (load_xml_html "text/html" Load_xml.start_element_handler Load_xml.end_element_handler
Load_xml.text_handler (Url.load_url url)));
let open Cduce_types in
let tstr = Builtin_defs.string in
......
......@@ -473,8 +473,6 @@ ident_or_keyword:
| k = keyword { k }
;
int_or_star:
| i = INT { Some i }
| "*" { None }
......@@ -530,7 +528,6 @@ field_pat:
;
regexp:
| x = regexp "|" y = regexp_concat {
match x, y with
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment