(* SPDX-License-Identifier: AGPL-3.0-or-later *) type t = | Verbatim | Styled of { style : Render.style; tradition : Book.tradition; names : Book.id -> [ `Full | `Abbr ] -> string; } let verbatim = Verbatim let make ~style ~tradition ~names = Styled { style; tradition; names } let format t s = match t with | Verbatim -> s | Styled { style; tradition; names } -> ( match Parse.parse s with | Error _ -> s | Ok c -> let c = { c with Parse.book = Book.map tradition c.Parse.book } in Render.render style ~names c)