let to_unicode = Utf8Macro.unicode_of_tex
-let rec make_attributes l1 = function
+(* let rec make_attributes l1 = function
| [] -> []
| None :: tl -> make_attributes (List.tl l1) tl
| Some s :: tl ->
let p,n = List.hd l1 in
- (p,n,s) :: make_attributes (List.tl l1) tl
+ prerr_endline (Printf.sprintf "make_attributes %s %s" n s);
+ (p,n,s) :: make_attributes (List.tl l1) tl *)
+let rec make_attributes l1 = function
+ | [] -> []
+ | hd :: tl ->
+ (match !hd with
+ | None -> make_attributes (List.tl l1) tl
+ | Some s ->
+ let p,n = List.hd l1 in
+ prerr_endline (Printf.sprintf "make_attributes %s %s" n s);
+ hd := None;
+ (p,n,s) :: make_attributes (List.tl l1) tl)
let box_of_mpres =
function
| Some id -> (try Some (Hashtbl.find ids_to_uris id) with Not_found -> None)
in
let make_href xmlattrs xref uris =
- let xref_uri = lookup_uri xref in
- let raw_uris = List.map UriManager.string_of_uri uris in
+ let xref_uri = lookup_uri !xref in
+ let raw_uris = List.map UriManager.string_of_uri !uris in
let uri =
match xref_uri, raw_uris with
| None, [] -> None
| None, raw_uris -> Some (String.concat " " raw_uris)
| Some uri, raw_uris -> Some (String.concat " " (uri :: raw_uris))
in
+ uris := [];
xmlattrs
- @ make_attributes [Some "helm", "xref"; Some "xlink", "href"] [xref; uri]
+ @ make_attributes [Some "helm", "xref"; Some "xlink", "href"]
+ [xref; ref uri]
in
let make_xref xref = make_attributes [Some "helm","xref"] [xref] in
(* when mathonly is true no boxes should be generated, only mrows *)
+ (* "xref" is *)
let rec aux xmlattrs mathonly xref pos prec uris t =
match t with
| A.AttributedTerm _ ->
| A.Uri (literal, subst) ->
let attrs =
(RenderingAttrs.ident_attributes `MathML)
- @ make_href xmlattrs xref []
+ @ make_href xmlattrs xref (ref [])
in
let name = P.Mi (attrs, to_unicode literal) in
(match subst with
aux_attribute t
| t ->
(match !new_level with
- | None -> aux !new_xmlattrs mathonly !new_xref pos prec !new_uris t
+ | None -> aux !new_xmlattrs mathonly new_xref pos prec new_uris t
| Some (child_prec, child_assoc) ->
let t' =
- aux !new_xmlattrs mathonly !new_xref pos child_prec !new_uris t
+ aux !new_xmlattrs mathonly new_xref pos child_prec new_uris t
in
add_parens child_prec child_assoc pos prec t')
in
| `Number s -> P.Mn (attrs, to_unicode s))
and aux_layout mathonly xref pos prec uris l =
let attrs = make_xref xref in
- let invoke' t = aux [] true None pos prec uris t in
+ let invoke' t = aux [] true (ref None) pos prec uris t in
match l with
| A.Sub (t1, t2) -> P.Msub (attrs, invoke' t1, invoke' t2)
| A.Sup (t1, t2) -> P.Msup (attrs, invoke' t1, invoke' t2)
in
List.map boxify_pres (find_clusters terms)
in
- aux [] false None `None 0 []
+ aux [] false (ref None) `None 0 (ref [])
let rec print_box (t: boxml_markup) =
Box.box2xml print_mpres t