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:
2 files changed
+8
-2
No files matched your search
@@ -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
|
||||
},
|
||||
|
||||
@@ -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}`);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user