1234567891011121314151617181920212223242526272829303132333435363738394041424344454647(* Elements and attributes are technically utf8, but ascii is enough for now.
see <http://www.w3.org/TR/html51/syntax.html#syntax>
*)(* When dropping support for 4.02, this module can simply be deleted. *)moduleChar=structincludeCharletlowercase_ascii=Char.lowercase[@ocaml.warning"-3"]letuppercase_ascii=Char.uppercase[@ocaml.warning"-3"]end(* In the ocaml parser:
let identchar = ['A'-'Z' 'a'-'z' '_' '\'' '0'-'9']
*)letis_identchar=function|'A'..'Z'|'a'..'z'|'_'|'\''|'0'..'9'->true|_->falseletto_ocaml_bytess=letfc=ifis_identcharcthencelse'_'inBytes.init(String.lengths)(funi->fs.[i])letto_ocamls=Bytes.to_string(to_ocaml_bytess)letidents=lets=to_ocaml_bytessinlets=Bytes.mapi(funic->ifi=0thenChar.lowercase_asciicelsec)sinBytes.to_stringsletattribs="a_"^to_ocamlsletpolyvars=lets=to_ocaml_bytessinlets=Bytes.mapi(funic->ifi=0thenChar.uppercase_asciicelsec)sin"`"^Bytes.to_strings