File tree Expand file tree Collapse file tree 1 file changed +19
-3
lines changed Expand file tree Collapse file tree 1 file changed +19
-3
lines changed Original file line number Diff line number Diff line change @@ -161,18 +161,34 @@ let rec error_padding = function
161161 let xs = error_padding xs in
162162 x :: xs
163163
164+ let compute_delimiter ~base_delim outputs =
165+ let s =
166+ Format. asprintf " %a" (Format. pp_print_list (Output. pp ~pad: 0 )) outputs
167+ in
168+ let is_inadequate delim =
169+ Astring.String. is_infix ~affix: (" ]" ^ delim ^ " }" ) s
170+ in
171+ let rec loop n =
172+ let delim =
173+ match n with 0 -> base_delim | n -> Format. sprintf " %s_%d" base_delim n
174+ in
175+ if is_inadequate delim then loop (n + 1 ) else delim
176+ in
177+ loop 0
178+
164179let pp_error ?syntax ?delim ppf outputs =
165180 match syntax with
166181 | Some Syntax. Markdown ->
167182 Fmt. pf ppf " ```\n ```mdx-error\n %a\n "
168183 Fmt. (list ~sep: (any " \n " ) Output. pp)
169184 outputs
170185 | Some Syntax. Mli | Some Syntax. Mld ->
171- Fmt. pf ppf " ]%a[\n {err@mdx-error[\n %a\n ]err}"
186+ let err_delim = compute_delimiter ~base_delim: " err" outputs in
187+ Fmt. pf ppf " ]%a[\n {%s@mdx-error[\n %a\n ]%s}"
172188 Fmt. (option string )
173- delim
189+ delim err_delim
174190 Fmt. (list ~sep: (any " \n " ) Output. pp)
175- outputs
191+ outputs err_delim
176192 | _ -> ()
177193
178194let has_output t =
You can’t perform that action at this time.
0 commit comments