Prioritizes config format in template variables

Ensures that the format specified in the export configuration
takes precedence over the default format specified in the settings
when populating template variables for PDF conversion.

Additionally, only uses the settings default for the export format
if one is not already provided.
This commit is contained in:
AlexKucera committed 2025-09-03 19:21:13 +02:00
1 parent 247d5add36
commit 42ad862ba0
2 files changed
+8 -2

No files matched your search

+7 -1
View File
@@ -573,12 +573,18 @@ export class obsidianTypstPDFExport extends Plugin {
this.templateManager.getTemplatePath('default.typ');
// Convert to PDF using the preprocessed content
const templateVariables = {
...(config.templateVariables || {}),
// Add format from config if specified (takes priority over settings default)
...(config.format && { export_format: config.format })
};
const result = await this.converter.convertMarkdownToPDF(
processedResult.content, // Use preprocessed content instead of raw content
outputPath,
{
template: templatePath,
variables: config.templateVariables || {},
variables: templateVariables,
pluginDir: pluginDir,
vaultBasePath: vaultPath
},
+1 -1
View File
@@ -466,7 +466,7 @@ export class PandocTypstConverter {
}
}
// Add export format variable
// Add export format variable - only use settings default if not already provided
if (!existingVars.export_format && settings.exportDefaults && settings.exportDefaults.format) {
args.push('-V', `export_format=${settings.exportDefaults.format}`);
}