From 9124531c58d341b37e39b317a80d2247b7aad738 Mon Sep 17 00:00:00 2001 From: Alexander Kucera Date: Thu, 11 Sep 2025 12:11:33 +0200 Subject: [PATCH] Improves Typst error reporting in Pandoc conversion Replaces intermediate Typst file generation with enhanced diagnostic options Adds short diagnostic format for better error reporting during Typst PDF engine conversion Removes complex intermediate file generation and debug file copying logic Simplifies command builder by focusing on diagnostic improvements --- src/converters/pandoc/PandocCommandBuilder.ts | 33 ++++--------------- src/converters/pandoc/PandocExecutor.ts | 4 --- 2 files changed, 6 insertions(+), 31 deletions(-) diff --git a/src/converters/pandoc/PandocCommandBuilder.ts b/src/converters/pandoc/PandocCommandBuilder.ts index b404fd4..ca88717 100644 --- a/src/converters/pandoc/PandocCommandBuilder.ts +++ b/src/converters/pandoc/PandocCommandBuilder.ts @@ -60,8 +60,8 @@ export class PandocCommandBuilder { // Add Typst engine options this.addTypstEngineOptions(args, pandocOptions); - // Generate intermediate Typst file if requested - await this.addIntermediateTypstOutput(args, pandocOptions); + // Add enhanced Typst diagnostics for better error reporting + this.addTypstDiagnostics(args, pandocOptions); // Set working directory for relative paths if (pandocOptions.vaultBasePath) { @@ -147,32 +147,11 @@ export class PandocCommandBuilder { } /** - * Generate intermediate Typst file if requested + * Add enhanced Typst diagnostics for better error reporting */ - private async addIntermediateTypstOutput(args: string[], pandocOptions: PandocOptions): Promise { - if (!pandocOptions.generateIntermediateTypst || !pandocOptions.tempDir) { - return; - } - - const typstPath = path.join(pandocOptions.tempDir, 'intermediate.typ'); - args.push('--output', typstPath); - - // Also create a copy to keep for debugging - const debugTypstPath = path.join(pandocOptions.tempDir, 'debug.typ'); - // Store cleanup handler in pandocOptions to be handled by the caller - if (!pandocOptions.cleanupHandlers) { - pandocOptions.cleanupHandlers = []; - } - pandocOptions.cleanupHandlers.push(() => { - try { - const fs = require('fs'); - if (fs.existsSync(typstPath)) { - fs.copyFileSync(typstPath, debugTypstPath); - } - } catch (e) { - console.warn('Could not create debug Typst file:', e); - } - }); + private addTypstDiagnostics(args: string[], pandocOptions: PandocOptions): void { + // Add Typst diagnostic options for better error reporting + args.push('--pdf-engine-opt', '--diagnostic-format=short'); } } \ No newline at end of file diff --git a/src/converters/pandoc/PandocExecutor.ts b/src/converters/pandoc/PandocExecutor.ts index c31ec0b..cfdac7d 100644 --- a/src/converters/pandoc/PandocExecutor.ts +++ b/src/converters/pandoc/PandocExecutor.ts @@ -30,10 +30,6 @@ export class PandocExecutor { const pandocPath = this.pathResolver.resolveExecutablePath(pandocOptions.pandocPath, 'pandoc'); const timeout = pandocOptions.timeout || 60000; - // Log the exact command being executed for debugging - - progressCallback?.('Starting Pandoc process...', 40); - // Determine working directory - use vault base path if available, fallback to plugin directory let workingDir: string;