We are running using the full version so we dont need to load camlp4
In [2]:
#use "topfind"
Out[2]:
Now load the TyXML library and syntax extension. We currently need to add some predicates to 'Topfind' so the syntax extension loads properly. A customised topfind for different iocamljs versions will eventually be needed.
In [3]:
Topfind.add_predicates["syntax";"camlp4o"]
Out[3]:
In [4]:
#require "tyxml.syntax"
Out[4]:
Define a printing function which will display the HTML in the notebook.
In [5]:
let html q =
let b = Buffer.create 10 in
Html5.P.print_list ~output:(Buffer.add_string b) q;
Iocaml.display "text/html" (Buffer.contents b)
Out[5]:
We can now write some HTML. Note the local binding of the Html5 module. If we do this globally we get a JavaScript stack overflow exception. I think this is due to printing a large module signature.
In [6]:
let x =
let module Html5 = Html5.M in
<:html5< <p> <i>hello</i> <b>world</b> </p> >>
Out[6]:
Now we can display the html
In [7]:
html [x]
Out[7]: