2011-04-09 00:39:40 +00:00
|
|
|
open Tex
|
|
|
|
open Render_info
|
|
|
|
|
2011-05-12 21:46:18 +00:00
|
|
|
type t = TREE_MN of string | TREE_MO of string | TREE_MI of string | TREE_MF of string | TREE_MFB of string * string
|
2011-04-09 00:39:40 +00:00
|
|
|
|
|
|
|
let rec make_mathml_tree = function
|
|
|
|
TREE_MN a::otr,TEX_LITERAL(MHTMLABLEC(_,_,_,MN,b))::itr -> make_mathml_tree(TREE_MN (a^b)::otr,itr)
|
|
|
|
| otr,TEX_LITERAL(MHTMLABLEC(_,_,_,MN,a))::itr -> make_mathml_tree(TREE_MN a::otr,itr)
|
|
|
|
| otr,TEX_LITERAL(MHTMLABLEC(_,_,_,MO,a))::itr -> make_mathml_tree(TREE_MO a::otr,itr)
|
|
|
|
| otr,TEX_LITERAL(MHTMLABLEC(_,_,_,MI,a))::itr -> make_mathml_tree(TREE_MI a::otr,itr)
|
2011-05-12 21:46:18 +00:00
|
|
|
| otr,TEX_LITERAL(MHTMLABLEC(_,_,_,MF,a))::itr -> make_mathml_tree(TREE_MF a::otr,itr)
|
|
|
|
| otr,TEX_LITERAL(MHTMLABLEFC(_,_,_,MF,a,b))::itr -> make_mathml_tree(TREE_MFB (a,b)::otr,itr)
|
2011-04-09 00:39:40 +00:00
|
|
|
| otr,TEX_CURLY(crl)::itr -> make_mathml_tree(otr,crl@itr)
|
|
|
|
| otr,[] -> List.rev otr
|
|
|
|
| _ -> failwith "failed to render mathml"
|
|
|
|
|
|
|
|
let render_mathml_tree = function
|
|
|
|
TREE_MN s -> "<mn>"^s^"</mn>"
|
|
|
|
| TREE_MI s -> "<mi>"^s^"</mi>"
|
|
|
|
| TREE_MO s -> "<mo>"^s^"</mo>"
|
2011-05-14 03:04:08 +00:00
|
|
|
| TREE_MF s -> "<mi>"^s^" </mi>"
|
|
|
|
| TREE_MFB (s,b) -> "<mi>"^s^"</mi>"^"<mo>"^b^"</mo>"
|
2011-04-09 00:39:40 +00:00
|
|
|
|
|
|
|
let render tree = try Some (Util.mapjoin render_mathml_tree (make_mathml_tree ([],tree))) with _ -> None
|