aboutsummaryrefslogtreecommitdiff
path: root/bin/main.ml
diff options
context:
space:
mode:
Diffstat (limited to 'bin/main.ml')
-rw-r--r--bin/main.ml37
1 files changed, 28 insertions, 9 deletions
diff --git a/bin/main.ml b/bin/main.ml
index 0a09a63..cf6cb33 100644
--- a/bin/main.ml
+++ b/bin/main.ml
@@ -650,7 +650,27 @@ let extension path =
fallback to [Escape.None_]: guessing the flavour wrong produces malformed
output (unescaped LaTeX/HTML metacharacters) that looks fine until it does
not -- the same "never silently substitute" discipline [data_dir]'s own
- [COLITUR_DATA_DIR] handling documents above. *)
+ [COLITUR_DATA_DIR] handling documents above.
+
+ Both error messages below list the flavours by walking [Escape.all]
+ rather than a hand-typed literal, on purpose: a hand-typed list is
+ exactly the kind of call site the design claims does not exist outside
+ escape.ml (spec section 5) -- adding Typst as a seventh flavour found
+ this one had drifted from that claim (it silently still said "the six
+ flavours" until then), so this is now future-proof against the same
+ drift the next flavour would otherwise reintroduce. *)
+let flavour_names_comma () =
+ match List.map Colitur_render.Escape.to_string Colitur_render.Escape.all with
+ | [] -> ""
+ | [ x ] -> x
+ | xs -> (
+ match List.rev xs with
+ | last :: rest -> String.concat ", " (List.rev rest) ^ " or " ^ last
+ | [] -> "")
+
+let flavour_names_bar () =
+ String.concat "|" (List.map Colitur_render.Escape.to_string Colitur_render.Escape.all)
+
let table_report ~lang ~template ~flavour_opt ~overlays y =
let flavour =
match flavour_opt with
@@ -658,16 +678,14 @@ let table_report ~lang ~template ~flavour_opt ~overlays y =
match Colitur_render.Escape.of_string name with
| Some f -> f
| None ->
- Printf.eprintf "colitur: unknown flavour %S (want latex, groff, html, xml, ics or none)\n"
- name;
+ Printf.eprintf "colitur: unknown flavour %S (want %s)\n" name (flavour_names_comma ());
exit 2)
| None -> (
match Colitur_render.Escape.of_extension (extension template) with
| Some f -> f
| None ->
- Printf.eprintf
- "colitur: cannot infer a flavour from %S; pass --flavour latex|groff|html|xml|ics|none\n"
- (extension template);
+ Printf.eprintf "colitur: cannot infer a flavour from %S; pass --flavour %s\n"
+ (extension template) (flavour_names_bar ());
exit 2)
in
match read_file template with
@@ -1116,11 +1134,12 @@ rendering:
--flavour X selects how interpolated VALUES are escaped (never the
template's own literal markup, which is the author's). One of:
- latex groff html xml ics none
+ latex typst groff html xml ics none
Inferred from --template's extension when --flavour is omitted:
.tex -> latex
+ .typ -> typst
.ms .mom .me -> groff
.html .htm -> html
.xml -> xml
@@ -1132,7 +1151,7 @@ rendering:
them alone)
An extension colitur does not recognise is a hard ERROR naming
- the six flavours above, never a silent fallback to `none`:
+ the seven flavours above, never a silent fallback to `none`:
guessing wrong produces output that looks fine until the
metacharacters it silently failed to escape show up.
@@ -1190,7 +1209,7 @@ Reading references only (e.g. "Jn 3:16"); never scripture text.
See colitur(1) for the full description and the sources it computes against,
colitur-overlay(5) for the overlay file format in full,
colitur-templates(5) for the template format in full -- the syntax, the
-remaining scope hazard, the six flavours' escaping, and the full view-model
+remaining scope hazard, the seven flavours' escaping, and the full view-model
field reference -- and colitur-config(5) for the config file's location and
precedence in full.|}