+let replacements =
+ let map s = String.length s, s, Str.regexp_string s, "_discharged" ^ s in
+ List.map map suffixes
+
+let replacement (ok, u) (l, s, x, t) =
+ if ok then ok, u else
+ if Str.last_chars u l = s then true, Str.replace_first x t u else ok, u
+
+let discharge_uri style uri =
+ let template = match style with
+ | G.Declarative -> "cic:/matita/declarative/"
+ | G.Procedural _ -> "cic:/matita/procedural/"
+ in
+ let s = UM.string_of_uri uri in
+ if Str.string_match matita_prefix s 0 then uri else
+ let s = Str.replace_first cic_prefix template s in
+ let _, s = List.fold_left replacement (false, s) replacements in
+ UM.uri_of_string s
+
+let discharge_name s = s ^ "_discharged"
+
+let txt_of_inline_uri ~map_unicode_to_tex style ?flavour prefix suri =
+ let print_exc = function
+ | ProofEngineHelpers.Bad_pattern s as e ->
+ Printexc.to_string e ^ " " ^ Lazy.force s
+ | e -> Printexc.to_string e
+ in