Ensures that relative redirect URLs are resolved against the original image URL.
This prevents issues when downloading remote images from servers that return
relative redirect paths.
Ensures images without file extensions are properly handled by appending ".png" to the filename, preventing potential issues with image processing or display.
Preserves existing extensions for other image types (e.g., svg, ico, avif) without forcing a ".png" extension.
Adds comprehensive unit tests to improve code coverage for core functionalities: constants, paper size mapping, modal settings, security utilities, temporary directory management, and variable mapping.
This ensures that basic functionalities work as expected and enhances the reliability of the plugin.
Additionally, this commit includes a mock Obsidian API to facilitate testing in a non-Obsidian environment.
Removes unnecessary conditional logic when constructing paths for temporary directories.
The logic previously checked if the plugin directory was absolute before joining it with the directory name. This check is redundant as `path.join` correctly handles both absolute and relative paths.
Ensures that standard markdown images with remote URLs are processed for download after embeds and before wikilinks.
This ensures that remote URLs in the standard markdown format `` are correctly queued for download.
Consolidates local path resolution logic into a dedicated
`resolveLocalPath` method for improved code reuse and readability.
Improves image downloading by using the vault adapter to write
binary data, preventing potential data corruption.
This change addresses issues with image embed resolution,
especially for attachments in non-standard locations, and fixes
file overwriting during image downloads.
Simplifies the path joining logic by leveraging the built-in `path.join` method directly.
This change removes the manual iteration and absolute path handling, resulting in more concise and readable code.
Ensures correct path handling on Windows.
Refactors the code to leverage `path.join` for cross-platform path manipulation, especially improving handling of absolute paths on Windows.
Removes redundant normalizations and simplifies the logic for determining temporary directories. This change ensures consistent behavior across different operating systems and reduces code complexity.
Disables Pandoc's automatic citeproc filter to prevent errors
when processing documents without a bibliography file. This
resolves issues where Pandoc incorrectly detects citation-like
patterns in markdown and attempts to generate bibliographies,
leading to "document does not contain a bibliography" errors.
Addresses issues with path construction on Windows by using `path.isAbsolute()` to correctly handle absolute paths. Improves cross-platform compatibility in temp directory management and binary location.
Adds support for downloading and embedding remote images (http/https URLs) in markdown, enhancing content integration. Provides fallback mechanism with placeholder text upon download failure.
Updates the repository URLs in the README file to reflect the correct owner.
This ensures users are directed to the correct location for the project and its releases, especially for installation instructions.
Fixes TypeScript error by using the existing PathUtils.getVaultPath() method
which safely accesses FileSystemAdapter.getBasePath() with proper error handling.
The adapter.basePath property doesn't exist on DataAdapter interface.
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
Replace complex heuristic with precise pattern matching for absolute paths:
- Unix paths: starts with /
- Windows drive letters: C:\ or C:/ using regex /^[a-zA-Z]:[/\\]/
- Windows UNC paths: \\server\share
Removes unreliable temp/tmp path indicators and file: URL checks while
maintaining fs fallback behavior for proper external file processing.
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
- Set both PATH and Path environment variables for Windows compatibility
- Add tilde (~) path expansion for user home directories
- Implement actual path deduplication using Set instead of just filtering empty strings
- Properly split and combine existing PATH with additional platform-specific paths
Ensures spawned typst processes can find executables reliably across all platforms.
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
Prevents adapter.list() errors on absolute temp paths by detecting whether outputDir
is inside the vault and using filesystem fallback for external/absolute paths.
Only calls adapter.list() with vault-relative paths for proper Obsidian compatibility.
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
Improves binary validation by using fs.promises.access() as fallback when plugin context
is not available, ensuring cross-platform binary detection works reliably.
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
- Fixed adapter.list() call to use vault-relative path instead of absolute templatesPath
- Added proper path conversion by stripping vault base path and leading separators
- Ensures compatibility with Obsidian's vault.adapter API requirements
- Prevents potential file listing failures due to incorrect path format
- Maintains cross-platform path handling with proper separator normalization
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
- Fixed TempDirectoryManager.create() to pass plugin.manifest.id instead of undefined
- Ensures temp directory cleanup targets only this plugin's directories
- Prevents interference with other plugins' temp directories
- Improves plugin isolation and cleanup reliability
- Follows proper plugin namespacing patterns established earlier
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
- Replaced vulnerable string operations (startsWith/includes) with normalized path comparison
- Uses normalizePath() for proper cross-platform path normalization
- Constructs explicit temp directory paths for precise validation
- Prevents path traversal attacks like '../../../etc/passwd' or similar
- Ensures directory validation is based on actual path structure, not string matching
- Maintains functionality while improving security posture
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
- Fixed vault.adapter.remove() call to use vault-relative paths instead of absolute paths
- Added proper path conversion by stripping vault base path and leading separators
- Maintains fs.unlink fallback when plugin.app is not available
- Prevents potential file removal failures due to incorrect path format
- Follows Obsidian API best practices for vault operations
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
- Documents all CodeRabbit review improvements implemented
- Highlights Windows compatibility enhancements
- Details dynamic image format support and pattern matching
- Records cross-platform font discovery improvements
- Notes security and path validation enhancements
- Organizes changes by Added/Fixed/Changed/Security categories
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
- Fixed vault.adapter operations to use vault-relative paths instead of absolute paths
- Added platform detection to cache data for invalidation on OS changes
- Enhanced error recovery with corrupted cache detection and automatic regeneration
- Improved cache validation with structure and content checks
- Added platform-specific PATH building for better Typst executable discovery
- Enhanced Windows, macOS, and Linux font path resolution
- Added comprehensive fallback mechanisms for all error scenarios
- Improved type safety and error handling throughout
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
- Added pluginName parameter using manifest.id for proper temp directory namespacing
- Improves isolation when multiple similar plugins are installed
- Prevents temp directory conflicts between plugins
- Uses existing TempDirectoryOptions.pluginName field per CodeRabbit review
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
- Added support for multiple image formats (.png, .jpg, .jpeg, .webp, .gif, .bmp, .tiff)
- Replaced hardcoded PNG-only filtering with dynamic extension detection
- Enhanced pattern matching with 5 progressive strategies:
1. Exact filename match
2. Base name match with any supported extension
3. Sanitized pattern match (removes special characters)
4. Fuzzy match for pdf2img patterns (handles -1, -page1 suffixes)
5. Fallback to first available image file
- Updated generateExpectedFilename with format validation and warnings
- Improved error messages to show supported formats and available files
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
- Added support for Windows executable extensions (.cmd, .bat, .ps1, .exe)
- Implemented comprehensive fallback paths for different installation methods
- Enhanced binary discovery with Windows-specific npm locations
- Improved error reporting with detailed search path information
- Maintains backward compatibility for Unix-like systems
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
- Changed adapter.list() to use empty string for vault root instead of absolute path
- Convert vault-relative paths to absolute paths when returning for external tools
- Fixes cross-platform compatibility issues per CodeRabbit review
- Maintains existing functionality while following Obsidian API best practices
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
- Remove manual quotes around templatesDir path in PandocCommandBuilder
- Node.js spawn() handles argument quoting automatically
- Manual quotes can break path resolution, especially on Windows
- Follows Node.js best practices for child_process.spawn()
CodeRabbit suggestion implementation 1/6
- Fix pathUtils.fileExists() to handle absolute filesystem paths
- Add proper conversion from absolute to vault-relative paths
- Add fs fallback for external files outside vault
- Resolves 'File not found' errors for embedded PDF, image, and document files
- Maintains compatibility with both vault-relative and absolute paths
This fixes the path resolution issue that occurred after migrating to vault.adapter,
where embedded files were showing as 'not found' because absolute paths were being
passed to vault.adapter.exists() which only accepts vault-relative paths.
- Replace fs operations with vault.adapter methods
- Update constructor to require App parameter
- Make all methods async for vault.adapter compatibility
- Update PluginLifecycle.ts to match new async API
- Remove direct fs/path module dependencies
- Build and lint pass successfully
Safety commit 16/16 - Path migration complete!
- Replace fs.unlink/rename with vault.adapter methods when plugin available
- Replace path.join with PathUtils.joinPath for vault paths
- Add plugin parameter to optimizeImage method for vault.adapter access
- Keep path module for external tool operations
- Add fs fallbacks for temp file operations when plugin unavailable
- Use readBinary/writeBinary pattern for image file moves
- Update PdfToImageConverter.ts to pass plugin to ImageOptimizer
- Maintain dual approach for vault and external temp file handling
- Replace all fs operations with vault.adapter methods
- Replace fs.readdirSync with vault.adapter.list for directory scanning
- Replace fs.existsSync with PathUtils.fileExists
- Replace path.join with PathUtils.joinPath for vault paths
- Remove fs/fsPromises imports, add PathUtils import
- Add plugin parameter to constructor for vault.adapter access
- Update PandocCommandBuilder to pass plugin to ResourcePathResolver
- Maintain resource discovery functionality for Pandoc
- Replace fs.promises operations with vault.adapter methods
- Replace path.join with PathUtils.joinPath for temp file paths
- Replace fsPromises.writeFile/unlink with vault.adapter.write/remove
- Replace fsPromises.rmdir with PathUtils.cleanupDir
- Remove unused path and os imports
- Use TempDirectoryManager consistently for both fallback cases
- Replace path.join operations with PathUtils methods
- Remove path module import, use PathUtils for all path operations
- Already used vault.adapter correctly for file operations
- Maintain consistency with other migrated files
- Replace unsafe basePath cast with PathUtils.getVaultPath()
- Replace fs.existsSync with PathUtils.fileExists()
- Remove fs fallbacks since app is always available in Obsidian
- Keep path module for command-line path building
- Add proper null checking for plugin.app
- Replaced fs.promises.access with PathUtils.fileExists() for file existence checks
- Replaced fs.promises.mkdir with PathUtils.ensureDir() for directory creation
- Replaced fs.promises.copyFile with vault.adapter readBinary/writeBinary operations
- Replaced path.join with PathUtils.joinPath() for consistent path normalization
- Updated all file resolution methods to use proper Obsidian API methods
- Removed fs import and all direct filesystem operations
- Enhanced copyImageToVaultTemp to use vault.adapter for binary file operations
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
- Replaced multiple basePath hacks (lines 25, 70, 86) with PathUtils.getVaultPath()
- Replaced path.join with PathUtils.joinPath() and getPluginDir()
- Removed path import after migration to PathUtils
- Added PathUtils integration for consistent path operations
- All three basePath hack locations now use proper Obsidian API methods
- TempDirectoryManager calls already updated in previous commit
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
- Replaced basePath hack with PathUtils.getVaultPath() and getPluginDir()
- Replaced fs.existsSync with vault.adapter.exists() via PathUtils.fileExists()
- Replaced fs.readdirSync with vault.adapter.list() for directory listing
- Replaced fs.readFileSync with vault.adapter.read() for template content
- Replaced path.join with PathUtils.joinPath() for consistent normalization
- Removed fs import and all direct filesystem operations
- All template operations now use proper Obsidian API methods
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
- Replaced unsafe basePath hack with PathUtils.getVaultPath()
- Replaced fs.promises.access/mkdir with vault.adapter methods via PathUtils.ensureDir()
- Replaced path.join with PathUtils.joinPath() for consistent normalization
- Removed fs import and direct filesystem operations
- Simplified error handling with PathUtils abstraction
- All path operations now use proper Obsidian API methods
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
- Updated TempDirectoryManager to use vault.adapter methods exclusively
- Made all temp directory operations async (ensureTempDir, cleanupTempDir, cleanupAllTempDirs)
- Removed unnecessary fs fallback since App instance is always available in Obsidian plugins
- Updated calling code in PandocTypstConverter and ExportOrchestrator to handle async
- Updated PluginLifecycle cleanup methods to use fire-and-forget async pattern
- All path operations now use normalizePath for cross-platform compatibility
- Simplified interface - App parameter is now required as it should be
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
- Add ABOUTME comments following guidelines
- Implement safe FileSystemAdapter access with proper type checking
- Use vault.adapter methods (exists, mkdir, list, remove)
- Use normalizePath() consistently for all paths
- Match existing patterns (cleanupDir only removes files, returns boolean)
- Add user-friendly error messages with Notice
- Place in src/core/ alongside other core utilities
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>