X-Git-Url: http://matita.cs.unibo.it/gitweb/?a=blobdiff_plain;f=helm%2Fsoftware%2Fcomponents%2Fsyntax_extensions%2Futf8Macro.ml;h=c95282d58a061d1569a199a59a5ce582e46350d4;hb=e9b09b14538f770b9e65083c24e3e9cf487df648;hp=e5fca10c48cc06e3a428865ea94190758f7cbc3f;hpb=58955ec841575330f0b429033264f9ec7df319f9;p=helm.git diff --git a/helm/software/components/syntax_extensions/utf8Macro.ml b/helm/software/components/syntax_extensions/utf8Macro.ml index e5fca10c4..c95282d58 100644 --- a/helm/software/components/syntax_extensions/utf8Macro.ml +++ b/helm/software/components/syntax_extensions/utf8Macro.ml @@ -41,7 +41,32 @@ let unicode_of_tex s = with Macro_not_found _ -> s let tex_of_unicode s = + (*WARNING: the space below is a nbsp (0x00A0), not a normal space *) + if s = " " then [""] + else try - "\\" ^ Hashtbl.find Utf8MacroTable.utf82macro s - with Not_found -> s + 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 +;;