From cd46163fa347bbc49bf8008d70d408f62feabda5 Mon Sep 17 00:00:00 2001 From: Lukasz Kasprzak Date: Thu, 20 Aug 2026 10:11:48 +0200 Subject: fix(cli): close the flavour-list call sites Typst's addition exposed The task this branch of work set out to test was whether the template engine is genuinely flavour-agnostic outside lib/render/escape.ml. It is not, quite: bin/main.ml's own --flavour error/help text and both man pages hand-typed the flavour list and its count ("the six flavours") as literal prose, so adding Typst as a seventh left three places silently wrong (an incomplete flavour list in two error messages, and "six" where the true count is now seven) until this commit. bin/main.ml's two error messages (unknown --flavour value, and cannot infer a flavour from an extension) now build their flavour list by walking Escape.all/to_string instead of a literal string, so the next flavour added will not reintroduce the same drift; the static --help body text and colitur(1)/colitur-templates(5) still name flavours and their count by hand; there was no equivalent gain available for prose formatted this specifically, so those were updated by hand instead, along with colitur-templates(5)'s FLAVOURS section, which gained typst's own subsection alongside latex/groff/html/xml/ics/none. test/cli.t's two pinned error-text assertions are updated to match, and gained a new case: .typ inferred from extension, and a real shipped citation's hyphen surviving --flavour typst's own escaping live, the same shape the 2035 Ss. Petri et Pauli case already proves for latex's ampersand just above it. --- test/cli.t | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'test/cli.t') diff --git a/test/cli.t b/test/cli.t index 610ce5b..ef1243e 100644 --- a/test/cli.t +++ b/test/cli.t @@ -621,18 +621,27 @@ An unknown extension with no --flavour is an error, not a silent fallback: $ printf 'x' > /tmp/t.wat $ colitur table --year 2027 --template /tmp/t.wat - colitur: cannot infer a flavour from ".wat"; pass --flavour latex|groff|html|xml|ics|none + colitur: cannot infer a flavour from ".wat"; pass --flavour latex|typst|groff|html|xml|ics|none [2] $ colitur table --year 2027 --template /tmp/t.wat --flavour none x -An unrecognised --flavour value is also an error naming the six valid ones: +An unrecognised --flavour value is also an error naming the seven valid ones: $ colitur table --year 2027 --template /tmp/t.txt --flavour bogus - colitur: unknown flavour "bogus" (want latex, groff, html, xml, ics or none) + colitur: unknown flavour "bogus" (want latex, typst, groff, html, xml, ics or none) [2] +Typst is inferred from .typ, like every other flavour's own extension. +Its metacharacters are escaped the same way latex's own is above -- here +'-', verified live (against the real typst binary) to collapse into an +en dash if left unescaped; a real shipped citation carries one: + + $ printf '{{#days}}{{first}}\n{{/days}}' > /tmp/t.typ + $ colitur table --year 2027 --template /tmp/t.typ | grep -c '11\\-16' + 1 + A malformed template is a clear error, not a crash: $ printf '{{#days}}oops' > /tmp/bad.txt -- cgit v1.3