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>
This commit is contained in:
2 files changed
+5
-8
No files matched your search
@@ -379,6 +379,7 @@ export class PandocTypstConverter {
|
|||||||
break;
|
break;
|
||||||
case 'bodyFontSize':
|
case 'bodyFontSize':
|
||||||
variableName = 'fontsize';
|
variableName = 'fontsize';
|
||||||
|
processedValue = value + 'pt';
|
||||||
break;
|
break;
|
||||||
case 'pageSize':
|
case 'pageSize':
|
||||||
variableName = 'paper';
|
variableName = 'paper';
|
||||||
@@ -387,15 +388,19 @@ export class PandocTypstConverter {
|
|||||||
break;
|
break;
|
||||||
case 'marginTop':
|
case 'marginTop':
|
||||||
variableName = 'margin_top';
|
variableName = 'margin_top';
|
||||||
|
processedValue = value + 'cm';
|
||||||
break;
|
break;
|
||||||
case 'marginBottom':
|
case 'marginBottom':
|
||||||
variableName = 'margin_bottom';
|
variableName = 'margin_bottom';
|
||||||
|
processedValue = value + 'cm';
|
||||||
break;
|
break;
|
||||||
case 'marginLeft':
|
case 'marginLeft':
|
||||||
variableName = 'margin_left';
|
variableName = 'margin_left';
|
||||||
|
processedValue = value + 'cm';
|
||||||
break;
|
break;
|
||||||
case 'marginRight':
|
case 'marginRight':
|
||||||
variableName = 'margin_right';
|
variableName = 'margin_right';
|
||||||
|
processedValue = value + 'cm';
|
||||||
break;
|
break;
|
||||||
// Keep other variables as-is (orientation, flipped, width, etc.)
|
// Keep other variables as-is (orientation, flipped, width, etc.)
|
||||||
}
|
}
|
||||||
@@ -430,12 +435,6 @@ export class PandocTypstConverter {
|
|||||||
if (!existingVars.bodyFontSize && !existingVars.fontsize && settings.typography.fontSizes.body) {
|
if (!existingVars.bodyFontSize && !existingVars.fontsize && settings.typography.fontSizes.body) {
|
||||||
args.push('-V', `fontsize=${settings.typography.fontSizes.body}pt`);
|
args.push('-V', `fontsize=${settings.typography.fontSizes.body}pt`);
|
||||||
}
|
}
|
||||||
if (!existingVars.heading_fontsize && settings.typography.fontSizes.heading) {
|
|
||||||
args.push('-V', `heading_fontsize=${settings.typography.fontSizes.heading}pt`);
|
|
||||||
}
|
|
||||||
if (!existingVars.small_fontsize && settings.typography.fontSizes.small) {
|
|
||||||
args.push('-V', `small_fontsize=${settings.typography.fontSizes.small}pt`);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -19,8 +19,6 @@
|
|||||||
// Support for UI-configurable options
|
// Support for UI-configurable options
|
||||||
$if(heading_font)$heading_font: "$heading_font$",$else$heading_font: none,$endif$
|
$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(monospace_font)$monospace_font: "$monospace_font$",$else$monospace_font: none,$endif$
|
||||||
$if(heading_fontsize)$heading_fontsize: $heading_fontsize$,$else$heading_fontsize: none,$endif$
|
|
||||||
$if(small_fontsize)$small_fontsize: $small_fontsize$,$else$small_fontsize: none,$endif$
|
|
||||||
$if(margin_top)$margin_top: $margin_top$,$else$margin_top: 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_right)$margin_right: $margin_right$,$else$margin_right: none,$endif$
|
||||||
$if(margin_bottom)$margin_bottom: $margin_bottom$,$else$margin_bottom: none,$endif$
|
$if(margin_bottom)$margin_bottom: $margin_bottom$,$else$margin_bottom: none,$endif$
|
||||||
|
|||||||
Reference in new issue
Block a user