Tezos_stdlib.Pretty_printing
add_ansi_marking ppf
will enable ppf
to handle semantic tags.
See https://ocaml.org/manual/5.2/api/Format.html#tags for more precisions.
Possible values are:
Possible colors are: 'black', 'blue', 'cyan', 'green', 'magenta', 'red', 'white', 'yellow'.
Styles are declared with "@{<list of styles separated by ';'>...@}"
It's a good habit to enable semantic tags at point and reset to the previous behavior to avoid conflicting with other printers that would implement their own semantic tags handlers. This is why this function returns a function that allows to reset ppf
to its old behavior.
Example of use:
[ let pp ppf t = let reset = add_ansi_marking ppf in Format.fprintf ppf "@{<bold; fg_cyan>...@}" t; reset () ]