Commit Graph
38 Commits
Author SHA1 Message Date
Jarvis 70241a012c feat: add PDF embedding and frontmatter display controls
- Add embedPdfFiles setting to control PDF attachment embedding
- Add printFrontmatter setting to display frontmatter as formatted text
- Implement frontmatter formatting with proper line breaks and bullet lists
- Add settings toggles to both plugin settings and export modal
- Fix filename sanitization for PDF preview images with spaces
- Ensure modal export config includes new behavior settings
- Always generate PDF preview images regardless of embedding setting

The frontmatter display formats long comma-separated values (like email lists)
as bulleted lists and adds proper line breaks after each property label.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-04 22:15:08 +02:00
AlexKucera a15caaef1e Adds type safety to process event handlers
Specifies the types for data and close events in process handlers.

This improves code clarity and maintainability by ensuring that the
data received from stdout and stderr streams is treated as a Buffer,
and the close event receives a number or null for the exit code.
2025-09-04 16:40:02 +02:00
AlexKucera 2c5b916978 Improves resource path caching error handling
Moves the catch block for resource path scanning to be inside the try block.
This ensures that errors during resource path caching do not prevent the timestamp from being updated, potentially leading to repeated scanning.
2025-09-04 16:38:02 +02:00
Jarvis 3fc6219ad1 WIP: Sharp removal changes 2025-09-04 16:32:12 +02:00
AlexKucera 1b3f83e6e6 Improves export performance with resource path caching
Implements a cache for resource paths to avoid rescanning the vault directory on every export.

This significantly improves the speed of subsequent exports,
especially when the vault contains a large number of files. The cache
expires after a configurable interval (default: 5 minutes) to ensure
that new or removed resources are eventually reflected.
2025-09-04 15:17:35 +02:00
AlexKucera 557a0675be Refactors file stat to use async API
Updates file stat operation to use the asynchronous API
to prevent blocking the event loop during file system operations.

This improves the responsiveness of the application, especially
when dealing with potentially slow or numerous file system accesses.
2025-09-04 15:03:43 +02:00
AlexKucera c872a56bc2 Improves error reporting for template loading.
Adds error message to the notice when loading templates fails, providing more context for debugging.
2025-09-04 14:36:41 +02:00
AlexKucera e48af55635 Adds robustness to file system operations
Improves error handling when creating directories,
loading, and saving settings. This prevents crashes and
provides more informative error messages to the user.

Adds a try-catch block to `fs.statSync` to handle cases where a
file might be deleted between `readdirSync` and `statSync`,
preventing program termination.
2025-09-03 23:09:36 +02:00
AlexKucera 42aa8e176c Adds output path validation for enhanced security
Enhances security by validating output paths and executable paths.

This prevents path traversal attacks and command injection vulnerabilities
by ensuring that users can only specify valid relative paths within the vault
and safe executable paths. It also displays notices when the path is deemed unsafe.
2025-09-03 22:56:30 +02:00
AlexKucera f00bc88bb2 Improves dependency checking security
Replaces `child_process.exec` with `child_process.spawn` for both asynchronous and synchronous dependency checks.
This change mitigates potential command injection vulnerabilities by passing arguments separately, enhancing the security of the application.
2025-09-03 22:33:29 +02:00
AlexKucera 3f8f2b2089 Refactors project structure for improved modularity
Moves components and modules to more appropriate directories.

This change improves project organization and maintainability by grouping related files into logical directories, enhancing code discoverability and reducing potential naming conflicts.
2025-09-03 22:05:45 +02:00
AlexKucera a2020c90f3 Introduces temp directory management
Centralizes temporary directory creation and cleanup using a dedicated `TempDirectoryManager` class.

This change improves code maintainability and reduces redundancy by encapsulating temporary directory logic.

It also ensures that temporary directories are properly cleaned up after export operations, preventing potential disk space issues.
2025-09-03 19:48:43 +02:00
AlexKucera f9a6166da3 Centralizes export error handling
Introduces `ExportErrorHandler` to manage export-related errors, progress notices, and batch results.

This change provides a unified way to handle errors, display progress, and report results of export operations, improving code maintainability and user experience.
2025-09-03 19:43:52 +02:00
AlexKucera 608a51b81e Refactors export modal settings preparation
Introduces a helper class to encapsulate the logic for preparing the export configuration modal settings.

This improves code readability and maintainability by extracting the complex settings preparation logic from the main plugin file.
The helper handles both single and multi-file export scenarios, ensuring consistent settings across different export contexts.
2025-09-03 19:38:43 +02:00
AlexKucera d0b096368f Refactors dependency checking into a class
Consolidates dependency checking logic into a dedicated `DependencyChecker` class.
This improves code organization and reusability.
It now uses a single method for checking all dependencies, both asynchronously (for displaying status) and synchronously (for startup checks).
It also augments the PATH environment variable to include common binary locations to improve detection.

The status modal now displays more detailed information about each dependency.
2025-09-03 19:35:07 +02:00
AlexKucera 5fc8e348f4 Refactors fallback fonts into a constant
Moves the list of fallback fonts to a dedicated constant file.
This improves code readability and maintainability by centralizing
this configuration.
2025-09-03 19:31:19 +02:00
AlexKucera ccc0e5aec6 Delete Unused Code 2025-09-03 19:23:44 +02:00
AlexKucera 42ad862ba0 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.
2025-09-03 19:21:13 +02:00
Jarvis fbdebc95dd feat: add multi-file export support using files-menu event
- Add files-menu event handler for multi-file selection in file explorer
- Create exportFiles() method for batch export with default settings
- Create showExportModalForFiles() method for batch export with configuration
- Add exportFilesWithConfig() helper for batch processing
- Update ExportConfigModalSettings to support files array
- Update modal header to show file count for multi-file exports
- Users can now select multiple files and export them all at once
- Maintains backward compatibility with single file exports

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-03 17:39:39 +02:00
AlexKucera 819b127987 Improves export config modal and template vars
Refactors the export configuration modal to provide a better user experience and more accurate default values.

- Removes the batch export feature from the right-click menu.
- Updates the template variables to derive from the settings tab.
- Modifies the reset function in the export config modal to reset to plugin defaults.
- Improves font handling and font size settings in the TypographySection of the export config modal, including slider for font size.
- Enhances default template variable initialization in the ModalState.
2025-09-03 17:04:29 +02:00
Jarvis a0830e589b fix: correct unit handling for margins and font sizes in Typst export
- Add "cm" suffix to margin values (marginTop, marginBottom, marginLeft, marginRight) when passed from UI to Typst
- Add "pt" suffix to bodyFontSize values when passed from UI to Typst
- Remove obsolete heading_fontsize and small_fontsize parameters from templates
- Templates now use relative sizing (body-fontsize * multiplier) instead of separate font size variables

Fixes issue where Typst expected length units but received raw numbers, causing "expected relative length or auto, found float" errors during PDF export.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-03 17:02:28 +02:00
AlexKucera 26ddbb7f35 Enhances paper size selection and handling
Updates the paper size selection in settings and modals to use a predefined list of supported sizes, ensuring consistency across the plugin and compatibility with Typst.

It also maps the selected paper size to its Typst equivalent before passing it to the converter, preventing issues with unsupported sizes.
The change also ensures that template validation uses the correct paper sizes.
2025-09-03 14:35:34 +02:00
AlexKucera c749852125 Simplifies margin handling to use centimeters
Updates the margin settings to directly use centimeters, removing unnecessary conversions to points.
This simplifies the configuration and improves accuracy in setting page margins for PDF exports.
The settings tab and modal now accept and display margins in centimeters.
2025-09-03 13:59:35 +02:00
AlexKucera 6eedeaace3 Adds export configuration modal sections
Adds sections to the export configuration modal for behavior, page setup, and typography.

These sections allow users to configure export behavior like opening the PDF after export and preserving folder structure, as well as page setup options like page size, orientation, and margins.
Additionally, typography options for font selection and size configuration are included.
Updates default settings for export format and adds default values for new settings.

Removes the old TypographySection file.
2025-09-03 10:16:48 +02:00
AlexKucera 0e89488cf7 Adds folder path autocompletion
Implements a folder suggestion component that provides
autocomplete for existing vault folders in folder path inputs.

This enhances the user experience by making it easier to select
existing folders when specifying file paths.
2025-09-03 10:16:11 +02:00
Jarvis 99da5f6cee fix: resolve export modal and PDF embed processing issues
- Fix font size duplication bug (11pt11pt) in exportFileWithConfig
- Fix modal settings not being respected by removing conditional fallbacks
- Fix Export Current Note to include complete template variables
- Fix PDF embed processing temp directory from system temp to plugin temp
- Fix pdf2img to use relative paths instead of absolute paths for proper file creation
- Ensure temp-images directory exists before PDF processing

The export modal now properly respects all user settings and PDF embeds
are correctly processed and found during export operations.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-03 10:15:19 +02:00
Jarvis 172a69161d feat: refactor export system and improve PDF/email handling
Major improvements to PDF export functionality and code organization:

- BREAKING: Refactor main.ts from 4224 to 994 lines by extracting modular components
- Replace broken PDF links with proper Typst pdf.embed() attachments
- Filter out unnecessary "Open:" links and Mail.app links from exports
- Fix duplicate title issue by replacing frontmatter title with filename
- Move temp file processing from system temp to plugin folder
- Clean up temp-images and temp-pandoc directories after export
- Remove timestamp from export filenames to match note names exactly
- Handle Unicode line separators (0x2028, 0x2029) in email content
- Improve markdown preprocessing with better frontmatter handling

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-02 17:16:55 +02:00
Jarvis a60b2a8efd feat(markdown): add email block support for Obsidian to Typst conversion
- Implement email block detection and parsing in MarkdownPreprocessor
- Convert Obsidian email blocks to Typst #email-block() function calls
- Add Pandoc raw blocks wrapper for proper Typst code execution
- Import email-block function in universal wrapper template
- Disable smart quotes with --from markdown-smart flag

Fixes email blocks appearing as plain text in PDF exports

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-01 20:34:43 +02:00
AlexKucera 00292f8146 Replaces a built-in template
Updates the list of built-in templates, replacing 'single-page.typ' with 'modern.typ'.
This change reflects a shift in the default template options, offering users a more contemporary template choice.
2025-09-01 12:04:26 +02:00
Jarvis 3fd6dde592 fix: resolve all TypeScript build errors and improve type safety
Comprehensive fix for 26+ TypeScript compilation errors to enable successful builds:

- Update tsconfig.json: Add ES2015/ES2017 libs for iterator support
- Add missing type exports: Create central export location in CSSExtractor.ts
- Fix interface definitions: Add optimizeForPrint to MappingOptions
- Fix access modifiers: Make mapCSSProperty public in CSSToTypstMapper
- Add missing methods: getEnhancedThemeProfile and extractThemeStyles to PopularThemeSupport
- Fix null/undefined type issues: Update return types for proper TypeScript compliance
- Fix NodeList iteration: Convert to Array.from() for ES6 iterator compatibility
- Fix template validator: Resolve condition logic and index signature errors

All TypeScript compilation errors are now resolved while maintaining code functionality.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-31 16:10:59 +02:00
Jarvis 532bc04455 feat: add comprehensive image embed support with WebP conversion
- Implement image embed processing similar to PDF embed handling
- Add marker-based preprocessing for async image resource handling
- Support all three Obsidian image linking patterns:
  - Shortest path (filename only): ![[auf_der_couch.png]]
  - Note-relative paths: ![[2023-05-04.../image.jpeg]]
  - Vault-relative paths: ![[../attachments/image.webp]]
- Add automatic WebP to PNG conversion using ImageMagick
- Copy images to vault temp directory for Typst accessibility
- Handle multiple path resolution strategies with fallback options
- Add comprehensive error handling and logging for image processing

Resolves image export issues where only text was included in PDF exports.
Images are now properly resolved, copied, and converted as needed for
Typst compatibility.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-31 15:03:00 +02:00
Jarvis b9fb1a455f feat: add PDF embed support with first-page preview generation
- Implement PdfToImageConverter using pdf-to-img CLI for PDF-to-image conversion
- Add PDF embed detection and processing in MarkdownPreprocessor
- Generate first-page preview images for PDF embeds in exported documents
- Copy generated images to vault location for Typst accessibility
- Add --embed-resources flag to Pandoc for proper resource embedding
- Support both image and PDF attachments in exported documents

Fixes issue where PDF exports only contained text without attachments.
PDF embeds now show visual previews like Obsidian's native behavior.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-31 14:39:57 +02:00
Jarvis d765f09402 fix: Process embeds before wikilinks to prevent incorrect .md extensions on images
- Reorder processing steps: embeds first, then wikilinks
- Prevents ![[image.jpg]] from becoming ![](image.jpg.md)
- Ensures image filenames remain correct for Pandoc/Typst resolution

This fixes the core issue where image files were getting .md extensions
appended, causing Typst to look for non-existent .md files instead of
the actual image files.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-30 17:57:31 +02:00
Jarvis c9bd4cb210 fix: Add attachment support to PDF export
- Run Pandoc from vault directory for proper path resolution
- Add --resource-path arguments for attachment directories
- Use absolute template paths when working directory is vault
- Preserve relative attachment paths in MarkdownPreprocessor
- Support common attachment folder structures (attachments/, assets/, files/, images/)

Fixes issue where exported PDFs only contained text without embedded images/attachments.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-30 17:50:45 +02:00
Jarvis 0d81bb31b4 feat: implement CSS extraction and style preservation system (task 8)
Complete implementation of comprehensive CSS extraction system for
theme-aware Typst PDF exports:

- CSSExtractor.ts: Core DOM style extraction with theme detection
- CSSToTypstMapper.ts: CSS to Typst property conversion with color parsing
- ThemeManager.ts: Theme-specific variable handling for popular themes
- PopularThemeSupport.ts: Enhanced support for Minimal, Blue Topaz, Sanctum
- PluginSpecificStyleHandler.ts: Style extraction for Dataview, Templater, etc
- HybridExportMode.ts: Main integration system with conflict resolution
- Updated index.ts to export all new components and types

System supports automatic theme detection, CSS variable extraction,
plugin-specific styling, and hybrid export modes with configurable
conflict resolution strategies.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-29 23:23:35 +02:00
Jarvis a4a13e4aeb feat: implement typst template system with validation (task 6)
Adds comprehensive template management system for Typst PDF export:

• TemplateManager: Built-in and custom template support with 4 embedded templates
• TemplateSubstitution: Variable processing with Typst character escaping
• TemplateValidator: Syntax validation, structure checks, and feature detection
• Complete TypeScript type definitions for template system

Supports Typst 0.11+ features and provides robust error handling.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-29 22:45:07 +02:00
Jarvis cca5c0210b feat: implement comprehensive markdown preprocessor for obsidian syntax (task 4)
Add MarkdownPreprocessor class with full Obsidian syntax conversion:
- Convert wikilinks [[file#heading|alias]] to standard markdown links
- Process embeds ![[file]] with size parameters and file type detection
- Transform callouts to enhanced blockquotes with CSS class markers
- Extract and preserve frontmatter using gray-matter library
- Enhanced tag extraction from content and frontmatter
- Comprehensive error handling and warnings system
- Optimized for Pandoc → Typst conversion pipeline

Validated against Pandoc documentation for maximum compatibility.
All preprocessing outputs standard markdown that Pandoc processes
efficiently for high-quality PDF generation via Typst.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-29 17:59:47 +02:00
Jarvis 7312575588 feat: implement dependency checker and external tool management (task 3)
Add comprehensive dependency checking system for external tools:

- Create DependencyChecker class with cross-platform executable detection
- Implement version validation for Pandoc (3.0.0+) and Typst (0.11.0+)
- Add timeout handling and robust error management for external processes
- Integrate dependency checking with plugin lifecycle and settings interface
- Create DependencyStatusModal with detailed status display and installation guides
- Add platform-specific installation instructions (Windows/Mac/Linux)
- Include user-friendly error messages and troubleshooting guidance
- Add dependency status section to settings with "Check Dependencies" button
- Style dependency modal with Obsidian theme-aware CSS
- Update TypeScript config to exclude reference files from compilation

The dependency checker provides non-blocking startup validation,
export workflow integration, and comprehensive user guidance for
missing or outdated external tools.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-29 17:41:42 +02:00