children
in
let attrs' =
- (if spacing then RenderingAttrs.spacing_attributes `BoxML else [])
- @ (if indent then RenderingAttrs.indent_attributes `BoxML else [])
+ (if spacing then [None, "spacing", "0.5em"] else [])
+ @ (if indent then [None, "indent", "0.5em"] else [])
@ attrs
in
match kind with
| A.AttributedTerm _ ->
aux_attributes [] "" prec t
| A.Num (literal, _) -> Box.Text ([], literal)
- | A.Symbol (literal, _) -> Box.Text ([], literal)
+ | A.Symbol (literal, Some (None,desc)) ->
+ let txt = "<A title=\"" ^ desc ^ "\">" ^ literal ^ "</A>" in
+ Box.Text ([], to_unicode txt)
+ | A.Symbol (literal, Some (Some u,desc)) ->
+ let txt =
+ "<A href=\"" ^ u ^ "\" title=\"" ^ desc ^ "\">" ^ literal ^ "</A>" in
+ Box.Text ([], to_unicode txt)
+ | A.Symbol (literal, _) -> Box.Text ([], to_unicode literal)
+ | A.Ident (literal, `Uri u) ->
+ let txt = "<A href=\"" ^ u ^ "\">" ^ literal ^ "</A>" in
+ Box.Text ([], to_unicode txt)
| A.Ident (literal, _) -> Box.Text ([], to_unicode literal)
| A.Meta(n, l) ->
let local_context =
| A.InfRule (t1, t2, t3) -> assert false
| A.Sqrt t -> assert false
| A.Root (t1, t2) -> assert false
- | A.Box (a, terms) ->
- let children = List.map (aux prec) terms in
- Box.H([],children)
+ | A.Box ((_,spacing,_) as kind, terms) ->
+ let children =
+ aux_children spacing prec
+ (NotationUtil.ungroup terms)
+ in
+ box_of kind attrs children
| A.Mstyle (l,terms) -> assert false
| A.Mpadded (l,terms) -> assert false
| A.Maction alternatives ->
toggle_action (List.map invoke_reinit alternatives)
| A.Group terms -> assert false
- | A.Break -> Box.Space []
+ | A.Break -> Box.Space []
+ and aux_children spacing prec terms =
+ let find_clusters =
+ let rec aux_list first clusters acc =
+ function
+ [] when acc = [] -> List.rev clusters
+ | [] -> aux_list first (List.rev acc :: clusters) [] []
+ | (A.Layout A.Break) :: tl when acc = [] ->
+ aux_list first clusters [] tl
+ | (A.Layout A.Break) :: tl ->
+ aux_list first (List.rev acc :: clusters) [] tl
+ | [hd] ->
+ aux_list false clusters
+ (aux prec hd :: acc) []
+ | hd :: tl ->
+ aux_list false clusters
+ (aux prec hd :: acc) tl
+ in
+ aux_list true [] []
+ in
+ let boxify_pres =
+ function
+ [t] -> t
+ | tl -> box_of (A.H, spacing, false) [] tl
+ in
+ List.map boxify_pres (find_clusters terms)
in
- aux prec
+ (fun t ->
+ prerr_endline ("ast:\n" ^ (NotationPp.pp_term status t));
+ aux prec t)
(* let render_to_boxml id_to_uri t =
let xml_stream = print_box (box_of_mpres (render id_to_uri t)) in
render status (TermContentPres.pp_ast status t)])
let render_context status context =
- Box.V ([],
+ Box.V ([],
+ Box.Space [None, "width", "0.5em"]::
List.map
(fun (name,entry) ->
render_context_entry status (to_unicode name) entry) context)
let render_sequent status (i,context,ty) =
Box.V ([],
- [render_context status context;
+ [render_context status (List.rev context);
Box.Ink [None,"width","4cm"; None,"height","2px"];
render status (TermContentPres.pp_ast status ty)])
let find_level2_patterns32 status pid =
IntMap.find pid status#interp_db.level2_patterns32
-let instantiate32 env symbol args =
+let instantiate32 env symbol dsc args =
let rec instantiate_arg = function
| Ast.IdentArg (n, name) ->
let t =
in
add_lambda t (n - count_lambda t)
in
- let head = Ast.Symbol (symbol, None) in
+ let head = Ast.Symbol (symbol, Some (None, dsc)) in
if args = [] then head
else Ast.Appl (head :: List.map instantiate_arg args)
term
) env
in
- let _, symbol, args, _ =
+ let dsc, symbol, args, _ =
try
find_level2_patterns32 status pid
with Not_found -> assert false
in
- instantiate32 env symbol args
+ instantiate32 env symbol dsc args
;;
let nmap_context0 status ~metasenv ~subst context =