diff --git a/main.ts b/main.ts index 9d86484..0d61c02 100644 --- a/main.ts +++ b/main.ts @@ -193,6 +193,7 @@ args.push('--standalone'); // Add resource paths for attachment resolution if (this.pandocOptions.vaultBasePath) { const path = require('path'); + const fs = require('fs'); // Add vault root as primary resource path args.push('--resource-path', this.pandocOptions.vaultBasePath); @@ -207,12 +208,38 @@ if (this.pandocOptions.vaultBasePath) { ]; // Check if these directories exist and add them - const fs = require('fs'); for (const attachPath of commonAttachmentPaths) { if (fs.existsSync(attachPath)) { args.push('--resource-path', attachPath); + console.log('Added resource path:', attachPath); } } + + // Also scan for note-specific attachment folders (Obsidian often creates these) + try { + const vaultContents = fs.readdirSync(this.pandocOptions.vaultBasePath); + for (const item of vaultContents) { + const itemPath = path.join(this.pandocOptions.vaultBasePath, item); + const stat = fs.statSync(itemPath); + if (stat.isDirectory() && !item.startsWith('.') && !item.startsWith('_')) { + // Check if this directory contains images + try { + const dirContents = fs.readdirSync(itemPath); + const hasImages = dirContents.some(file => + /\.(png|jpg|jpeg|gif|svg|webp|bmp|ico|tiff)$/i.test(file) + ); + if (hasImages) { + args.push('--resource-path', itemPath); + console.log('Added note-specific resource path:', itemPath); + } + } catch (e) { + // Ignore directories we can't read + } + } + } + } catch (e) { + console.warn('Could not scan vault for attachment directories:', e); + } } // Use -V template= syntax for Typst templates (not --template) @@ -1329,6 +1356,16 @@ try { console.warn('Preprocessing warnings:', processedResult.warnings); } + // Debug: Log processed content to see what image paths look like + console.log('Export: Original content length:', content.length); + console.log('Export: Processed content length:', processedResult.content.length); + + // Log a sample of processed content to see image references + const imageSample = processedResult.content.split('\n').filter(line => + line.includes('![') || line.includes('