Skip to content

Commit 5831cb0

Browse files
committed
Port Pandoc 3.13 typst terms hanging indent and keyword nowrap
Pandoc 3.13 replaced its custom terms.item show rule with #set terms(hanging-indent: 1.5em), because the typst writer no longer wraps tight definition-list descriptions in #block (jgm/pandoc#11748). Keeping the old rule on 3.13 forced every description onto the line below its term; the set rule restores Typst's native layout where tight items keep the description on the term's line. Also port the /nowrap modifier on template keywords for parity with upstream default.typst. It is a no-op in Quarto's pipeline, which renders templates with wrap: none. The definition-item-no-break smoke test asserted the old two-line layout; it is replaced by definition-lists.qmd asserting the new geometry for tight and loose items.
1 parent cd4aa33 commit 5831cb0

5 files changed

Lines changed: 45 additions & 31 deletions

File tree

‎llm-docs/pandoc-quarto-typst-templates.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ Two files are copied from Pandoc for typst support:
3636

3737
**default.typst** (becomes `typst.template`): The main Pandoc template that orchestrates the document structure. It:
3838
- Defines a horizontal rule helper
39-
- Sets up term list rendering with indented descriptions
39+
- Sets up term list rendering with a hanging indent
4040
- Configures table styling with no strokes
4141
- Sets figure caption positions for tables (top) and images (bottom)
4242
- Optionally includes syntax highlighting definitions
@@ -87,7 +87,7 @@ Combines Pandoc definitions with Quarto-specific functionality:
8787
**From Pandoc**:
8888
- `content-to-string` helper to extract text from content nodes (used for PDF metadata and link colors)
8989
- `horizontalrule` definition for horizontal rules
90-
- Term list show rule with indented descriptions
90+
- Term list hanging indent (`#set terms(hanging-indent: 1.5em)`; Pandoc 3.13 dropped its custom `terms.item` show rule)
9191
- Code highlighting definitions (conditionally included)
9292

9393
**Quarto additions**:

‎src/resources/formats/typst/pandoc/quarto/definitions.typ‎

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,7 @@
1717
#stack(dir: ltr, spacing: 3pt, super[#num], contents)
1818
]
1919

20-
#show terms.item: it => block(breakable: false)[
21-
#text(weight: "bold")[#it.term]
22-
#block(inset: (left: 1.5em, top: -0.4em))[#it.description]
23-
]
20+
#set terms(hanging-indent: 1.5em)
2421

2522
// Some quarto-specific definitions.
2623

‎src/resources/formats/typst/pandoc/quarto/typst-show.typ‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ $if(filecolor)$
8585
filecolor: [$filecolor$],
8686
$endif$
8787
$if(keywords)$
88-
keywords: ($for(keywords)$"$keywords$",$endfor$),
88+
keywords: ($for(keywords)$"$keywords/nowrap$",$endfor$),
8989
$endif$
9090
$if(toc)$
9191
toc: $toc$,

‎tests/docs/smoke-all/typst/definition-item-no-break.qmd‎

Lines changed: 0 additions & 24 deletions
This file was deleted.
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
---
2+
title: "Definition List Layout Test"
3+
format: typst
4+
_quarto:
5+
tests:
6+
typst:
7+
ensurePdfTextPositions:
8+
- # Tight item: description sits on the same line as the term
9+
- subject: "TIGHTTERM"
10+
relation: leftOf
11+
object: "TIGHTDESC"
12+
- subject: "TIGHTTERM"
13+
relation: topAligned
14+
object: "TIGHTDESC"
15+
# Loose item: description stays in a block below the term
16+
- subject: "LOOSETERM"
17+
relation: above
18+
object: "LOOSEDESC"
19+
- # Description of a loose item is indented, never left-aligned with its term
20+
- subject: "LOOSEDESC"
21+
relation: leftAligned
22+
object: "LOOSETERM"
23+
noErrors: default
24+
---
25+
26+
Pandoc 3.13 renders definition lists with Typst's native `terms` element and a
27+
hanging indent (upstream replaced its custom `terms.item` show rule with
28+
`#set terms(hanging-indent: 1.5em)`). Tight items keep the description on the
29+
term's line; loose items keep the block layout. Quarto's template ports that
30+
rule, and this document checks both layouts in the PDF.
31+
32+
A tight item:
33+
34+
TIGHTTERM
35+
: TIGHTDESC wraps onto the term line when the item is tight.
36+
37+
A loose item:
38+
39+
LOOSETERM
40+
41+
: LOOSEDESC stays below the term because the item is loose.

0 commit comments

Comments
 (0)