let tex_of_unicode s =
(*WARNING: the space below is a nbsp (0x00A0), not a normal space *)
- if s = " " then Some ""
+ if s = " " then [""]
else
try
- Some ("\\" ^ Hashtbl.find Utf8MacroTable.utf82macro s)
- with Not_found -> None
+ let alt =
+ List.map (fun x -> "\\"^x)
+ (Hashtbl.find_all Utf8MacroTable.utf82macro s)
+ in
+ List.sort
+ (fun x y -> Pervasives.compare (String.length x) (String.length y))
+ alt
+ with Not_found -> []
+let pp_table () =
+ let rec list_uniq ?(eq=(=)) = function
+ | [] -> []
+ | h::[] -> [h]
+ | h1::h2::tl when eq h1 h2 -> list_uniq ~eq (h2 :: tl)
+ | h1::tl (* when h1 <> h2 *) -> h1 :: list_uniq ~eq tl
+ in
+ let l = ref [] in
+ Hashtbl.iter (fun k _ -> l := k :: !l) Utf8MacroTable.utf82macro;
+ l := list_uniq (List.sort compare !l);
+ List.map
+ (fun k ->
+ let vs = Hashtbl.find_all Utf8MacroTable.utf82macro k in
+ (k, List.map (fun x -> "\\"^x) vs))
+ !l
+;;