From 006d45c890eb783ec885ebd0f67f7d6f0e7d1830 Mon Sep 17 00:00:00 2001 From: Dandaedre Date: Wed, 16 Sep 2026 17:38:55 +0200 Subject: [PATCH] Style inline raw text as compact pills --- docs/report-contract.md | 2 +- templates/report.typ | 4 ++++ tests/test_render.py | 4 ++-- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/docs/report-contract.md b/docs/report-contract.md index 2ba27e7..b98c709 100644 --- a/docs/report-contract.md +++ b/docs/report-contract.md @@ -84,7 +84,7 @@ are rejected, including legacy `diagnostics`, top-level `organization` and named Unknown or misspelled blocks fail validation. Text and commands are data, not code for the validator to execute. The renderer must preserve that boundary. Within a `text` block, balanced single backticks mark inline code, for example -`` `5661ea1` ``. The renderer uses Typst's inline raw text for the marked span; +`` `5661ea1` ``. The renderer shows Typst's inline raw text as a small rounded pill; unmatched backticks remain literal. This formatting never executes report text. Cards render as rounded, shaded panels. Omit `tone` for a neutral panel or set it to a severity token to tint its border and background. A card may contain diff --git a/templates/report.typ b/templates/report.typ index 2fe3acb..518404c 100644 --- a/templates/report.typ +++ b/templates/report.typ @@ -91,6 +91,10 @@ text(size: 7pt, fill: muted)[Page #counter(page).display()])) #set text(font: get(theme, "font", default: "DejaVu Sans"), size: 9.5pt, fill: ink) #set par(leading: 0.58em, spacing: 0.55em) +#show raw.where(block: false): box.with( + fill: soft, stroke: 0.5pt + line-color, radius: 3pt, + inset: (x: 4pt, y: 1pt), outset: (y: 1pt), +) #text(size: 22pt, weight: "bold", fill: accent)[#as-text(report.title)] #if "subtitle" in report { v(3pt); text(size: 11pt, fill: muted)[#as-text(report.subtitle)] } diff --git a/tests/test_render.py b/tests/test_render.py index 425ca63..afcf955 100644 --- a/tests/test_render.py +++ b/tests/test_render.py @@ -107,8 +107,8 @@ class RenderTests(unittest.TestCase): renderer.render(input_path, output, TYPST) self.assert_pdf(output) if PDFTOTEXT: - extracted = subprocess.check_output([PDFTOTEXT, str(output), "-"], text=True) - self.assertIn("Pinned 5661ea1 and 5969196.", extracted) + extracted = subprocess.check_output([PDFTOTEXT, "-layout", str(output), "-"], text=True) + self.assertRegex(extracted, r"Pinned\s+5661ea1\s+and\s+5969196\s*\.") self.assertIn("Unmatched ` stays literal.", extracted) def test_existing_output_requires_force_and_input_is_never_output(self):