Enhances path handling and file resolution #5

Merged
AlexKucera merged 36 commits from 1.3.0 into master 2025-09-25 16:47:12 +02:00
Showing only changes of commit f8142f995a - Show all commits
@@ -9,6 +9,7 @@ import { TypstVariableMapper } from './TypstVariableMapper';
import { ResourcePathResolver } from './ResourcePathResolver';
import { PathResolver } from '../../plugin/PathResolver';
import type { obsidianTypstPDFExport } from '../../../main';
import { PathUtils } from '../../core/PathUtils';
export class PandocCommandBuilder {
private plugin: obsidianTypstPDFExport;
@@ -95,19 +96,19 @@ export class PandocCommandBuilder {
private async addTemplateConfiguration(args: string[], pandocOptions: PandocOptions): Promise<void> {
// Use universal wrapper with --template and pass actual template as template_path variable
if (pandocOptions.template) {
const fs = require('fs');
const pathUtils = new PathUtils(this.plugin.app);
const absolutePluginDir = pandocOptions.pluginDir || '';
const wrapperPath = path.resolve(absolutePluginDir, 'templates', 'universal-wrapper.pandoc.typ');
const wrapperPath = pathUtils.joinPath(absolutePluginDir, 'templates', 'universal-wrapper.pandoc.typ');
// Verify wrapper exists
if (!fs.existsSync(wrapperPath)) {
if (!(await pathUtils.fileExists(wrapperPath))) {
throw new Error(`Universal wrapper template not found at: ${wrapperPath}`);
}
args.push('--template', wrapperPath);
// Add plugin templates directory as a resource path so Typst can find template files
const templatesDir = path.resolve(absolutePluginDir, 'templates');
const templatesDir = pathUtils.joinPath(absolutePluginDir, 'templates');
// Quote the path to handle spaces and special characters
args.push('--resource-path', `"${templatesDir}"`);
1