X-Git-Url: http://matita.cs.unibo.it/gitweb/?a=blobdiff_plain;f=helm%2Fsoftware%2Fmatita%2FmatitaGtkMisc.ml;h=772f17a41643f14250daf5f4c7f60e57d8a99066;hb=647b419e96770d90a82d7a9e5e8843566a9f93ee;hp=9c00dfddef4aa1b7879026c85e12fa1df0c3700d;hpb=d1f310f1f31b6919aa6e5ac6afd41b539130aec5;p=helm.git diff --git a/helm/software/matita/matitaGtkMisc.ml b/helm/software/matita/matitaGtkMisc.ml index 9c00dfdde..772f17a41 100644 --- a/helm/software/matita/matitaGtkMisc.ml +++ b/helm/software/matita/matitaGtkMisc.ml @@ -398,17 +398,26 @@ let utf8_parsed_text s floc = let start, stop = HExtlib.loc_of_floc floc in let start_bytes = Glib.Utf8.offset_to_pos s ~pos:0 ~off:start in let stop_bytes = Glib.Utf8.offset_to_pos s ~pos:0 ~off:stop in - assert(stop_bytes >= start_bytes); + if (stop_bytes < start_bytes) then + Printf.sprintf "ERROR (%d > %d)" start_bytes stop_bytes, 0 + else let bytes = stop_bytes - start_bytes in try String.sub s start_bytes bytes, bytes with Invalid_argument _ -> - Printf.eprintf "%s/%d/%d\n" s start_bytes bytes; - assert false - + Printf.sprintf "ERROR (%s/%d/%d)" s start_bytes bytes, 0 let utf8_string_length s = if BuildTimeConf.debug then assert(Glib.Utf8.validate s); Glib.Utf8.length s + +let escape_pango_markup text = + let text = Pcre.replace ~pat:"&" ~templ:"&" text in + let text = Pcre.replace ~pat:"<" ~templ:"<" text in + let text = Pcre.replace ~pat:"'" ~templ:"'" text in + let text = Pcre.replace ~pat:"\"" ~templ:""" text in + text +;; +