-let txt_of_cic_term size metasenv context t =
- let fake_sequent = (-1,context,t) in
- txt_of_cic_sequent_conclusion size metasenv fake_sequent
+let txt_of_cic_term ~map_unicode_to_tex size metasenv context t =
+ let fake_sequent = (-1,context,t) in
+ txt_of_cic_sequent_conclusion ~map_unicode_to_tex ~output_type:`Term size
+ metasenv fake_sequent
+;;
+
+ignore (
+ CicMetaSubst.set_ppterm_in_context
+ (fun ~metasenv subst term context ->
+ try
+ let context' = CicMetaSubst.apply_subst_context subst context in
+ let metasenv = CicMetaSubst.apply_subst_metasenv subst metasenv in
+ let term' = CicMetaSubst.apply_subst subst term in
+ let res =
+ txt_of_cic_term
+ ~map_unicode_to_tex:(Helm_registry.get_bool "matita.paste_unicode_as_tex")
+ 30 metasenv context' term' in
+ if String.contains res '\n' then
+ "\n" ^ res ^ "\n"
+ else
+ res
+ with
+ Sys.Break as exn -> raise exn
+ | exn ->
+ "[[ Exception raised during pretty-printing: " ^
+ (try
+ Printexc.to_string exn
+ with
+ Sys.Break as exn -> raise exn
+ | _ -> "<<exception raised pretty-printing the exception>>"
+ ) ^ " ]] " ^
+ (CicMetaSubst.use_low_level_ppterm_in_context := true;
+ try
+ let res =
+ CicMetaSubst.ppterm_in_context ~metasenv subst term context
+ in
+ CicMetaSubst.use_low_level_ppterm_in_context := false;
+ res
+ with
+ exc ->
+ CicMetaSubst.use_low_level_ppterm_in_context := false;
+ raise exc))
+);;