]> matita.cs.unibo.it Git - helm.git/blobdiff - components/content_pres/boxPp.ml
tagging rc-1
[helm.git] / components / content_pres / boxPp.ml
index 7a2fa9912f31144cb135e72441fe03f7b1bfd6fc..0c18475489b076db0fc5aa1feeb262ec83e21ca9 100644 (file)
@@ -31,7 +31,7 @@ module Pres = Mpresentation
 
 let string_space = " "
 let string_space_len = String.length string_space
-let string_indent = string_space
+let string_indent = (* string_space *) ""
 let string_indent_len = String.length string_indent
 let string_ink = "##"
 let string_ink_len = String.length string_ink
@@ -93,7 +93,7 @@ let fixed_rendering s =
   let s_len = String.length s in
   (fun _ -> s_len, [s])
 
-let render_to_strings size markup =
+let render_to_strings ~map_unicode_to_tex choose_action size markup =
   let max_size = max_int in
   let rec aux_box =
     function
@@ -101,7 +101,7 @@ let render_to_strings size markup =
     | Box.Space _ -> fixed_rendering string_space
     | Box.Ink _ -> fixed_rendering string_ink
     | Box.Action (_, []) -> assert false
-    | Box.Action (_, hd :: _) -> aux_box hd
+    | Box.Action (_, l) -> aux_box (choose_action l)
     | Box.Object (_, o) -> aux_mpres o
     | Box.H (attrs, children) ->
         let spacing = want_spacing attrs in
@@ -193,11 +193,15 @@ let render_to_strings size markup =
     | Pres.Mgliph (_, s) -> fixed_rendering s
     | Pres.Mo (_, s) ->
         let s =
-          if String.length s > 1 then
-            (* heuristic to guess which operators need to be expanded in their
-             * TeX like format *)
-            Utf8Macro.tex_of_unicode s ^ " "
-          else s
+          if map_unicode_to_tex then begin
+            if String.length s = 1 && Char.code s.[0] < 128 then
+              s
+            else
+              match Utf8Macro.tex_of_unicode s with
+              | Some s -> s ^ " "
+              | None -> " " ^ s ^ " "
+          end else
+            s
         in
         fixed_rendering s
     | Pres.Mspace _ -> fixed_rendering string_space
@@ -236,6 +240,7 @@ let render_to_strings size markup =
   in
   snd (aux_mpres markup size)
 
-let render_to_string size markup =
-  String.concat "\n" (render_to_strings size markup)
+let render_to_string ~map_unicode_to_tex choose_action size markup =
+  String.concat "\n"
+    (render_to_strings ~map_unicode_to_tex choose_action size markup)