4 type t
= TREE_MN
of string | TREE_MO
of string | TREE_MI
of string
6 let rec make_mathml_tree = function
7 TREE_MN a
::otr
,TEX_LITERAL
(MHTMLABLEC
(_
,_
,_
,MN
,b
))::itr
-> make_mathml_tree(TREE_MN
(a^b
)::otr
,itr
)
8 | otr
,TEX_LITERAL
(MHTMLABLEC
(_
,_
,_
,MN
,a
))::itr
-> make_mathml_tree(TREE_MN a
::otr
,itr
)
9 | otr
,TEX_LITERAL
(MHTMLABLEC
(_
,_
,_
,MO
,a
))::itr
-> make_mathml_tree(TREE_MO a
::otr
,itr
)
10 | otr
,TEX_LITERAL
(MHTMLABLEC
(_
,_
,_
,MI
,a
))::itr
-> make_mathml_tree(TREE_MI a
::otr
,itr
)
11 | otr
,TEX_CURLY
(crl
)::itr
-> make_mathml_tree(otr
,crl
@itr
)
12 | otr
,[] -> List.rev otr
13 | _
-> failwith
"failed to render mathml"
15 let render_mathml_tree = function
16 TREE_MN s
-> "<mn>"^s^
"</mn>"
17 | TREE_MI s
-> "<mi>"^s^
"</mi>"
18 | TREE_MO s
-> "<mo>"^s^
"</mo>"
20 let render tree
= try Some
(Util.mapjoin
render_mathml_tree (make_mathml_tree ([],tree
))) with _
-> None