2017-11-27 09:13:12 +04:00
|
|
|
(**************************************************************************)
|
|
|
|
(* *)
|
2018-02-06 00:17:03 +04:00
|
|
|
(* Copyright (c) 2014 - 2018. *)
|
2017-11-27 09:13:12 +04:00
|
|
|
(* Dynamic Ledger Solutions, Inc. <contact@tezos.com> *)
|
|
|
|
(* *)
|
|
|
|
(* All rights reserved. No warranty, explicit or implicit, provided. *)
|
|
|
|
(* *)
|
|
|
|
(**************************************************************************)
|
|
|
|
|
|
|
|
module Infix = struct
|
|
|
|
|
|
|
|
let (<<) g f = fun a -> g (f a)
|
|
|
|
|
|
|
|
let (--) i j =
|
|
|
|
let rec loop acc j =
|
|
|
|
if j < i then acc else loop (j :: acc) (pred j) in
|
|
|
|
loop [] j
|
|
|
|
|
|
|
|
end
|
|
|
|
|
2018-05-10 12:26:42 +04:00
|
|
|
let nbsp = Re.(compile (str "\xC2\xA0"))
|
2017-11-27 09:13:12 +04:00
|
|
|
let display_paragraph ppf description =
|
|
|
|
Format.fprintf ppf "@[%a@]"
|
|
|
|
(Format.pp_print_list ~pp_sep:Format.pp_print_newline
|
|
|
|
(fun ppf line ->
|
|
|
|
Format.pp_print_list ~pp_sep:Format.pp_print_space
|
|
|
|
(fun ppf w ->
|
|
|
|
(* replace by real spaces... *)
|
|
|
|
Format.fprintf ppf "%s@ "
|
2018-05-10 12:26:42 +04:00
|
|
|
(Re.replace ~all:true nbsp ~f:(fun _ -> " ") w))
|
2017-11-27 09:13:12 +04:00
|
|
|
ppf
|
|
|
|
(TzString.split ' ' line)))
|
|
|
|
(TzString.split ~dup:false '\n' description)
|
|
|
|
|
|
|
|
let finalize f g = try let res = f () in g (); res with exn -> g (); raise exn
|