Files
obsidian-typst-pdf-export/templates/universal-wrapper.pandoc.typ
T
Jarvis a0830e589b fix: correct unit handling for margins and font sizes in Typst export
- Add "cm" suffix to margin values (marginTop, marginBottom, marginLeft, marginRight) when passed from UI to Typst
- Add "pt" suffix to bodyFontSize values when passed from UI to Typst
- Remove obsolete heading_fontsize and small_fontsize parameters from templates
- Templates now use relative sizing (body-fontsize * multiplier) instead of separate font size variables

Fixes issue where Typst expected length units but received raw numbers, causing "expected relative length or auto, found float" errors during PDF export.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-03 17:02:28 +02:00

29 lines
2.1 KiB
Typst

// Universal Pandoc wrapper for all Typst templates
// This wrapper handles Pandoc's variable substitution and passes them to the actual Typst template
#import "$template_path$": conf, email-block
#show: doc => conf(
$if(title)$title: [$title$],$else$title: none,$endif$
$if(authors)$authors: ($for(authors)$(name: "$authors.name$", email: "$authors.email$", affiliation: "$authors.affiliation$")$sep$, $endfor$),$else$authors: (),$endif$
$if(date)$date: [$date$],$else$date: none,$endif$
$if(lang)$lang: "$lang$",$else$lang: "en",$endif$
$if(region)$region: "$region$",$else$region: "US",$endif$
$if(paper)$paper: "$paper$",$else$paper: "a4",$endif$
$if(margin)$margin: (x: $margin.x$, y: $margin.y$),$else$$if(margin_top)$margin: (top: $margin_top$, right: $if(margin_right)$$margin_right$$else$1.5cm$endif$, bottom: $if(margin_bottom)$$margin_bottom$$else$1.5cm$endif$, left: $if(margin_left)$$margin_left$$else$1.5cm$endif$),$else$margin: (x: 1.5cm, y: 1.5cm),$endif$$endif$
$if(cols)$cols: $cols$,$else$cols: 1,$endif$
$if(font)$font: ("$font$", "Concourse OT 3", "Helvetica Neue", "Arial"),$else$font: ("Concourse OT 3", "Helvetica Neue", "Arial"),$endif$
$if(fontsize)$fontsize: $fontsize$,$else$fontsize: 11pt,$endif$
$if(sectionnumbering)$sectionnumbering: "$sectionnumbering$",$else$sectionnumbering: "1.",$endif$
$if(pagenumbering)$pagenumbering: "$pagenumbering$",$else$pagenumbering: "1",$endif$
// Support for UI-configurable options
$if(heading_font)$heading_font: "$heading_font$",$else$heading_font: none,$endif$
$if(monospace_font)$monospace_font: "$monospace_font$",$else$monospace_font: none,$endif$
$if(margin_top)$margin_top: $margin_top$,$else$margin_top: none,$endif$
$if(margin_right)$margin_right: $margin_right$,$else$margin_right: none,$endif$
$if(margin_bottom)$margin_bottom: $margin_bottom$,$else$margin_bottom: none,$endif$
$if(margin_left)$margin_left: $margin_left$,$else$margin_left: none,$endif$
$if(orientation)$orientation: "$orientation$",$else$orientation: "portrait",$endif$
export_format: "$if(export_format)$$export_format$$else$standard$endif$",
[$body$]
)