summaryrefslogtreecommitdiff
path: root/lib/citation/sigla.ml
blob: a4f45555ed39f6e088c192ec6d44998f95eac20f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
(* 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)