Pure OCaml Yaml 1.2 reader and writer using Bytesrw
1(*---------------------------------------------------------------------------
2 Copyright (c) 2025 Anil Madhavapeddy <anil@recoil.org>. All rights reserved.
3 SPDX-License-Identifier: ISC
4 ---------------------------------------------------------------------------*)
5
6(** Block scalar chomping indicators *)
7
8type t =
9 | Strip (** Remove final line break and trailing empty lines *)
10 | Clip (** Keep final line break, remove trailing empty lines (default) *)
11 | Keep (** Keep final line break and trailing empty lines *)
12
13let to_string = function
14 | Strip -> "strip"
15 | Clip -> "clip"
16 | Keep -> "keep"
17
18let pp fmt t =
19 Format.pp_print_string fmt (to_string t)
20
21let of_char = function
22 | '-' -> Some Strip
23 | '+' -> Some Keep
24 | _ -> None
25
26let to_char = function
27 | Strip -> Some '-'
28 | Clip -> None
29 | Keep -> Some '+'
30
31let equal a b = a = b