Addresses several issues related to file paths, remote images, and bibliography generation:
Resolves issues with absolute path handling on Windows
Enables support for remote images in markdown files
Prevents errors related to missing bibliographies by disabling Pandoc's automatic citeproc filter. This avoids Pandoc incorrectly detecting citation patterns and attempting to generate a bibliography when none is provided.
Summary by CodeRabbit
New Features
Remote image download/embedding with timeout, temp storage/cleanup; direct Markdown→PDF and PDF→image conversion flows; single-page export option.
Centralized path, temp-directory, resource and command-building logic; unified resolution and lifecycle/cleanup handling.
Documentation
Expanded changelog, diagnostics, and user-facing notices.
Tests
Comprehensive unit tests and test harness added.
Addresses several issues related to file paths, remote images, and bibliography generation:
- Resolves issues with absolute path handling on Windows
- Enables support for remote images in markdown files
- Prevents errors related to missing bibliographies by disabling Pandoc's automatic citeproc filter. This avoids Pandoc incorrectly detecting citation patterns and attempting to generate a bibliography when none is provided.
<!-- This is an auto-generated comment: release notes by coderabbit.ai -->
## Summary by CodeRabbit
* **New Features**
* Remote image download/embedding with timeout, temp storage/cleanup; direct Markdown→PDF and PDF→image conversion flows; single-page export option.
* **Bug Fixes**
* Improved Windows/path handling, remote URL image resilience, bibliography/citation behavior, and stricter path/executable validation.
* **Refactor**
* Centralized path, temp-directory, resource and command-building logic; unified resolution and lifecycle/cleanup handling.
* **Documentation**
* Expanded changelog, diagnostics, and user-facing notices.
* **Tests**
* Comprehensive unit tests and test harness added.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
Adds remote-image detection and download queuing, centralizes vault/path/temp utilities, introduces a Pandoc command builder and richer conversion lifecycle, strengthens dependency and security checks, expands settings and modal helpers, adds PDF→image pipeline, extensive unit tests and Vitest infra, and updates changelog and gitignore.
Add PathUtils for normalized path operations, TempDirectoryManager for plugin-scoped temp dirs and cleanup, extend constants (FONTS_CACHE, NOTICE_DURATION) and expand FALLBACK_FONTS.
Rework preprocessor pipeline: new metadata structure, detect/queue standard Markdown remote images into metadata.imageEmbeds, replace with IMAGE_EMBED_MARKER, add options (baseUrl, printFrontmatter) and richer PreprocessingResult.
New PandocCommandBuilder to assemble pandoc args (Typst integration, resource paths, templates, engine opts); PandocTypstConverter adds temp-dir lifecycle, convertMarkdownToPDF, cleanup and progress callbacks; PandocExecutor docs expanded.
PDF → image conversion src/converters/PdfToImageConverter.ts, src/converters/pdf/BinaryLocator.ts
Add PdfToImageConverter singleton API (convert/validate/getInfo), structured conversion pipeline; BinaryLocator refactors to reuse PathUtils and refines Windows path handling.
Add DependencyInfo/DependencyCheckResult, PATH/env augmentation helpers, async/sync executable resolution and version checks, status reporting and showDependencyStatus.
Expand settings schema (paths, executables, typography, pageSetup, behavior), add ExportFormat enum, and ModalSettingsHelper static helpers for single/multi-file modal preparation.
Tests, mocks & test infra tests/*, tests/__mocks__/obsidian.ts, vitest.config.ts, package.json, .gitignore
Add many unit tests (ModalSettingsHelper, SecurityUtils, TempDirectoryManager, TypstVariableMapper, paperSizeMapper, basicCoverage, converterTypes), Obsidian mock, Vitest config and scripts, dev-deps, and add coverage/ to .gitignore.
Changelog & misc CHANGELOG.md, package.json
Update CHANGELOG (Unreleased and historical items), add test scripts/dev-deps in package.json.
Sequence Diagram(s)
sequenceDiagram
participant MD as MarkdownPreprocessor
participant Meta as ResultMetadata
participant EP as EmbedProcessor
participant DL as RemoteDownloader
participant FS as Filesystem
participant CMD as PandocCommandBuilder
participant PAND as PandocExecutor
MD->>MD: scan content for images
alt remote (http/https)
MD->>Meta: queue imageEmbeds {originalPath, sanitizedPath, fileName, marker}
MD->>MD: replace image with IMAGE_EMBED_MARKER
else local
MD->>MD: keep local markup (handle embeds/wikilinks)
end
EP->>Meta: read imageEmbeds
loop each embed
EP->>EP: isRemote?
alt yes
EP->>DL: downloadRemoteImage(url, tempDir)
DL->>FS: HTTP(S) request (redirects, timeout)
FS-->>DL: localTempPath / error
DL-->>EP: downloadedPath or null
EP->>EP: replace marker with local path or placeholder
else no
EP->>EP: resolveLocalPath(decodedPath, vaultBase, currentFile, additionalPaths)
EP->>EP: replace marker with resolved vault path or placeholder
end
end
CMD->>CMD: buildPandocArgs(input, output, pandocOptions)
CMD-->>PAND: args[]
PAND->>FS: spawn pandoc with args (engine, resources, template)
PAND-->>PAND: parse progress & errors
src/core/ExecutableChecker.ts & src/core/DependencyChecker.ts — PATH augmentation, version parsing, concurrency and async error paths.
Possibly related PRs
AlexKucera/obsidian-typst-pdf-export#5 — Overlaps on PathUtils/TempDirectoryManager centralization and related updates to EmbedProcessor, BinaryLocator, and temp-dir handling.
Poem
🐰
I hop through markdown, fetching images from afar,
I stitch vault paths and tidy temp files in my jar,
I build commands, map variables, and guard each route,
I warn, I test, I clean — a rabbit's quiet bout,
Petite refactor, neat and bright. 🥕
Pre-merge checks and finishing touches
✅ Passed checks (2 passed)
Check name
Status
Explanation
Description Check
✅ Passed
Check skipped - CodeRabbit’s high-level summary is enabled.
Title check
✅ Passed
The title 'Fixes path, image, and bibliography issues' directly corresponds to the three main objectives stated in the PR description: path handling on Windows, remote image support, and bibliography/citeproc fixes.
✨ Finishing touches
📝 Generate docstrings
🧪 Generate unit tests (beta)
Create PR with unit tests
Post copyable unit tests in a comment
Commit unit tests in branch windows_path_fix
📜 Recent review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📥 Commits
Reviewing files that changed from the base of the PR and between 35a5249607 and 68238e3db2.
src/**/*.ts: Organize code into multiple files under src/ (commands/, ui/, utils/, etc.) rather than putting everything in main.ts
Add user-facing commands via this.addCommand(...) and use stable command IDs
Persist settings using this.loadData()/this.saveData() and provide sensible defaults via a settings tab
Register and clean up all DOM, app, and interval listeners using this.register* helpers for safe unload
Prefer async/await over promise chains and handle errors gracefully
Learnt from: AlexKucera
Repo: AlexKucera/obsidian-typst-pdf-export PR: 5
File: src/core/PathUtils.ts:108-119
Timestamp: 2025-09-25T14:27:31.837Z
Learning: The obsidian-typst-pdf-export plugin prefers to avoid Node.js built-in modules like 'path' and instead stick to Obsidian API calls for path operations.
26-26: Verify the use of Node.js path module aligns with the updated approach.
The code imports and uses the Node.js path module for path joining operations. This deviates from a previous learning that the plugin prefers Obsidian API calls over Node.js built-in modules for path operations. However, given that this PR explicitly aims to fix Windows path handling issues and path.join is used to properly handle absolute paths cross-platform (as noted in the comments), this appears to be an intentional architectural decision.
Please confirm that using path.join is the intended approach going forward, as it provides more robust cross-platform path handling than string concatenation or alternatives.
Based on learnings.
Also applies to: 169-169, 208-208, 446-447
117-458: Excellent implementation of the temp directory manager.
The implementation is well-structured with proper:
Async/await patterns throughout
Error handling (creation errors propagate, cleanup errors are caught and logged)
Security validation in isPluginTempDir with correct path prefix checking
coderabbitai[bot]
(Migrated from github.com)
left a comment
Copy link
Copy source
Actionable comments posted: 1
🧹 Nitpick comments (6)
src/core/TempDirectoryManager.ts (2)
37-58: Simplify path construction logic.
The manual iteration through segments to handle absolute paths replicates behavior already provided by path.join(). Node.js path.join() automatically handles absolute path segments by resetting the base when an absolute path is encountered.
Apply this diff to simplify:
- private getPluginDir(): string {
- // Use path.join to properly handle absolute paths
- const segments = [this.vaultPath, this.configDir, 'plugins', this.pluginName];
- let result = '';
-
- for (const segment of segments) {
- if (!segment) continue;
-
- if (path.isAbsolute(segment)) {
- // This segment is absolute, use it as the new base
- result = segment;
- } else if (result) {
- // Join with the current result
- result = path.join(result, segment);
- } else {
- // First relative segment
- result = segment;
- }
- }
-
- return normalizePath(path.normalize(result));
+ private getPluginDir(): string {
+ // path.join automatically handles absolute paths correctly
+ const result = path.join(this.vaultPath, this.configDir, 'plugins', this.pluginName);
+ return normalizePath(result);
}
133-144: Remove redundant path.normalize calls.
The paths are already normalized by normalizePath() and passed through path.join(), making the additional path.normalize() calls redundant.
The manual iteration to handle absolute paths replicates behavior already provided by path.join(). Node.js path.join() automatically handles absolute path segments correctly across platforms.
Apply this diff to simplify:
joinPath(...segments: string[]): string {
- // Filter out empty segments
const filtered = segments.filter(s => s);
-
if (filtered.length === 0) {
return '';
}
-
- // Find the last absolute path in the segments
- // If a segment is absolute, it becomes the new base and we ignore previous segments
- let result = '';
- for (const segment of filtered) {
- if (path.isAbsolute(segment)) {
- // This segment is absolute, use it as the new base
- result = segment;
- } else if (result) {
- // Join with the current result
- result = path.join(result, segment);
- } else {
- // First relative segment
- result = segment;
- }
- }
-
- // Normalize the final path using path.normalize for cross-platform compatibility
- // then use Obsidian's normalizePath for vault-relative paths
- const normalized = path.normalize(result);
- return normalizePath(normalized);
+ const result = path.join(...filtered);
+ return normalizePath(result);
}
Note: path.join() already normalizes paths and handles absolute segments by using the last absolute path as the new base.
src/plugin/EmbedProcessor.ts (2)
27-104: Consider using Obsidian's vault.adapter for file operations.
The implementation uses Node.js fs module directly (lines 69, 82) to write downloaded images, bypassing Obsidian's vault.adapter API. This is inconsistent with the codebase's preference for Obsidian APIs.
Additionally, there's no check if a file already exists at outputPath before writing, which could overwrite existing files or cause concurrent write issues.
Consider:
Using this.plugin.app.vault.adapter.writeBinary() instead of fs.createWriteStream()
Checking file existence before writing to avoid overwriting
Example approach:
// Check if file exists
constexists=awaitthis.pathUtils.fileExists(outputPath);if(exists){// Handle collision: append timestamp or skip
}// Write using vault adapter
constchunks: Buffer[]=[];response.on('data',(chunk)=>chunks.push(chunk));response.on('end',async()=>{try{constbuffer=Buffer.concat(chunks);awaitthis.plugin.app.vault.adapter.writeBinary(outputPath,buffer);resolve(outputPath);}catch(err){console.error(`Export: Error writing image: ${err.message}`);resolve(null);}});
The local file path resolution logic (lines 227-247) duplicates similar logic in resolvePdfPath() and resolveFilePath() methods. Consider extracting this into a shared helper method.
Example:
privateasyncresolveLocalPath(decodedPath: string,vaultBasePath: string,currentFile?: TFile,additionalPaths: string[]=[]):Promise<string|null>{constpossiblePaths=[path.resolve(vaultBasePath,decodedPath),currentFile?path.resolve(vaultBasePath,path.dirname(currentFile.path),decodedPath):null,...additionalPaths].filter((p):pisstring=>p!==null);for(constpossiblePathofpossiblePaths){try{if(awaitthis.pathUtils.fileExists(possiblePath)){returnpossiblePath;}}catch{// Continue to next path
}}returnnull;}
Then call it from processImageEmbeds, resolvePdfPath, and resolveFilePath.
src/converters/MarkdownPreprocessor.ts (1)
146-147: Consider documenting the processing order.
The new Step 5.5 is inserted between embed processing (Step 5) and wikilink processing (Step 6). Consider adding a comment explaining why remote image processing happens after embeds but before wikilinks.
// Step 5: Convert embeds FIRST (before wikilinks to avoid .md extension being added)
result.content = this.embedProcessor.processEmbeds(result.content, result);
- // Step 5.5: Handle standard markdown images with remote URLs
+ // Step 5.5: Handle standard markdown images with remote URLs
+ // Process after embeds (which handle ![[]] syntax) but before wikilinks
+ // to ensure remote URLs in standard markdown  format are queued for download
result.content = this.processStandardMarkdownImages(result.content, result);
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📥 Commits
Reviewing files that changed from the base of the PR and between 536351cbbf and 9ca299cafd.
src/**/*.ts: Organize code into multiple files under src/ (commands/, ui/, utils/, etc.) rather than putting everything in main.ts
Add user-facing commands via this.addCommand(...) and use stable command IDs
Persist settings using this.loadData()/this.saveData() and provide sensible defaults via a settings tab
Register and clean up all DOM, app, and interval listeners using this.register* helpers for safe unload
Prefer async/await over promise chains and handle errors gracefully
Learnt from: AlexKucera
Repo: AlexKucera/obsidian-typst-pdf-export PR: 5
File: src/core/PathUtils.ts:108-119
Timestamp: 2025-09-25T14:27:31.837Z
Learning: The obsidian-typst-pdf-export plugin prefers to avoid Node.js built-in modules like 'path' and instead stick to Obsidian API calls for path operations.
Applied to files:
src/converters/pdf/BinaryLocator.ts
src/core/TempDirectoryManager.ts
src/core/PathUtils.ts
src/plugin/EmbedProcessor.ts
CHANGELOG.md
📚 Learning: 2025-09-25T14:14:57.437Z
Learnt from: AlexKucera
Repo: AlexKucera/obsidian-typst-pdf-export PR: 5
File: src/converters/pandoc/ResourcePathResolver.ts:109-111
Timestamp: 2025-09-25T14:14:57.437Z
Learning: In src/converters/pandoc/ResourcePathResolver.ts, the image extension regex /\.(png|jpg|jpeg|gif|svg|webp|bmp|ico|tiff)$/i is intentionally restricted and should not be expanded to include additional formats like .tif, .avif, .heic, .heif as this is a conscious design decision by the maintainer.
The codebase previously preferred to avoid Node.js built-in modules like path in favor of Obsidian API calls for path operations. While Windows absolute path handling may justify this change, ensure this is the intended approach.
Based on learnings.
src/converters/pandoc/PandocCommandBuilder.ts (1)
49-52: LGTM!
The --no-citeproc flag appropriately disables Pandoc's automatic citation processing when no bibliography is provided, preventing false-positive bibliography errors.
src/core/PathUtils.ts (1)
6-6: Verify necessity of Node.js path module.
The codebase previously preferred to avoid Node.js built-in modules like path in favor of Obsidian API calls for path operations. While Windows absolute path handling may justify this change, ensure this is the intended approach.
Based on learnings.
src/converters/pdf/BinaryLocator.ts (1)
133-145: LGTM!
Good refactoring to reuse the PathUtils instance and use centralized joinPath() for path construction. The null-check for the plugin parameter is appropriate.
src/plugin/EmbedProcessor.ts (1)
206-225: LGTM with security note.
The remote URL detection and download logic is appropriate. The 10-second timeout and graceful fallback to placeholder text provide good UX.
However, ensure users are aware that remote images are downloaded without domain validation. Consider documenting this behavior in user-facing documentation.
src/converters/MarkdownPreprocessor.ts (2)
12-12: Verify necessity of Node.js path module.
The codebase previously preferred to avoid Node.js built-in modules like path in favor of Obsidian API calls. While this may be necessary for filename extraction from URLs, ensure this is the intended approach.
Based on learnings.
171-217: LGTM!
The remote image detection and queuing logic is well-implemented. The regex pattern correctly matches standard markdown images, and the URL validation appropriately identifies remote resources. The fallback filename handling when URL parsing fails is robust.
CHANGELOG.md (1)
8-37: LGTM!
The changelog accurately documents the key changes in this PR:
Remote image download functionality with timeout and fallback behavior
Windows absolute path handling fixes
Bibliography error prevention with --no-citeproc
The descriptions are clear, comprehensive, and well-organized by category.
**Actionable comments posted: 1**
<details>
<summary>🧹 Nitpick comments (6)</summary><blockquote>
<details>
<summary>src/core/TempDirectoryManager.ts (2)</summary><blockquote>
`37-58`: **Simplify path construction logic.**
The manual iteration through segments to handle absolute paths replicates behavior already provided by `path.join()`. Node.js `path.join()` automatically handles absolute path segments by resetting the base when an absolute path is encountered.
Apply this diff to simplify:
```diff
- private getPluginDir(): string {
- // Use path.join to properly handle absolute paths
- const segments = [this.vaultPath, this.configDir, 'plugins', this.pluginName];
- let result = '';
-
- for (const segment of segments) {
- if (!segment) continue;
-
- if (path.isAbsolute(segment)) {
- // This segment is absolute, use it as the new base
- result = segment;
- } else if (result) {
- // Join with the current result
- result = path.join(result, segment);
- } else {
- // First relative segment
- result = segment;
- }
- }
-
- return normalizePath(path.normalize(result));
+ private getPluginDir(): string {
+ // path.join automatically handles absolute paths correctly
+ const result = path.join(this.vaultPath, this.configDir, 'plugins', this.pluginName);
+ return normalizePath(result);
}
```
---
`133-144`: **Remove redundant path.normalize calls.**
The paths are already normalized by `normalizePath()` and passed through `path.join()`, making the additional `path.normalize()` calls redundant.
Apply this diff:
```diff
public isPluginTempDir(dirPath: string): boolean {
const pluginDir = this.getPluginDir();
const normalizedDirPath = normalizePath(dirPath);
const normalizedPluginDir = normalizePath(pluginDir);
-
- // Use path.join to properly handle absolute paths
- const tempImagesDir = normalizePath(path.normalize(path.join(normalizedPluginDir, PLUGIN_DIRS.TEMP_IMAGES)));
- const tempPandocDir = normalizePath(path.normalize(path.join(normalizedPluginDir, PLUGIN_DIRS.TEMP_PANDOC)));
+ const tempImagesDir = normalizePath(path.join(normalizedPluginDir, PLUGIN_DIRS.TEMP_IMAGES));
+ const tempPandocDir = normalizePath(path.join(normalizedPluginDir, PLUGIN_DIRS.TEMP_PANDOC));
return normalizedDirPath.startsWith(tempImagesDir) ||
normalizedDirPath.startsWith(tempPandocDir);
}
```
</blockquote></details>
<details>
<summary>src/core/PathUtils.ts (1)</summary><blockquote>
`34-62`: **Simplify path joining logic.**
The manual iteration to handle absolute paths replicates behavior already provided by `path.join()`. Node.js `path.join()` automatically handles absolute path segments correctly across platforms.
Apply this diff to simplify:
```diff
joinPath(...segments: string[]): string {
- // Filter out empty segments
const filtered = segments.filter(s => s);
-
if (filtered.length === 0) {
return '';
}
-
- // Find the last absolute path in the segments
- // If a segment is absolute, it becomes the new base and we ignore previous segments
- let result = '';
- for (const segment of filtered) {
- if (path.isAbsolute(segment)) {
- // This segment is absolute, use it as the new base
- result = segment;
- } else if (result) {
- // Join with the current result
- result = path.join(result, segment);
- } else {
- // First relative segment
- result = segment;
- }
- }
-
- // Normalize the final path using path.normalize for cross-platform compatibility
- // then use Obsidian's normalizePath for vault-relative paths
- const normalized = path.normalize(result);
- return normalizePath(normalized);
+ const result = path.join(...filtered);
+ return normalizePath(result);
}
```
Note: `path.join()` already normalizes paths and handles absolute segments by using the last absolute path as the new base.
</blockquote></details>
<details>
<summary>src/plugin/EmbedProcessor.ts (2)</summary><blockquote>
`27-104`: **Consider using Obsidian's vault.adapter for file operations.**
The implementation uses Node.js `fs` module directly (lines 69, 82) to write downloaded images, bypassing Obsidian's vault.adapter API. This is inconsistent with the codebase's preference for Obsidian APIs.
Additionally, there's no check if a file already exists at `outputPath` before writing, which could overwrite existing files or cause concurrent write issues.
Consider:
1. Using `this.plugin.app.vault.adapter.writeBinary()` instead of `fs.createWriteStream()`
2. Checking file existence before writing to avoid overwriting
Example approach:
```typescript
// Check if file exists
const exists = await this.pathUtils.fileExists(outputPath);
if (exists) {
// Handle collision: append timestamp or skip
}
// Write using vault adapter
const chunks: Buffer[] = [];
response.on('data', (chunk) => chunks.push(chunk));
response.on('end', async () => {
try {
const buffer = Buffer.concat(chunks);
await this.plugin.app.vault.adapter.writeBinary(outputPath, buffer);
resolve(outputPath);
} catch (err) {
console.error(`Export: Error writing image: ${err.message}`);
resolve(null);
}
});
```
---
`226-248`: **Consolidate duplicate path resolution logic.**
The local file path resolution logic (lines 227-247) duplicates similar logic in `resolvePdfPath()` and `resolveFilePath()` methods. Consider extracting this into a shared helper method.
Example:
```typescript
private async resolveLocalPath(
decodedPath: string,
vaultBasePath: string,
currentFile?: TFile,
additionalPaths: string[] = []
): Promise<string | null> {
const possiblePaths = [
path.resolve(vaultBasePath, decodedPath),
currentFile ? path.resolve(vaultBasePath, path.dirname(currentFile.path), decodedPath) : null,
...additionalPaths
].filter((p): p is string => p !== null);
for (const possiblePath of possiblePaths) {
try {
if (await this.pathUtils.fileExists(possiblePath)) {
return possiblePath;
}
} catch {
// Continue to next path
}
}
return null;
}
```
Then call it from processImageEmbeds, resolvePdfPath, and resolveFilePath.
</blockquote></details>
<details>
<summary>src/converters/MarkdownPreprocessor.ts (1)</summary><blockquote>
`146-147`: **Consider documenting the processing order.**
The new Step 5.5 is inserted between embed processing (Step 5) and wikilink processing (Step 6). Consider adding a comment explaining why remote image processing happens after embeds but before wikilinks.
```diff
// Step 5: Convert embeds FIRST (before wikilinks to avoid .md extension being added)
result.content = this.embedProcessor.processEmbeds(result.content, result);
- // Step 5.5: Handle standard markdown images with remote URLs
+ // Step 5.5: Handle standard markdown images with remote URLs
+ // Process after embeds (which handle ![[]] syntax) but before wikilinks
+ // to ensure remote URLs in standard markdown  format are queued for download
result.content = this.processStandardMarkdownImages(result.content, result);
```
</blockquote></details>
</blockquote></details>
<details>
<summary>📜 Review details</summary>
**Configuration used**: CodeRabbit UI
**Review profile**: CHILL
**Plan**: Pro
<details>
<summary>📥 Commits</summary>
Reviewing files that changed from the base of the PR and between 536351cbbf2e8065f83325a7a4d9b70836f68d38 and 9ca299cafd915a43145a0bfb43acb9fb2d514d37.
</details>
<details>
<summary>📒 Files selected for processing (7)</summary>
* `CHANGELOG.md` (4 hunks)
* `src/converters/MarkdownPreprocessor.ts` (3 hunks)
* `src/converters/pandoc/PandocCommandBuilder.ts` (1 hunks)
* `src/converters/pdf/BinaryLocator.ts` (1 hunks)
* `src/core/PathUtils.ts` (2 hunks)
* `src/core/TempDirectoryManager.ts` (3 hunks)
* `src/plugin/EmbedProcessor.ts` (2 hunks)
</details>
<details>
<summary>🧰 Additional context used</summary>
<details>
<summary>📓 Path-based instructions (1)</summary>
<details>
<summary>src/**/*.ts</summary>
**📄 CodeRabbit inference engine (AGENTS.md)**
> `src/**/*.ts`: Organize code into multiple files under src/ (commands/, ui/, utils/, etc.) rather than putting everything in main.ts
> Add user-facing commands via this.addCommand(...) and use stable command IDs
> Persist settings using this.loadData()/this.saveData() and provide sensible defaults via a settings tab
> Register and clean up all DOM, app, and interval listeners using this.register* helpers for safe unload
> Prefer async/await over promise chains and handle errors gracefully
Files:
- `src/converters/pdf/BinaryLocator.ts`
- `src/core/TempDirectoryManager.ts`
- `src/core/PathUtils.ts`
- `src/converters/pandoc/PandocCommandBuilder.ts`
- `src/plugin/EmbedProcessor.ts`
- `src/converters/MarkdownPreprocessor.ts`
</details>
</details><details>
<summary>🧠 Learnings (2)</summary>
<details>
<summary>📚 Learning: 2025-09-25T14:27:31.837Z</summary>
```
Learnt from: AlexKucera
Repo: AlexKucera/obsidian-typst-pdf-export PR: 5
File: src/core/PathUtils.ts:108-119
Timestamp: 2025-09-25T14:27:31.837Z
Learning: The obsidian-typst-pdf-export plugin prefers to avoid Node.js built-in modules like 'path' and instead stick to Obsidian API calls for path operations.
```
**Applied to files:**
- `src/converters/pdf/BinaryLocator.ts`
- `src/core/TempDirectoryManager.ts`
- `src/core/PathUtils.ts`
- `src/plugin/EmbedProcessor.ts`
- `CHANGELOG.md`
</details>
<details>
<summary>📚 Learning: 2025-09-25T14:14:57.437Z</summary>
```
Learnt from: AlexKucera
Repo: AlexKucera/obsidian-typst-pdf-export PR: 5
File: src/converters/pandoc/ResourcePathResolver.ts:109-111
Timestamp: 2025-09-25T14:14:57.437Z
Learning: In src/converters/pandoc/ResourcePathResolver.ts, the image extension regex /\.(png|jpg|jpeg|gif|svg|webp|bmp|ico|tiff)$/i is intentionally restricted and should not be expanded to include additional formats like .tif, .avif, .heic, .heif as this is a conscious design decision by the maintainer.
```
**Applied to files:**
- `src/converters/MarkdownPreprocessor.ts`
</details>
</details><details>
<summary>🧬 Code graph analysis (5)</summary>
<details>
<summary>src/converters/pdf/BinaryLocator.ts (1)</summary><blockquote>
<details>
<summary>src/core/PathUtils.ts (1)</summary>
* `PathUtils` (8-150)
</details>
</blockquote></details>
<details>
<summary>src/core/TempDirectoryManager.ts (1)</summary><blockquote>
<details>
<summary>src/core/constants.ts (1)</summary>
* `PLUGIN_DIRS` (25-29)
</details>
</blockquote></details>
<details>
<summary>src/core/PathUtils.ts (1)</summary><blockquote>
<details>
<summary>scripts/package-plugin.js (1)</summary>
* `path` (12-12)
</details>
</blockquote></details>
<details>
<summary>src/plugin/EmbedProcessor.ts (3)</summary><blockquote>
<details>
<summary>src/converters/preprocessors/EmbedProcessor.ts (1)</summary>
* `EmbedProcessor` (54-244)
</details>
<details>
<summary>src/core/PathUtils.ts (1)</summary>
* `PathUtils` (8-150)
</details>
<details>
<summary>main.ts (1)</summary>
* `obsidianTypstPDFExport` (30-245)
</details>
</blockquote></details>
<details>
<summary>src/converters/MarkdownPreprocessor.ts (1)</summary><blockquote>
<details>
<summary>src/converters/preprocessors/WikilinkProcessor.ts (1)</summary>
* `PreprocessingResult` (20-58)
</details>
</blockquote></details>
</details>
</details>
<details>
<summary>🔇 Additional comments (8)</summary><blockquote>
<details>
<summary>src/core/TempDirectoryManager.ts (1)</summary><blockquote>
`7-7`: **Verify necessity of Node.js `path` module.**
The codebase previously preferred to avoid Node.js built-in modules like `path` in favor of Obsidian API calls for path operations. While Windows absolute path handling may justify this change, ensure this is the intended approach.
Based on learnings.
</blockquote></details>
<details>
<summary>src/converters/pandoc/PandocCommandBuilder.ts (1)</summary><blockquote>
`49-52`: **LGTM!**
The `--no-citeproc` flag appropriately disables Pandoc's automatic citation processing when no bibliography is provided, preventing false-positive bibliography errors.
</blockquote></details>
<details>
<summary>src/core/PathUtils.ts (1)</summary><blockquote>
`6-6`: **Verify necessity of Node.js `path` module.**
The codebase previously preferred to avoid Node.js built-in modules like `path` in favor of Obsidian API calls for path operations. While Windows absolute path handling may justify this change, ensure this is the intended approach.
Based on learnings.
</blockquote></details>
<details>
<summary>src/converters/pdf/BinaryLocator.ts (1)</summary><blockquote>
`133-145`: **LGTM!**
Good refactoring to reuse the PathUtils instance and use centralized `joinPath()` for path construction. The null-check for the plugin parameter is appropriate.
</blockquote></details>
<details>
<summary>src/plugin/EmbedProcessor.ts (1)</summary><blockquote>
`206-225`: **LGTM with security note.**
The remote URL detection and download logic is appropriate. The 10-second timeout and graceful fallback to placeholder text provide good UX.
However, ensure users are aware that remote images are downloaded without domain validation. Consider documenting this behavior in user-facing documentation.
</blockquote></details>
<details>
<summary>src/converters/MarkdownPreprocessor.ts (2)</summary><blockquote>
`12-12`: **Verify necessity of Node.js `path` module.**
The codebase previously preferred to avoid Node.js built-in modules like `path` in favor of Obsidian API calls. While this may be necessary for filename extraction from URLs, ensure this is the intended approach.
Based on learnings.
---
`171-217`: **LGTM!**
The remote image detection and queuing logic is well-implemented. The regex pattern correctly matches standard markdown images, and the URL validation appropriately identifies remote resources. The fallback filename handling when URL parsing fails is robust.
</blockquote></details>
<details>
<summary>CHANGELOG.md (1)</summary><blockquote>
`8-37`: **LGTM!**
The changelog accurately documents the key changes in this PR:
- Remote image download functionality with timeout and fallback behavior
- Windows absolute path handling fixes
- Bibliography error prevention with `--no-citeproc`
The descriptions are clear, comprehensive, and well-organized by category.
</blockquote></details>
</blockquote></details>
</details>
<!-- This is an auto-generated comment by CodeRabbit for review status -->
Lines 69-71 have a redundant ternary that returns the same result in both branches.
Apply this diff:
public getTempDir(type: 'images' | 'pandoc'): string {
const dirName = type === 'images' ? PLUGIN_DIRS.TEMP_IMAGES : PLUGIN_DIRS.TEMP_PANDOC;
const pluginDir = this.getPluginDir();
-
- // Use path.join to properly handle absolute paths
- const result = path.isAbsolute(pluginDir)
- ? path.join(pluginDir, dirName)
- : path.join(pluginDir, dirName);
-
- return normalizePath(path.normalize(result));
+ const result = path.join(pluginDir, dirName);
+ return normalizePath(result);
}
🤖 Prompt for AI Agents
In src/core/TempDirectoryManager.ts around lines 64 to 74, the code uses a
redundant ternary when building result (both branches call path.join(pluginDir,
dirName)); remove the ternary and directly compute result with
path.join(pluginDir, dirName). Keep the existing
normalizePath(path.normalize(...)) wrapping and ensure you preserve the
selection of dirName earlier.
_🛠️ Refactor suggestion_ | _🟠 Major_
**Remove redundant ternary operator.**
Lines 69-71 have a redundant ternary that returns the same result in both branches.
Apply this diff:
```diff
public getTempDir(type: 'images' | 'pandoc'): string {
const dirName = type === 'images' ? PLUGIN_DIRS.TEMP_IMAGES : PLUGIN_DIRS.TEMP_PANDOC;
const pluginDir = this.getPluginDir();
-
- // Use path.join to properly handle absolute paths
- const result = path.isAbsolute(pluginDir)
- ? path.join(pluginDir, dirName)
- : path.join(pluginDir, dirName);
-
- return normalizePath(path.normalize(result));
+ const result = path.join(pluginDir, dirName);
+ return normalizePath(result);
}
```
<details>
<summary>🤖 Prompt for AI Agents</summary>
```
In src/core/TempDirectoryManager.ts around lines 64 to 74, the code uses a
redundant ternary when building result (both branches call path.join(pluginDir,
dirName)); remove the ternary and directly compute result with
path.join(pluginDir, dirName). Keep the existing
normalizePath(path.normalize(...)) wrapping and ensure you preserve the
selection of dirName earlier.
```
</details>
<!-- This is an auto-generated comment by CodeRabbit -->
✅ Addressed in commits 501f380 to 4a0376e
src/**/*.ts: Organize code into multiple files under src/ (commands/, ui/, utils/, etc.) rather than putting everything in main.ts
Add user-facing commands via this.addCommand(...) and use stable command IDs
Persist settings using this.loadData()/this.saveData() and provide sensible defaults via a settings tab
Register and clean up all DOM, app, and interval listeners using this.register* helpers for safe unload
Prefer async/await over promise chains and handle errors gracefully
Learnt from: AlexKucera
Repo: AlexKucera/obsidian-typst-pdf-export PR: 5
File: src/core/PathUtils.ts:108-119
Timestamp: 2025-09-25T14:27:31.837Z
Learning: The obsidian-typst-pdf-export plugin prefers to avoid Node.js built-in modules like 'path' and instead stick to Obsidian API calls for path operations.
Applied to files:
src/plugin/EmbedProcessor.ts
📚 Learning: 2025-09-25T14:14:57.437Z
Learnt from: AlexKucera
Repo: AlexKucera/obsidian-typst-pdf-export PR: 5
File: src/converters/pandoc/ResourcePathResolver.ts:109-111
Timestamp: 2025-09-25T14:14:57.437Z
Learning: In src/converters/pandoc/ResourcePathResolver.ts, the image extension regex /\.(png|jpg|jpeg|gif|svg|webp|bmp|ico|tiff)$/i is intentionally restricted and should not be expanded to include additional formats like .tif, .avif, .heic, .heif as this is a conscious design decision by the maintainer.
**Actionable comments posted: 2**
<details>
<summary>📜 Review details</summary>
**Configuration used**: CodeRabbit UI
**Review profile**: CHILL
**Plan**: Pro
<details>
<summary>📥 Commits</summary>
Reviewing files that changed from the base of the PR and between 9ca299cafd915a43145a0bfb43acb9fb2d514d37 and 4a0376ec2b922897f5c80e64a0e7268aa3980503.
</details>
<details>
<summary>📒 Files selected for processing (4)</summary>
* `src/converters/MarkdownPreprocessor.ts` (3 hunks)
* `src/core/PathUtils.ts` (2 hunks)
* `src/core/TempDirectoryManager.ts` (3 hunks)
* `src/plugin/EmbedProcessor.ts` (4 hunks)
</details>
<details>
<summary>🚧 Files skipped from review as they are similar to previous changes (3)</summary>
* src/core/PathUtils.ts
* src/converters/MarkdownPreprocessor.ts
* src/core/TempDirectoryManager.ts
</details>
<details>
<summary>🧰 Additional context used</summary>
<details>
<summary>📓 Path-based instructions (1)</summary>
<details>
<summary>src/**/*.ts</summary>
**📄 CodeRabbit inference engine (AGENTS.md)**
> `src/**/*.ts`: Organize code into multiple files under src/ (commands/, ui/, utils/, etc.) rather than putting everything in main.ts
> Add user-facing commands via this.addCommand(...) and use stable command IDs
> Persist settings using this.loadData()/this.saveData() and provide sensible defaults via a settings tab
> Register and clean up all DOM, app, and interval listeners using this.register* helpers for safe unload
> Prefer async/await over promise chains and handle errors gracefully
Files:
- `src/plugin/EmbedProcessor.ts`
</details>
</details><details>
<summary>🧠 Learnings (2)</summary>
<details>
<summary>📚 Learning: 2025-09-25T14:27:31.837Z</summary>
```
Learnt from: AlexKucera
Repo: AlexKucera/obsidian-typst-pdf-export PR: 5
File: src/core/PathUtils.ts:108-119
Timestamp: 2025-09-25T14:27:31.837Z
Learning: The obsidian-typst-pdf-export plugin prefers to avoid Node.js built-in modules like 'path' and instead stick to Obsidian API calls for path operations.
```
**Applied to files:**
- `src/plugin/EmbedProcessor.ts`
</details>
<details>
<summary>📚 Learning: 2025-09-25T14:14:57.437Z</summary>
```
Learnt from: AlexKucera
Repo: AlexKucera/obsidian-typst-pdf-export PR: 5
File: src/converters/pandoc/ResourcePathResolver.ts:109-111
Timestamp: 2025-09-25T14:14:57.437Z
Learning: In src/converters/pandoc/ResourcePathResolver.ts, the image extension regex /\.(png|jpg|jpeg|gif|svg|webp|bmp|ico|tiff)$/i is intentionally restricted and should not be expanded to include additional formats like .tif, .avif, .heic, .heif as this is a conscious design decision by the maintainer.
```
**Applied to files:**
- `src/plugin/EmbedProcessor.ts`
</details>
</details><details>
<summary>🧬 Code graph analysis (1)</summary>
<details>
<summary>src/plugin/EmbedProcessor.ts (3)</summary><blockquote>
<details>
<summary>src/converters/preprocessors/EmbedProcessor.ts (1)</summary>
* `EmbedProcessor` (54-244)
</details>
<details>
<summary>src/core/PathUtils.ts (1)</summary>
* `PathUtils` (8-129)
</details>
<details>
<summary>main.ts (1)</summary>
* `obsidianTypstPDFExport` (30-245)
</details>
</blockquote></details>
</details>
</details>
</details>
<!-- This is an auto-generated comment by CodeRabbit for review status -->
Preserve original image extensions instead of forcing .png.
When a remote file ends with something like .svg, we append .png without converting the contents. That leaves us with an SVG payload masquerading as PNG, so Typst/Pandoc will fail to decode the asset. Please keep the on-disk extension if one is present (at least include .svg, .ico, etc. in validExtensions, or only fall back to .png when the URL truly lacks an extension). Based on learnings
🤖 Prompt for AI Agents
In src/plugin/EmbedProcessor.ts around lines 96 to 103, the current logic forces
a .png when the file extension isn't in a small whitelist, which causes
mismatched on-disk extensions for assets like .svg or .ico; change the logic to
preserve any existing extension returned by path.extname (after normalizing and
stripping query/fragments) and only append .png when no extension is present (or
the ext is empty), or alternatively expand the validExtensions list to include
common types like .svg, .ico, .avif, .svgz; ensure you normalize ext via
toLowerCase() and treat extensions with query strings correctly so the
finalFileName uses the original extension when present and only falls back to
.png when the URL truly lacks one.
_⚠️ Potential issue_ | _🟠 Major_
**Preserve original image extensions instead of forcing `.png`.**
When a remote file ends with something like `.svg`, we append `.png` without converting the contents. That leaves us with an SVG payload masquerading as PNG, so Typst/Pandoc will fail to decode the asset. Please keep the on-disk extension if one is present (at least include `.svg`, `.ico`, etc. in `validExtensions`, or only fall back to `.png` when the URL truly lacks an extension). Based on learnings
<details>
<summary>🤖 Prompt for AI Agents</summary>
```
In src/plugin/EmbedProcessor.ts around lines 96 to 103, the current logic forces
a .png when the file extension isn't in a small whitelist, which causes
mismatched on-disk extensions for assets like .svg or .ico; change the logic to
preserve any existing extension returned by path.extname (after normalizing and
stripping query/fragments) and only append .png when no extension is present (or
the ext is empty), or alternatively expand the validExtensions list to include
common types like .svg, .ico, .avif, .svgz; ensure you normalize ext via
toLowerCase() and treat extensions with query strings correctly so the
finalFileName uses the original extension when present and only falls back to
.png when the URL truly lacks one.
```
</details>
<!-- fingerprinting:phantom:medusa:sabertoothed -->
<!-- This is an auto-generated comment by CodeRabbit -->
✅ Addressed in commits 7ac9e1f to 4eb52d1
Handle relative redirects when downloading images.
Redirects such as Location: /assets/img.png are valid but new URL(redirectUrl) will throw without the original request as a base, causing every relative redirect download to fail. Pass the original URL to new URL(...) (or otherwise resolve before recursing) so remote images behind relative redirects work.
🤖 Prompt for AI Agents
In src/plugin/EmbedProcessor.ts around lines 112 to 118, the code assumes
Location is an absolute URL and calls new URL(redirectUrl) which throws for
relative redirects; resolve redirectUrl against the original request URL (e.g.,
use new URL(redirectUrl, originalRequestUrl) or URL.resolve equivalent) to
produce an absolute URL, then pass that resolved absolute URL into
this.downloadRemoteImage(...) when recursing so relative Location headers (like
"/assets/img.png") are handled correctly.
_⚠️ Potential issue_ | _🟠 Major_
**Handle relative redirects when downloading images.**
Redirects such as `Location: /assets/img.png` are valid but `new URL(redirectUrl)` will throw without the original request as a base, causing every relative redirect download to fail. Pass the original URL to `new URL(...)` (or otherwise resolve before recursing) so remote images behind relative redirects work.
<details>
<summary>🤖 Prompt for AI Agents</summary>
```
In src/plugin/EmbedProcessor.ts around lines 112 to 118, the code assumes
Location is an absolute URL and calls new URL(redirectUrl) which throws for
relative redirects; resolve redirectUrl against the original request URL (e.g.,
use new URL(redirectUrl, originalRequestUrl) or URL.resolve equivalent) to
produce an absolute URL, then pass that resolved absolute URL into
this.downloadRemoteImage(...) when recursing so relative Location headers (like
"/assets/img.png") are handled correctly.
```
</details>
<!-- fingerprinting:phantom:medusa:sabertoothed -->
<!-- This is an auto-generated comment by CodeRabbit -->
✅ Addressed in commits 7ac9e1f to 4eb52d1
coderabbitai[bot]
(Migrated from github.com)
left a comment
Copy link
Copy source
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (4)
src/converters/PandocTypstConverter.ts (2)
190-198: Don't claim success on failure paths.
progressCallback?.('Conversion complete!', 100); fires even when result.success is false, so the UI reports a 100 % success message on failed exports. Guard this so the success message only emits when the conversion actually succeeded, or emit a failure update instead.
294-303: Unwind global process listeners and drop uncaughtException hook.
Every converter instantiation registers four process.on handlers that are never removed. Over time this leaks listeners, prevents the converter from being garbage-collected, and will eventually hit Node’s listener cap. Worse, the uncaughtException handler swallows the error (Node stops exiting once a handler is present), so any unrelated crash just triggers cleanup and the original error disappears. Please register these handlers once (or store them and remove them in dispose/cleanup) and avoid the global uncaughtException hook—or at least rethrow/exit after cleanup so errors are not silently consumed.
src/core/ExecutableChecker.ts (1)
80-92: Fix PATH delimiter handling on Windows.
getAugmentedPath always uses : when joining PATH segments, which corrupts PATH entries on Windows (they are ;-delimited). Once this runs, any appended directory becomes part of the previous entry, so executables in those locations stop resolving—negating the Windows path fixes this PR is targeting.(cs.unb.ca)
Please join with the platform-specific separator (via path.delimiter or process.platform) and skip empty segments so existing PATH contents stay intact. For example:
129-136: Fix reserved-name check for nested segments
The reserved-name guard only matches when the entire normalized path equals a device name. Windows still rejects segments like reports/CON/report.pdf or AUX.txt, so malicious or unlucky input slips through and the export blows up later when we try to create the directory. Please split the path into segments (both / and \) and check each (ignoring '.'/'') against the reserved-name list, treating names with extensions as invalid too.
Line 210 applies both path.normalize() and normalizePath() to the result. Since normalizePath() (from Obsidian) already handles path normalization and ensures forward slashes, the intermediate path.normalize() call may be redundant and could potentially interfere with Obsidian's normalization.
Consider this simplification:
// Use path.join to properly handle absolute paths
const result = path.join(pluginDir, dirName);
- return normalizePath(path.normalize(result));
+ return normalizePath(result);
The same pattern appears in isPluginTempDir at lines 447-448, which may also benefit from removing the intermediate path.join after normalization is already applied.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📥 Commits
Reviewing files that changed from the base of the PR and between 4a0376ec2b and 4eb52d11c0.
⛔ Files ignored due to path filters (1)
package-lock.json is excluded by !**/package-lock.json
Use npm as the package manager (project scripts and deps defined in package.json)
Files:
package.json
src/**/*.ts
📄 CodeRabbit inference engine (AGENTS.md)
src/**/*.ts: Organize code into multiple files under src/ (commands/, ui/, utils/, etc.) rather than putting everything in main.ts
Add user-facing commands via this.addCommand(...) and use stable command IDs
Persist settings using this.loadData()/this.saveData() and provide sensible defaults via a settings tab
Register and clean up all DOM, app, and interval listeners using this.register* helpers for safe unload
Prefer async/await over promise chains and handle errors gracefully
Learnt from: CR
Repo: AlexKucera/obsidian-typst-pdf-export PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-09-25T14:48:20.040Z
Learning: Applies to esbuild.config.mjs : Use esbuild for bundling (this sample relies on esbuild.config.mjs)
Applied to files:
package.json
📚 Learning: 2025-09-25T14:27:31.837Z
Learnt from: AlexKucera
Repo: AlexKucera/obsidian-typst-pdf-export PR: 5
File: src/core/PathUtils.ts:108-119
Timestamp: 2025-09-25T14:27:31.837Z
Learning: The obsidian-typst-pdf-export plugin prefers to avoid Node.js built-in modules like 'path' and instead stick to Obsidian API calls for path operations.
Applied to files:
src/plugin/EmbedProcessor.ts
tests/__mocks__/obsidian.ts
src/converters/PdfToImageConverter.ts
src/core/PathUtils.ts
src/core/TempDirectoryManager.ts
src/core/ExecutableChecker.ts
src/core/constants.ts
📚 Learning: 2025-09-25T14:14:57.437Z
Learnt from: AlexKucera
Repo: AlexKucera/obsidian-typst-pdf-export PR: 5
File: src/converters/pandoc/ResourcePathResolver.ts:109-111
Timestamp: 2025-09-25T14:14:57.437Z
Learning: In src/converters/pandoc/ResourcePathResolver.ts, the image extension regex /\.(png|jpg|jpeg|gif|svg|webp|bmp|ico|tiff)$/i is intentionally restricted and should not be expanded to include additional formats like .tif, .avif, .heic, .heif as this is a conscious design decision by the maintainer.
Applied to files:
src/plugin/EmbedProcessor.ts
src/converters/PdfToImageConverter.ts
📚 Learning: 2025-09-25T14:48:20.040Z
Learnt from: CR
Repo: AlexKucera/obsidian-typst-pdf-export PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-09-25T14:48:20.040Z
Learning: Applies to src/**/*.ts : Add user-facing commands via this.addCommand(...) and use stable command IDs
Applied to files:
src/converters/pandoc/PandocCommandBuilder.ts
📚 Learning: 2025-09-25T14:48:20.040Z
Learnt from: CR
Repo: AlexKucera/obsidian-typst-pdf-export PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-09-25T14:48:20.040Z
Learning: Applies to src/**/*.ts : Persist settings using this.loadData()/this.saveData() and provide sensible defaults via a settings tab
The test suite thoroughly exercises all public methods of TempDirectoryManager with proper mocking, error handling scenarios, and cross-platform path validation. The tests cover:
Constructor and factory method initialization
Directory path resolution for both 'images' and 'pandoc' types
Directory creation with existence checks
Cleanup operations with file removal and error handling
Path validation for security checks
Windows-style path normalization
src/core/settings.ts (1)
1-341: LGTM! Excellent settings architecture and documentation.
The settings module provides a well-designed configuration schema with:
Comprehensive JSDoc explaining purpose, usage, and lifecycle of each setting
Sensible defaults that work out-of-the-box
Type safety through TypeScript interfaces and enums
Detailed examples showing how settings are loaded, merged, and used
The documentation quality is exceptional and will help future maintainers understand the configuration system.
src/core/ModalSettingsHelper.ts (1)
1-279: LGTM! Clean API design with excellent documentation.
The ModalSettingsHelper provides a well-structured interface for transforming plugin settings into modal configuration:
Clear separation between single-file and multi-file export preparation
Automatic template variable extraction from plugin settings
Smart handling of multi-file scenarios (count display, file arrays)
Landscape mode width adjustment for single-page exports
Comprehensive JSDoc with multiple usage examples
The static method design promotes clean, stateless operation and simplifies testing.
src/core/TempDirectoryManager.ts (2)
26-26: Node.js 'path' module usage is intentional for cross-platform support.
While past learnings indicate a preference to avoid Node.js built-in modules in favor of Obsidian API calls, the use of the 'path' module here aligns with the PR objectives to resolve Windows path handling issues. The Node.js 'path' module provides robust cross-platform path operations (especially for Windows drive letters and absolute path handling) that complement Obsidian's normalizePath function.
Based on learnings
1-452: Excellent implementation with comprehensive documentation.
The TempDirectoryManager provides robust temporary directory management with:
Cross-platform path handling using Node.js path utilities + Obsidian normalizePath
Automatic directory creation on first use
Safe cleanup preserving directory structure
Security validation to prevent directory traversal
Comprehensive error handling with console warnings rather than exceptions
Well-documented lifecycle and usage patterns
The singleton pattern via static create() and extensive JSDoc make this class easy to use and maintain.
src/converters/PdfToImageConverter.ts (1)
1-631: LGTM! Excellent converter architecture with outstanding documentation.
The PdfToImageConverter provides a robust, well-documented singleton for PDF-to-image conversion:
Strengths:
Clear separation of concerns via delegation to specialized utilities (PdfProcessor, PdfCliExecutor, FileDiscovery, ImageOptimizer)
Proper singleton pattern with plugin reference updates
Comprehensive error handling that returns results rather than throwing exceptions
Detailed JSDoc with multiple usage examples for each method
Well-defined interfaces (PdfConversionOptions, PdfConversionResult) with sensible defaults
Multi-stage pipeline with validation, conversion, discovery, and optimization
Architecture Benefits:
First-page-only conversion is fast and suitable for preview purposes
Configurable quality/dimensions for different use cases
Error messages preserve context for debugging
Modular design allows easy extension for multi-page conversion
Plugin reference enables vault file operations via PathUtils
The documentation quality is exceptional and the implementation is production-ready.
**Actionable comments posted: 1**
> [!CAUTION]
> Some comments are outside the diff and can’t be posted inline due to platform limitations.
>
>
>
> <details>
> <summary>⚠️ Outside diff range comments (4)</summary><blockquote>
>
> <details>
> <summary>src/converters/PandocTypstConverter.ts (2)</summary><blockquote>
>
> `190-198`: **Don't claim success on failure paths.**
>
> `progressCallback?.('Conversion complete!', 100);` fires even when `result.success` is false, so the UI reports a 100 % success message on failed exports. Guard this so the success message only emits when the conversion actually succeeded, or emit a failure update instead.
>
> ```diff
> - progressCallback?.('Conversion complete!', 100);
> + if (result.success) {
> + progressCallback?.('Conversion complete!', 100);
> + }
> ```
>
> ---
>
> `294-303`: **Unwind global process listeners and drop `uncaughtException` hook.**
>
> Every converter instantiation registers four `process.on` handlers that are never removed. Over time this leaks listeners, prevents the converter from being garbage-collected, and will eventually hit Node’s listener cap. Worse, the `uncaughtException` handler swallows the error (Node stops exiting once a handler is present), so any unrelated crash just triggers cleanup and the original error disappears. Please register these handlers once (or store them and remove them in `dispose/cleanup`) and avoid the global `uncaughtException` hook—or at least rethrow/exit after cleanup so errors are not silently consumed.
>
> </blockquote></details>
> <details>
> <summary>src/core/ExecutableChecker.ts (1)</summary><blockquote>
>
> `80-92`: **Fix PATH delimiter handling on Windows.**
>
> `getAugmentedPath` always uses `:` when joining PATH segments, which corrupts PATH entries on Windows (they are `;`-delimited). Once this runs, any appended directory becomes part of the previous entry, so executables in those locations stop resolving—negating the Windows path fixes this PR is targeting.([cs.unb.ca](https://www.cs.unb.ca/~bremner/teaching/cs2613/books/nodejs-api/path/))
>
> Please join with the platform-specific separator (via `path.delimiter` or `process.platform`) and skip empty segments so existing PATH contents stay intact. For example:
>
> ```diff
> - return `${process.env.PATH}:${allAdditionalPaths.join(':')}`;
> + const delimiter = process.platform === 'win32' ? ';' : ':';
> + const segments = [
> + process.env.PATH ?? '',
> + ...allAdditionalPaths.filter(p => p && p.trim() !== '')
> + ];
> + return segments.filter(Boolean).join(delimiter);
> ```
>
> </blockquote></details>
> <details>
> <summary>src/core/SecurityUtils.ts (1)</summary><blockquote>
>
> `129-136`: **Fix reserved-name check for nested segments**
>
> The reserved-name guard only matches when the entire normalized path equals a device name. Windows still rejects segments like `reports/CON/report.pdf` or `AUX.txt`, so malicious or unlucky input slips through and the export blows up later when we try to create the directory. Please split the path into segments (both `/` and `\`) and check each (ignoring `'.'`/`''`) against the reserved-name list, treating names with extensions as invalid too.
>
> Apply this diff to harden the validation:
>
> ```diff
> - /^(CON|PRN|AUX|NUL|COM[1-9]|LPT[1-9])$/i // Windows reserved names
> + (): void => {
> + const reserved = /^(CON|PRN|AUX|NUL|COM[1-9]|LPT[1-9])$/i;
> + return normalizedPath
> + .split(/[\\/]+/)
> + .filter(segment => segment && segment !== '.')
> + .some(segment => reserved.test(segment.split('.')[0] ?? ''));
> + }
> ```
>
> (Replace the existing regex entry with a function that inspects each segment.)
>
> </blockquote></details>
>
> </blockquote></details>
<details>
<summary>🧹 Nitpick comments (1)</summary><blockquote>
<details>
<summary>src/core/TempDirectoryManager.ts (1)</summary><blockquote>
`207-210`: **Consider removing redundant path.normalize call.**
Line 210 applies both `path.normalize()` and `normalizePath()` to the result. Since `normalizePath()` (from Obsidian) already handles path normalization and ensures forward slashes, the intermediate `path.normalize()` call may be redundant and could potentially interfere with Obsidian's normalization.
Consider this simplification:
```diff
// Use path.join to properly handle absolute paths
const result = path.join(pluginDir, dirName);
- return normalizePath(path.normalize(result));
+ return normalizePath(result);
```
The same pattern appears in `isPluginTempDir` at lines 447-448, which may also benefit from removing the intermediate `path.join` after normalization is already applied.
</blockquote></details>
</blockquote></details>
<details>
<summary>📜 Review details</summary>
**Configuration used**: CodeRabbit UI
**Review profile**: CHILL
**Plan**: Pro
<details>
<summary>📥 Commits</summary>
Reviewing files that changed from the base of the PR and between 4a0376ec2b922897f5c80e64a0e7268aa3980503 and 4eb52d11c002c4b89b40e35fa3a8b947e1d14f9a.
</details>
<details>
<summary>⛔ Files ignored due to path filters (1)</summary>
* `package-lock.json` is excluded by `!**/package-lock.json`
</details>
<details>
<summary>📒 Files selected for processing (27)</summary>
* `.gitignore` (1 hunks)
* `package.json` (2 hunks)
* `src/converters/MarkdownPreprocessor.ts` (10 hunks)
* `src/converters/PandocTypstConverter.ts` (9 hunks)
* `src/converters/PdfToImageConverter.ts` (6 hunks)
* `src/converters/pandoc/PandocCommandBuilder.ts` (8 hunks)
* `src/converters/pandoc/PandocExecutor.ts` (4 hunks)
* `src/core/DependencyChecker.ts` (6 hunks)
* `src/core/ExecutableChecker.ts` (8 hunks)
* `src/core/ExportErrorHandler.ts` (9 hunks)
* `src/core/ModalSettingsHelper.ts` (5 hunks)
* `src/core/PathUtils.ts` (4 hunks)
* `src/core/SecurityUtils.ts` (4 hunks)
* `src/core/TempDirectoryManager.ts` (6 hunks)
* `src/core/constants.ts` (5 hunks)
* `src/core/settings.ts` (2 hunks)
* `src/plugin/EmbedProcessor.ts` (4 hunks)
* `tests/ModalSettingsHelper.test.ts` (1 hunks)
* `tests/SecurityUtils.test.ts` (1 hunks)
* `tests/TempDirectoryManager.test.ts` (1 hunks)
* `tests/TypstVariableMapper.test.ts` (1 hunks)
* `tests/__mocks__/obsidian.ts` (1 hunks)
* `tests/basicCoverage.test.ts` (1 hunks)
* `tests/converterTypes.test.ts` (1 hunks)
* `tests/paperSizeMapper.test.ts` (1 hunks)
* `tests/setup.ts` (1 hunks)
* `vitest.config.ts` (1 hunks)
</details>
<details>
<summary>✅ Files skipped from review due to trivial changes (2)</summary>
* tests/SecurityUtils.test.ts
* tests/ModalSettingsHelper.test.ts
</details>
<details>
<summary>🧰 Additional context used</summary>
<details>
<summary>📓 Path-based instructions (2)</summary>
<details>
<summary>package.json</summary>
**📄 CodeRabbit inference engine (AGENTS.md)**
> Use npm as the package manager (project scripts and deps defined in package.json)
Files:
- `package.json`
</details>
<details>
<summary>src/**/*.ts</summary>
**📄 CodeRabbit inference engine (AGENTS.md)**
> `src/**/*.ts`: Organize code into multiple files under src/ (commands/, ui/, utils/, etc.) rather than putting everything in main.ts
> Add user-facing commands via this.addCommand(...) and use stable command IDs
> Persist settings using this.loadData()/this.saveData() and provide sensible defaults via a settings tab
> Register and clean up all DOM, app, and interval listeners using this.register* helpers for safe unload
> Prefer async/await over promise chains and handle errors gracefully
Files:
- `src/converters/pandoc/PandocExecutor.ts`
- `src/core/ModalSettingsHelper.ts`
- `src/core/DependencyChecker.ts`
- `src/plugin/EmbedProcessor.ts`
- `src/core/SecurityUtils.ts`
- `src/converters/PandocTypstConverter.ts`
- `src/converters/MarkdownPreprocessor.ts`
- `src/converters/PdfToImageConverter.ts`
- `src/converters/pandoc/PandocCommandBuilder.ts`
- `src/core/settings.ts`
- `src/core/PathUtils.ts`
- `src/core/TempDirectoryManager.ts`
- `src/core/ExportErrorHandler.ts`
- `src/core/ExecutableChecker.ts`
- `src/core/constants.ts`
</details>
</details><details>
<summary>🧠 Learnings (5)</summary>
<details>
<summary>📚 Learning: 2025-09-25T14:48:20.040Z</summary>
```
Learnt from: CR
Repo: AlexKucera/obsidian-typst-pdf-export PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-09-25T14:48:20.040Z
Learning: Applies to esbuild.config.mjs : Use esbuild for bundling (this sample relies on esbuild.config.mjs)
```
**Applied to files:**
- `package.json`
</details>
<details>
<summary>📚 Learning: 2025-09-25T14:27:31.837Z</summary>
```
Learnt from: AlexKucera
Repo: AlexKucera/obsidian-typst-pdf-export PR: 5
File: src/core/PathUtils.ts:108-119
Timestamp: 2025-09-25T14:27:31.837Z
Learning: The obsidian-typst-pdf-export plugin prefers to avoid Node.js built-in modules like 'path' and instead stick to Obsidian API calls for path operations.
```
**Applied to files:**
- `src/plugin/EmbedProcessor.ts`
- `tests/__mocks__/obsidian.ts`
- `src/converters/PdfToImageConverter.ts`
- `src/core/PathUtils.ts`
- `src/core/TempDirectoryManager.ts`
- `src/core/ExecutableChecker.ts`
- `src/core/constants.ts`
</details>
<details>
<summary>📚 Learning: 2025-09-25T14:14:57.437Z</summary>
```
Learnt from: AlexKucera
Repo: AlexKucera/obsidian-typst-pdf-export PR: 5
File: src/converters/pandoc/ResourcePathResolver.ts:109-111
Timestamp: 2025-09-25T14:14:57.437Z
Learning: In src/converters/pandoc/ResourcePathResolver.ts, the image extension regex /\.(png|jpg|jpeg|gif|svg|webp|bmp|ico|tiff)$/i is intentionally restricted and should not be expanded to include additional formats like .tif, .avif, .heic, .heif as this is a conscious design decision by the maintainer.
```
**Applied to files:**
- `src/plugin/EmbedProcessor.ts`
- `src/converters/PdfToImageConverter.ts`
</details>
<details>
<summary>📚 Learning: 2025-09-25T14:48:20.040Z</summary>
```
Learnt from: CR
Repo: AlexKucera/obsidian-typst-pdf-export PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-09-25T14:48:20.040Z
Learning: Applies to src/**/*.ts : Add user-facing commands via this.addCommand(...) and use stable command IDs
```
**Applied to files:**
- `src/converters/pandoc/PandocCommandBuilder.ts`
</details>
<details>
<summary>📚 Learning: 2025-09-25T14:48:20.040Z</summary>
```
Learnt from: CR
Repo: AlexKucera/obsidian-typst-pdf-export PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-09-25T14:48:20.040Z
Learning: Applies to src/**/*.ts : Persist settings using this.loadData()/this.saveData() and provide sensible defaults via a settings tab
```
**Applied to files:**
- `src/core/settings.ts`
</details>
</details><details>
<summary>🧬 Code graph analysis (14)</summary>
<details>
<summary>tests/TempDirectoryManager.test.ts (2)</summary><blockquote>
<details>
<summary>tests/__mocks__/obsidian.ts (1)</summary>
* `App` (54-65)
</details>
<details>
<summary>src/core/TempDirectoryManager.ts (1)</summary>
* `TempDirectoryManager` (117-453)
</details>
</blockquote></details>
<details>
<summary>src/converters/pandoc/PandocExecutor.ts (2)</summary><blockquote>
<details>
<summary>src/plugin/PathResolver.ts (1)</summary>
* `PathResolver` (12-87)
</details>
<details>
<summary>src/converters/converterTypes.ts (1)</summary>
* `PandocOptions` (5-30)
</details>
</blockquote></details>
<details>
<summary>src/core/ModalSettingsHelper.ts (1)</summary><blockquote>
<details>
<summary>tests/__mocks__/obsidian.ts (1)</summary>
* `TFile` (36-40)
</details>
</blockquote></details>
<details>
<summary>tests/paperSizeMapper.test.ts (1)</summary><blockquote>
<details>
<summary>src/utils/paperSizeMapper.ts (5)</summary>
* `SUPPORTED_PAPER_SIZES` (17-58)
* `DEFAULT_PAPER_SIZE` (63-63)
* `isSupportedPaperSize` (96-98)
* `mapToTypstPaperSize` (70-81)
* `getValidTypstPaperSizes` (87-89)
</details>
</blockquote></details>
<details>
<summary>src/plugin/EmbedProcessor.ts (3)</summary><blockquote>
<details>
<summary>src/core/PathUtils.ts (1)</summary>
* `PathUtils` (29-251)
</details>
<details>
<summary>main.ts (1)</summary>
* `obsidianTypstPDFExport` (30-245)
</details>
<details>
<summary>tests/__mocks__/obsidian.ts (1)</summary>
* `TFile` (36-40)
</details>
</blockquote></details>
<details>
<summary>vitest.config.ts (1)</summary><blockquote>
<details>
<summary>scripts/package-plugin.js (1)</summary>
* `path` (12-12)
</details>
</blockquote></details>
<details>
<summary>tests/basicCoverage.test.ts (2)</summary><blockquote>
<details>
<summary>src/core/constants.ts (4)</summary>
* `FALLBACK_FONTS` (52-64)
* `PLUGIN_DIRS` (89-93)
* `EXPORT_CONSTANTS` (122-128)
* `DEPENDENCY_CONSTANTS` (187-252)
</details>
<details>
<summary>src/utils/paperSizeMapper.ts (4)</summary>
* `SUPPORTED_PAPER_SIZES` (17-58)
* `mapToTypstPaperSize` (70-81)
* `isSupportedPaperSize` (96-98)
* `DEFAULT_PAPER_SIZE` (63-63)
</details>
</blockquote></details>
<details>
<summary>tests/TypstVariableMapper.test.ts (3)</summary><blockquote>
<details>
<summary>src/core/settings.ts (1)</summary>
* `obsidianTypstPDFExportSettings` (75-230)
</details>
<details>
<summary>src/converters/pandoc/TypstVariableMapper.ts (1)</summary>
* `TypstVariableMapper` (16-324)
</details>
<details>
<summary>src/converters/converterTypes.ts (1)</summary>
* `PandocOptions` (5-30)
</details>
</blockquote></details>
<details>
<summary>src/converters/MarkdownPreprocessor.ts (2)</summary><blockquote>
<details>
<summary>src/converters/preprocessors/WikilinkProcessor.ts (1)</summary>
* `PreprocessingResult` (20-58)
</details>
<details>
<summary>src/converters/preprocessors/EmbedProcessor.ts (1)</summary>
* `PreprocessingResult` (14-52)
</details>
</blockquote></details>
<details>
<summary>src/converters/PdfToImageConverter.ts (2)</summary><blockquote>
<details>
<summary>main.ts (1)</summary>
* `obsidianTypstPDFExport` (30-245)
</details>
<details>
<summary>src/converters/pdf/PdfProcessor.ts (1)</summary>
* `PdfProcessor` (19-108)
</details>
</blockquote></details>
<details>
<summary>src/converters/pandoc/PandocCommandBuilder.ts (4)</summary><blockquote>
<details>
<summary>src/converters/pandoc/TypstVariableMapper.ts (1)</summary>
* `TypstVariableMapper` (16-324)
</details>
<details>
<summary>src/converters/pandoc/ResourcePathResolver.ts (1)</summary>
* `ResourcePathResolver` (8-142)
</details>
<details>
<summary>src/plugin/PathResolver.ts (1)</summary>
* `PathResolver` (12-87)
</details>
<details>
<summary>src/converters/converterTypes.ts (1)</summary>
* `PandocOptions` (5-30)
</details>
</blockquote></details>
<details>
<summary>src/core/PathUtils.ts (1)</summary><blockquote>
<details>
<summary>tests/__mocks__/obsidian.ts (2)</summary>
* `App` (54-65)
* `normalizePath` (47-49)
</details>
</blockquote></details>
<details>
<summary>src/core/TempDirectoryManager.ts (2)</summary><blockquote>
<details>
<summary>tests/__mocks__/obsidian.ts (2)</summary>
* `App` (54-65)
* `normalizePath` (47-49)
</details>
<details>
<summary>src/core/constants.ts (1)</summary>
* `PLUGIN_DIRS` (89-93)
</details>
</blockquote></details>
<details>
<summary>src/core/ExportErrorHandler.ts (1)</summary><blockquote>
<details>
<summary>tests/__mocks__/obsidian.ts (1)</summary>
* `Notice` (4-6)
</details>
</blockquote></details>
</details>
</details>
<details>
<summary>🔇 Additional comments (6)</summary><blockquote>
<details>
<summary>tests/TempDirectoryManager.test.ts (1)</summary><blockquote>
`1-368`: **LGTM! Comprehensive test coverage.**
The test suite thoroughly exercises all public methods of TempDirectoryManager with proper mocking, error handling scenarios, and cross-platform path validation. The tests cover:
- Constructor and factory method initialization
- Directory path resolution for both 'images' and 'pandoc' types
- Directory creation with existence checks
- Cleanup operations with file removal and error handling
- Path validation for security checks
- Windows-style path normalization
</blockquote></details>
<details>
<summary>src/core/settings.ts (1)</summary><blockquote>
`1-341`: **LGTM! Excellent settings architecture and documentation.**
The settings module provides a well-designed configuration schema with:
- Clear separation of concerns (paths, executables, export defaults, typography, page setup, behavior)
- Comprehensive JSDoc explaining purpose, usage, and lifecycle of each setting
- Sensible defaults that work out-of-the-box
- Type safety through TypeScript interfaces and enums
- Detailed examples showing how settings are loaded, merged, and used
The documentation quality is exceptional and will help future maintainers understand the configuration system.
</blockquote></details>
<details>
<summary>src/core/ModalSettingsHelper.ts (1)</summary><blockquote>
`1-279`: **LGTM! Clean API design with excellent documentation.**
The ModalSettingsHelper provides a well-structured interface for transforming plugin settings into modal configuration:
- Clear separation between single-file and multi-file export preparation
- Automatic template variable extraction from plugin settings
- Smart handling of multi-file scenarios (count display, file arrays)
- Landscape mode width adjustment for single-page exports
- Comprehensive JSDoc with multiple usage examples
The static method design promotes clean, stateless operation and simplifies testing.
</blockquote></details>
<details>
<summary>src/core/TempDirectoryManager.ts (2)</summary><blockquote>
`26-26`: **Node.js 'path' module usage is intentional for cross-platform support.**
While past learnings indicate a preference to avoid Node.js built-in modules in favor of Obsidian API calls, the use of the 'path' module here aligns with the PR objectives to resolve Windows path handling issues. The Node.js 'path' module provides robust cross-platform path operations (especially for Windows drive letters and absolute path handling) that complement Obsidian's normalizePath function.
Based on learnings
---
`1-452`: **Excellent implementation with comprehensive documentation.**
The TempDirectoryManager provides robust temporary directory management with:
- Cross-platform path handling using Node.js path utilities + Obsidian normalizePath
- Automatic directory creation on first use
- Safe cleanup preserving directory structure
- Security validation to prevent directory traversal
- Comprehensive error handling with console warnings rather than exceptions
- Well-documented lifecycle and usage patterns
The singleton pattern via `static create()` and extensive JSDoc make this class easy to use and maintain.
</blockquote></details>
<details>
<summary>src/converters/PdfToImageConverter.ts (1)</summary><blockquote>
`1-631`: **LGTM! Excellent converter architecture with outstanding documentation.**
The PdfToImageConverter provides a robust, well-documented singleton for PDF-to-image conversion:
**Strengths:**
- Clear separation of concerns via delegation to specialized utilities (PdfProcessor, PdfCliExecutor, FileDiscovery, ImageOptimizer)
- Proper singleton pattern with plugin reference updates
- Comprehensive error handling that returns results rather than throwing exceptions
- Detailed JSDoc with multiple usage examples for each method
- Well-defined interfaces (PdfConversionOptions, PdfConversionResult) with sensible defaults
- Multi-stage pipeline with validation, conversion, discovery, and optimization
**Architecture Benefits:**
- First-page-only conversion is fast and suitable for preview purposes
- Configurable quality/dimensions for different use cases
- Error messages preserve context for debugging
- Modular design allows easy extension for multi-page conversion
- Plugin reference enables vault file operations via PathUtils
The documentation quality is exceptional and the implementation is production-ready.
</blockquote></details>
</blockquote></details>
</details>
<!-- This is an auto-generated comment by CodeRabbit for review status -->
startsWith('https') is case-sensitive, so uppercase schemes like HTTPS://… will hit the HTTP client. Node’s http.get('HTTPS://...') throws “Protocol "https:" not supported,” and every such remote download fails. Use the parsed URL’s protocol instead so we always call the right module.
Committable suggestion skipped: line range outside the PR's diff.
🤖 Prompt for AI Agents
In src/plugin/EmbedProcessor.ts around lines 108 to 110, the current protocol
selection uses imageUrl.startsWith('https') which is case-sensitive and fails
for uppercase schemes; parse the imageUrl with the URL constructor (e.g., new
URL(imageUrl)), read its .protocol (which will be 'https:' or 'http:'), and pick
the module accordingly (protocol === 'https:' ? https : http); ensure you use
the parsed URL object for the request call so the correct protocol is always
used.
_⚠️ Potential issue_ | _🟠 Major_
**Fix protocol selection for HTTPS URLs.**
`startsWith('https')` is case-sensitive, so uppercase schemes like `HTTPS://…` will hit the HTTP client. Node’s `http.get('HTTPS://...')` throws “Protocol "https:" not supported,” and every such remote download fails. Use the parsed URL’s protocol instead so we always call the right module.
```diff
- const protocol = imageUrl.startsWith('https') ? https : http;
+ const protocol = urlObj.protocol === 'https:' ? https : http;
```
> Committable suggestion skipped: line range outside the PR's diff.
<details>
<summary>🤖 Prompt for AI Agents</summary>
```
In src/plugin/EmbedProcessor.ts around lines 108 to 110, the current protocol
selection uses imageUrl.startsWith('https') which is case-sensitive and fails
for uppercase schemes; parse the imageUrl with the URL constructor (e.g., new
URL(imageUrl)), read its .protocol (which will be 'https:' or 'http:'), and pick
the module accordingly (protocol === 'https:' ? https : http); ensure you use
the parsed URL object for the request call so the correct protocol is always
used.
```
</details>
<!-- fingerprinting:phantom:medusa:sabertoothed -->
<!-- This is an auto-generated comment by CodeRabbit -->
✅ Addressed in commits 1aeebed to 35a5249
coderabbitai[bot]
(Migrated from github.com)
left a comment
Copy link
Copy source
Actionable comments posted: 0
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (6)
src/core/SecurityUtils.ts (1)
219-231: Legitimate Windows executables now fail validation dangerousPatterns (Line 220) blocks (, ), {, }, [, ], so SecurityUtils.validateExecutablePath("C:\\Program Files (x86)\\Pandoc\\pandoc.exe") now returns false. That is the default installer path on Windows, meaning most users cannot point to Pandoc/Typst/ImageMagick without hitting “Shell metacharacters are not allowed…”. We’re rejecting safe, real-world paths, so this breaks the configuration flow and contradicts the examples right above the method. Please narrow the metacharacter check to characters that are actually dangerous in our spawn usage and rely on the dedicated substitution regexes for $() / ${}. Suggested fix:
- /[;&|`$(){}[\]]/, // Shell metacharacters
+ /[;&|`$<>]/, // Shell metacharacters that can't appear in safe paths
Make the same adjustment in getExecutablePathValidationError (Line 374).
src/core/ExecutableChecker.ts (4)
141-182: Critical: which command doesn't exist on Windows.
The which command (line 148) is Unix-specific and will fail on Windows systems. Windows uses the where command instead. Since this PR specifically addresses Windows path issues, this cross-platform incompatibility is a blocker.
Apply this diff to add platform-specific command selection:
Line 217 uses includes('/') to detect paths, but Windows paths use backslashes (e.g., C:\Program Files\pandoc\pandoc.exe). This will cause Windows absolute paths to be incorrectly treated as executable names. Since the PR objectives specifically mention "Resolves issues with absolute path handling on Windows," this is a critical regression.
Apply this diff to support both Unix and Windows path separators:
public static async resolveExecutablePath(userPath: string | undefined, defaultName: string, additionalPaths: string[] = []): Promise<string> {
- // If user provided a full path (contains /), use it as-is
- if (userPath && userPath.trim() !== '' && userPath.includes('/')) {
+ // If user provided a full path (contains / or \), use it as-is
+ if (userPath && userPath.trim() !== '' && (userPath.includes('/') || userPath.includes('\\'))) {
return userPath;
}
248-277: Critical: Windows path detection and command compatibility issues.
This method has the same two critical Windows compatibility issues:
Line 250: includes('/') won't detect Windows paths with backslashes
Line 260: which command doesn't exist on Windows (needs where instead)
Apply this diff to fix both issues:
public static resolveExecutablePathSync(userPath: string | undefined, defaultName: string, additionalPaths: string[] = []): string {
- // If user provided a full path (contains /), use it as-is
- if (userPath && userPath.trim() !== '' && userPath.includes('/')) {
+ // If user provided a full path (contains / or \), use it as-is
+ if (userPath && userPath.trim() !== '' && (userPath.includes('/') || userPath.includes('\\'))) {
return userPath;
}
// If user provided just an executable name or empty path, resolve it
const searchName = (userPath && userPath.trim() !== '') ? userPath.trim() : defaultName;
// Try to find the executable using which command synchronously
const { spawnSync } = require('child_process');
+ const whichCommand = process.platform === 'win32' ? 'where' : 'which';
try {
- const result = spawnSync('which', [searchName], {
+ const result = spawnSync(whichCommand, [searchName], {
encoding: 'utf8',
env: this.getAugmentedEnv(additionalPaths)
});
1-402: Now I need to look at how to properly detect absolute paths in a cross-platform way:
Critical Windows compatibility issues require immediate fixes in path detection and executable resolution.
Verification found critical cross-platform problems across multiple files:
Path detection bug (ExecutableChecker.ts lines 195, 258): The code uses userPath.includes('/') to detect absolute paths, but on Windows paths use backslashes; path.isAbsolute() correctly handles Windows drive letters like C:\temp and UNC paths like \\server\share.
which command fails on Windows (ExecutableChecker.ts lines 148, 260; PathResolver.ts line 36): The which command doesn't exist on Windows, making executable resolution completely non-functional for Windows users. The codebase needs a platform-aware approach—either detecting Windows with process.platform === 'win32' or using a cross-platform npm package like cross-spawn.
Inconsistent pattern: PathUtils.ts already has proper cross-platform path detection that should be matched here—it correctly checks for Unix paths (/), Windows drive letters (regex match), and UNC paths (\\).
Replace manual path checks with path.isAbsolute() from the path module (available since Node.js 0.12.0) and implement Windows-aware executable resolution.
src/core/TempDirectoryManager.ts (1)
443-451: Tighten temp dir boundary check
startsWith lets anything prefixed with temp-images (e.g., /temp-images-backup) pass the guard, which defeats the “validation” guarantee and allows operations outside the intended directories. Please require an exact match or ensure the next character is a / so only the real temp folders (and their descendants) are accepted.
312-369: LGTM: Secure and robust dependency checking.
The use of spawn with separated arguments (line 323) properly prevents command injection. Error handling and return structure are well-designed.
For edge cases where version commands might contain quoted arguments, consider parsing the command more carefully than simple space splitting. However, for typical version flags like --version, the current implementation is sufficient.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📥 Commits
Reviewing files that changed from the base of the PR and between 4eb52d11c0 and 35a5249607.
src/**/*.ts: Organize code into multiple files under src/ (commands/, ui/, utils/, etc.) rather than putting everything in main.ts
Add user-facing commands via this.addCommand(...) and use stable command IDs
Persist settings using this.loadData()/this.saveData() and provide sensible defaults via a settings tab
Register and clean up all DOM, app, and interval listeners using this.register* helpers for safe unload
Prefer async/await over promise chains and handle errors gracefully
Learnt from: AlexKucera
Repo: AlexKucera/obsidian-typst-pdf-export PR: 5
File: src/core/PathUtils.ts:108-119
Timestamp: 2025-09-25T14:27:31.837Z
Learning: The obsidian-typst-pdf-export plugin prefers to avoid Node.js built-in modules like 'path' and instead stick to Obsidian API calls for path operations.
Applied to files:
src/plugin/EmbedProcessor.ts
src/core/TempDirectoryManager.ts
src/core/ExecutableChecker.ts
📚 Learning: 2025-09-25T14:14:57.437Z
Learnt from: AlexKucera
Repo: AlexKucera/obsidian-typst-pdf-export PR: 5
File: src/converters/pandoc/ResourcePathResolver.ts:109-111
Timestamp: 2025-09-25T14:14:57.437Z
Learning: In src/converters/pandoc/ResourcePathResolver.ts, the image extension regex /\.(png|jpg|jpeg|gif|svg|webp|bmp|ico|tiff)$/i is intentionally restricted and should not be expanded to include additional formats like .tif, .avif, .heic, .heif as this is a conscious design decision by the maintainer.
The platform-specific delimiter handling and empty segment filtering are well-implemented. The method correctly combines system paths with user-provided additional paths.
116-121: LGTM: Clean environment builder.
Simple and correct implementation that properly augments the environment with extended PATH.
The simplified boolean return is well-suited for quick initialization checks. Implementation mirrors the async version appropriately.
**Actionable comments posted: 0**
> [!CAUTION]
> Some comments are outside the diff and can’t be posted inline due to platform limitations.
>
>
>
> <details>
> <summary>⚠️ Outside diff range comments (6)</summary><blockquote>
>
> <details>
> <summary>src/core/SecurityUtils.ts (1)</summary><blockquote>
>
> `219-231`: **Legitimate Windows executables now fail validation**
> `dangerousPatterns` (Line 220) blocks `(`, `)`, `{`, `}`, `[`, `]`, so `SecurityUtils.validateExecutablePath("C:\\Program Files (x86)\\Pandoc\\pandoc.exe")` now returns false. That is the default installer path on Windows, meaning most users cannot point to Pandoc/Typst/ImageMagick without hitting “Shell metacharacters are not allowed…”. We’re rejecting safe, real-world paths, so this breaks the configuration flow and contradicts the examples right above the method. Please narrow the metacharacter check to characters that are actually dangerous in our spawn usage and rely on the dedicated substitution regexes for `$()` / `${}`. Suggested fix:
>
> ```diff
> - /[;&|`$(){}[\]]/, // Shell metacharacters
> + /[;&|`$<>]/, // Shell metacharacters that can't appear in safe paths
> ```
>
> Make the same adjustment in `getExecutablePathValidationError` (Line 374).
>
> </blockquote></details>
> <details>
> <summary>src/core/ExecutableChecker.ts (4)</summary><blockquote>
>
> `141-182`: **Critical: `which` command doesn't exist on Windows.**
>
> The `which` command (line 148) is Unix-specific and will fail on Windows systems. Windows uses the `where` command instead. Since this PR specifically addresses Windows path issues, this cross-platform incompatibility is a blocker.
>
>
>
> Apply this diff to add platform-specific command selection:
>
> ```diff
> private static async findExecutableWithWhich(executableName: string, additionalPaths: string[] = []): Promise<string | null> {
> const { spawn } = require('child_process');
> + const whichCommand = process.platform === 'win32' ? 'where' : 'which';
>
> try {
> const stdout = await new Promise<string>((resolve, reject) => {
> const env = this.getAugmentedEnv(additionalPaths);
>
> - const whichProcess = spawn('which', [executableName], {
> + const whichProcess = spawn(whichCommand, [executableName], {
> stdio: ['pipe', 'pipe', 'pipe'],
> env: env
> });
> ```
>
> ---
>
> `215-232`: **Critical: Windows path detection broken.**
>
> Line 217 uses `includes('/')` to detect paths, but Windows paths use backslashes (e.g., `C:\Program Files\pandoc\pandoc.exe`). This will cause Windows absolute paths to be incorrectly treated as executable names. Since the PR objectives specifically mention "Resolves issues with absolute path handling on Windows," this is a critical regression.
>
>
>
> Apply this diff to support both Unix and Windows path separators:
>
> ```diff
> public static async resolveExecutablePath(userPath: string | undefined, defaultName: string, additionalPaths: string[] = []): Promise<string> {
> - // If user provided a full path (contains /), use it as-is
> - if (userPath && userPath.trim() !== '' && userPath.includes('/')) {
> + // If user provided a full path (contains / or \), use it as-is
> + if (userPath && userPath.trim() !== '' && (userPath.includes('/') || userPath.includes('\\'))) {
> return userPath;
> }
> ```
>
> ---
>
> `248-277`: **Critical: Windows path detection and command compatibility issues.**
>
> This method has the same two critical Windows compatibility issues:
>
> 1. Line 250: `includes('/')` won't detect Windows paths with backslashes
> 2. Line 260: `which` command doesn't exist on Windows (needs `where` instead)
>
>
>
> Apply this diff to fix both issues:
>
> ```diff
> public static resolveExecutablePathSync(userPath: string | undefined, defaultName: string, additionalPaths: string[] = []): string {
> - // If user provided a full path (contains /), use it as-is
> - if (userPath && userPath.trim() !== '' && userPath.includes('/')) {
> + // If user provided a full path (contains / or \), use it as-is
> + if (userPath && userPath.trim() !== '' && (userPath.includes('/') || userPath.includes('\\'))) {
> return userPath;
> }
>
> // If user provided just an executable name or empty path, resolve it
> const searchName = (userPath && userPath.trim() !== '') ? userPath.trim() : defaultName;
>
> // Try to find the executable using which command synchronously
> const { spawnSync } = require('child_process');
> + const whichCommand = process.platform === 'win32' ? 'where' : 'which';
> try {
> - const result = spawnSync('which', [searchName], {
> + const result = spawnSync(whichCommand, [searchName], {
> encoding: 'utf8',
> env: this.getAugmentedEnv(additionalPaths)
> });
> ```
>
> ---
>
> `1-402`: Now I need to look at how to properly detect absolute paths in a cross-platform way:
>
> **Critical Windows compatibility issues require immediate fixes in path detection and executable resolution.**
>
> Verification found critical cross-platform problems across multiple files:
>
> 1. **Path detection bug (ExecutableChecker.ts lines 195, 258)**: The code uses `userPath.includes('/')` to detect absolute paths, but on Windows paths use backslashes; `path.isAbsolute()` correctly handles Windows drive letters like `C:\temp` and UNC paths like `\\server\share`.
>
> 2. **`which` command fails on Windows (ExecutableChecker.ts lines 148, 260; PathResolver.ts line 36)**: The `which` command doesn't exist on Windows, making executable resolution completely non-functional for Windows users. The codebase needs a platform-aware approach—either detecting Windows with `process.platform === 'win32'` or using a cross-platform npm package like `cross-spawn`.
>
> 3. **Inconsistent pattern**: PathUtils.ts already has proper cross-platform path detection that should be matched here—it correctly checks for Unix paths (`/`), Windows drive letters (regex match), and UNC paths (`\\`).
>
> Replace manual path checks with `path.isAbsolute()` from the path module (available since Node.js 0.12.0) and implement Windows-aware executable resolution.
>
> </blockquote></details>
> <details>
> <summary>src/core/TempDirectoryManager.ts (1)</summary><blockquote>
>
> `443-451`: **Tighten temp dir boundary check**
>
> `startsWith` lets anything prefixed with `temp-images` (e.g., `/temp-images-backup`) pass the guard, which defeats the “validation” guarantee and allows operations outside the intended directories. Please require an exact match or ensure the next character is a `/` so only the real temp folders (and their descendants) are accepted.
>
> ```diff
> - return normalizedDirPath.startsWith(tempImagesDir) ||
> - normalizedDirPath.startsWith(tempPandocDir);
> + const isImagesDir =
> + normalizedDirPath === tempImagesDir ||
> + normalizedDirPath.startsWith(`${tempImagesDir}/`);
> + const isPandocDir =
> + normalizedDirPath === tempPandocDir ||
> + normalizedDirPath.startsWith(`${tempPandocDir}/`);
> +
> + return isImagesDir || isPandocDir;
> ```
>
> </blockquote></details>
>
> </blockquote></details>
<details>
<summary>🧹 Nitpick comments (1)</summary><blockquote>
<details>
<summary>src/core/ExecutableChecker.ts (1)</summary><blockquote>
`312-369`: **LGTM: Secure and robust dependency checking.**
The use of `spawn` with separated arguments (line 323) properly prevents command injection. Error handling and return structure are well-designed.
For edge cases where version commands might contain quoted arguments, consider parsing the command more carefully than simple space splitting. However, for typical version flags like `--version`, the current implementation is sufficient.
</blockquote></details>
</blockquote></details>
<details>
<summary>📜 Review details</summary>
**Configuration used**: CodeRabbit UI
**Review profile**: CHILL
**Plan**: Pro
<details>
<summary>📥 Commits</summary>
Reviewing files that changed from the base of the PR and between 4eb52d11c002c4b89b40e35fa3a8b947e1d14f9a and 35a5249607720ad86047bd14021a9833f5777318.
</details>
<details>
<summary>📒 Files selected for processing (5)</summary>
* `src/converters/PandocTypstConverter.ts` (8 hunks)
* `src/core/ExecutableChecker.ts` (7 hunks)
* `src/core/SecurityUtils.ts` (4 hunks)
* `src/core/TempDirectoryManager.ts` (6 hunks)
* `src/plugin/EmbedProcessor.ts` (4 hunks)
</details>
<details>
<summary>🧰 Additional context used</summary>
<details>
<summary>📓 Path-based instructions (1)</summary>
<details>
<summary>src/**/*.ts</summary>
**📄 CodeRabbit inference engine (AGENTS.md)**
> `src/**/*.ts`: Organize code into multiple files under src/ (commands/, ui/, utils/, etc.) rather than putting everything in main.ts
> Add user-facing commands via this.addCommand(...) and use stable command IDs
> Persist settings using this.loadData()/this.saveData() and provide sensible defaults via a settings tab
> Register and clean up all DOM, app, and interval listeners using this.register* helpers for safe unload
> Prefer async/await over promise chains and handle errors gracefully
Files:
- `src/plugin/EmbedProcessor.ts`
- `src/core/TempDirectoryManager.ts`
- `src/converters/PandocTypstConverter.ts`
- `src/core/ExecutableChecker.ts`
- `src/core/SecurityUtils.ts`
</details>
</details><details>
<summary>🧠 Learnings (2)</summary>
<details>
<summary>📚 Learning: 2025-09-25T14:27:31.837Z</summary>
```
Learnt from: AlexKucera
Repo: AlexKucera/obsidian-typst-pdf-export PR: 5
File: src/core/PathUtils.ts:108-119
Timestamp: 2025-09-25T14:27:31.837Z
Learning: The obsidian-typst-pdf-export plugin prefers to avoid Node.js built-in modules like 'path' and instead stick to Obsidian API calls for path operations.
```
**Applied to files:**
- `src/plugin/EmbedProcessor.ts`
- `src/core/TempDirectoryManager.ts`
- `src/core/ExecutableChecker.ts`
</details>
<details>
<summary>📚 Learning: 2025-09-25T14:14:57.437Z</summary>
```
Learnt from: AlexKucera
Repo: AlexKucera/obsidian-typst-pdf-export PR: 5
File: src/converters/pandoc/ResourcePathResolver.ts:109-111
Timestamp: 2025-09-25T14:14:57.437Z
Learning: In src/converters/pandoc/ResourcePathResolver.ts, the image extension regex /\.(png|jpg|jpeg|gif|svg|webp|bmp|ico|tiff)$/i is intentionally restricted and should not be expanded to include additional formats like .tif, .avif, .heic, .heif as this is a conscious design decision by the maintainer.
```
**Applied to files:**
- `src/plugin/EmbedProcessor.ts`
</details>
</details><details>
<summary>🧬 Code graph analysis (4)</summary>
<details>
<summary>src/plugin/EmbedProcessor.ts (3)</summary><blockquote>
<details>
<summary>src/converters/preprocessors/EmbedProcessor.ts (1)</summary>
* `EmbedProcessor` (54-244)
</details>
<details>
<summary>src/core/PathUtils.ts (1)</summary>
* `PathUtils` (29-251)
</details>
<details>
<summary>main.ts (1)</summary>
* `obsidianTypstPDFExport` (30-245)
</details>
</blockquote></details>
<details>
<summary>src/core/TempDirectoryManager.ts (2)</summary><blockquote>
<details>
<summary>tests/__mocks__/obsidian.ts (2)</summary>
* `App` (54-65)
* `normalizePath` (47-49)
</details>
<details>
<summary>src/core/constants.ts (1)</summary>
* `PLUGIN_DIRS` (89-93)
</details>
</blockquote></details>
<details>
<summary>src/converters/PandocTypstConverter.ts (2)</summary><blockquote>
<details>
<summary>src/converters/pandoc/PandocCommandBuilder.ts (1)</summary>
* `PandocCommandBuilder` (96-398)
</details>
<details>
<summary>src/converters/pandoc/PandocExecutor.ts (1)</summary>
* `PandocExecutor` (61-415)
</details>
</blockquote></details>
<details>
<summary>src/core/ExecutableChecker.ts (1)</summary><blockquote>
<details>
<summary>src/core/constants.ts (1)</summary>
* `DEPENDENCY_CONSTANTS` (187-252)
</details>
</blockquote></details>
</details>
</details>
<details>
<summary>🔇 Additional comments (3)</summary><blockquote>
<details>
<summary>src/core/ExecutableChecker.ts (3)</summary><blockquote>
`83-103`: **LGTM: Solid cross-platform PATH augmentation.**
The platform-specific delimiter handling and empty segment filtering are well-implemented. The method correctly combines system paths with user-provided additional paths.
---
`116-121`: **LGTM: Clean environment builder.**
Simple and correct implementation that properly augments the environment with extended PATH.
---
`390-402`: **LGTM: Appropriate synchronous availability check.**
The simplified boolean return is well-suited for quick initialization checks. Implementation mirrors the async version appropriately.
</blockquote></details>
</blockquote></details>
</details>
<!-- This is an auto-generated comment by CodeRabbit for review status -->
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Addresses several issues related to file paths, remote images, and bibliography generation:
Summary by CodeRabbit
New Features
Bug Fixes
Refactor
Documentation
Tests
Walkthrough
Adds remote-image detection and download queuing, centralizes vault/path/temp utilities, introduces a Pandoc command builder and richer conversion lifecycle, strengthens dependency and security checks, expands settings and modal helpers, adds PDF→image pipeline, extensive unit tests and Vitest infra, and updates changelog and gitignore.
Changes
src/core/PathUtils.ts,src/core/TempDirectoryManager.ts,src/core/constants.tsPathUtilsfor normalized path operations,TempDirectoryManagerfor plugin-scoped temp dirs and cleanup, extend constants (FONTS_CACHE,NOTICE_DURATION) and expandFALLBACK_FONTS.src/converters/MarkdownPreprocessor.tsmetadata.imageEmbeds, replace with IMAGE_EMBED_MARKER, add options (baseUrl,printFrontmatter) and richer PreprocessingResult.src/plugin/EmbedProcessor.tsresolveLocalPathanddownloadRemoteImage; unify local-resolution and remote-download logic (redirects, timeouts, temp storage, fallbacks) for image/embed processing.src/converters/pandoc/PandocCommandBuilder.ts,src/converters/PandocTypstConverter.ts,src/converters/pandoc/PandocExecutor.tsPandocCommandBuilderto assemble pandoc args (Typst integration, resource paths, templates, engine opts);PandocTypstConverteradds temp-dir lifecycle,convertMarkdownToPDF, cleanup and progress callbacks;PandocExecutordocs expanded.src/converters/PdfToImageConverter.ts,src/converters/pdf/BinaryLocator.tsPdfToImageConvertersingleton API (convert/validate/getInfo), structured conversion pipeline;BinaryLocatorrefactors to reusePathUtilsand refines Windows path handling.src/core/ExecutableChecker.ts,src/core/DependencyChecker.tsDependencyInfo/DependencyCheckResult, PATH/env augmentation helpers, async/sync executable resolution and version checks, status reporting andshowDependencyStatus.src/core/SecurityUtils.ts,src/core/ExportErrorHandler.tsExportErrorHandlerwith structured batch/single error types and multiple user-notice helpers.src/core/settings.ts,src/core/ModalSettingsHelper.tsExportFormatenum, andModalSettingsHelperstatic helpers for single/multi-file modal preparation.tests/*,tests/__mocks__/obsidian.ts,vitest.config.ts,package.json,.gitignorecoverage/to.gitignore.CHANGELOG.md,package.jsonpackage.json.Sequence Diagram(s)
Estimated code review effort
🎯 4 (Complex) | ⏱️ ~50 minutes
Possibly related PRs
Poem
Pre-merge checks and finishing touches
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
windows_path_fix📜 Recent review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📥 Commits
Reviewing files that changed from the base of the PR and between
35a5249607and68238e3db2.📒 Files selected for processing (4)
src/core/ExecutableChecker.ts(7 hunks)src/core/SecurityUtils.ts(6 hunks)src/core/TempDirectoryManager.ts(6 hunks)src/plugin/PathResolver.ts(1 hunks)🧰 Additional context used
📓 Path-based instructions (1)
src/**/*.ts
📄 CodeRabbit inference engine (AGENTS.md)
Files:
src/plugin/PathResolver.tssrc/core/SecurityUtils.tssrc/core/TempDirectoryManager.tssrc/core/ExecutableChecker.ts🧠 Learnings (1)
📚 Learning: 2025-09-25T14:27:31.837Z
Applied to files:
src/core/TempDirectoryManager.tssrc/core/ExecutableChecker.ts🧬 Code graph analysis (2)
src/core/TempDirectoryManager.ts (2)
src/core/ExecutableChecker.ts (1)
🔇 Additional comments (2)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
❤️ Share
Comment
@coderabbitai helpto get the list of available commands and usage tips.@coderabbitai configuration
CodeRabbit configuration
Actionable comments posted: 1
🧹 Nitpick comments (6)
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📥 Commits
Reviewing files that changed from the base of the PR and between
536351cbbfand9ca299cafd.📒 Files selected for processing (7)
CHANGELOG.md(4 hunks)src/converters/MarkdownPreprocessor.ts(3 hunks)src/converters/pandoc/PandocCommandBuilder.ts(1 hunks)src/converters/pdf/BinaryLocator.ts(1 hunks)src/core/PathUtils.ts(2 hunks)src/core/TempDirectoryManager.ts(3 hunks)src/plugin/EmbedProcessor.ts(2 hunks)🧰 Additional context used
📓 Path-based instructions (1)
src/**/*.ts
📄 CodeRabbit inference engine (AGENTS.md)
Files:
src/converters/pdf/BinaryLocator.tssrc/core/TempDirectoryManager.tssrc/core/PathUtils.tssrc/converters/pandoc/PandocCommandBuilder.tssrc/plugin/EmbedProcessor.tssrc/converters/MarkdownPreprocessor.ts🧠 Learnings (2)
📚 Learning: 2025-09-25T14:27:31.837Z
Applied to files:
src/converters/pdf/BinaryLocator.tssrc/core/TempDirectoryManager.tssrc/core/PathUtils.tssrc/plugin/EmbedProcessor.tsCHANGELOG.md📚 Learning: 2025-09-25T14:14:57.437Z
Applied to files:
src/converters/MarkdownPreprocessor.ts🧬 Code graph analysis (5)
src/converters/pdf/BinaryLocator.ts (1)
src/core/TempDirectoryManager.ts (1)
src/core/PathUtils.ts (1)
src/plugin/EmbedProcessor.ts (3)
src/converters/MarkdownPreprocessor.ts (1)
🔇 Additional comments (8)
@@ -8,0 +29,4 @@* Configuration options for TempDirectoryManager initialization.** @property vaultPath - Absolute path to the vault root directory* @property configDir - Configuration directory path (typically '.obsidian')🛠️ Refactor suggestion | 🟠 Major
Remove redundant ternary operator.
Lines 69-71 have a redundant ternary that returns the same result in both branches.
Apply this diff:
🤖 Prompt for AI Agents
✅ Addressed in commits
501f380to4a0376eActionable comments posted: 2
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📥 Commits
Reviewing files that changed from the base of the PR and between
9ca299cafdand4a0376ec2b.📒 Files selected for processing (4)
src/converters/MarkdownPreprocessor.ts(3 hunks)src/core/PathUtils.ts(2 hunks)src/core/TempDirectoryManager.ts(3 hunks)src/plugin/EmbedProcessor.ts(4 hunks)🚧 Files skipped from review as they are similar to previous changes (3)
🧰 Additional context used
📓 Path-based instructions (1)
src/**/*.ts
📄 CodeRabbit inference engine (AGENTS.md)
Files:
src/plugin/EmbedProcessor.ts🧠 Learnings (2)
📚 Learning: 2025-09-25T14:27:31.837Z
Applied to files:
src/plugin/EmbedProcessor.ts📚 Learning: 2025-09-25T14:14:57.437Z
Applied to files:
src/plugin/EmbedProcessor.ts🧬 Code graph analysis (1)
src/plugin/EmbedProcessor.ts (3)
@@ -19,0 +103,4 @@? fileName // Has an extension, preserve it: `${fileName}.png`; // No extension, append .pngconst outputPath = path.join(tempDir, finalFileName);⚠️ Potential issue | 🟠 Major
Preserve original image extensions instead of forcing
.png.When a remote file ends with something like
.svg, we append.pngwithout converting the contents. That leaves us with an SVG payload masquerading as PNG, so Typst/Pandoc will fail to decode the asset. Please keep the on-disk extension if one is present (at least include.svg,.ico, etc. invalidExtensions, or only fall back to.pngwhen the URL truly lacks an extension). Based on learnings🤖 Prompt for AI Agents
✅ Addressed in commits
7ac9e1fto4eb52d1@@ -19,0 +123,4 @@console.log(`Export: Following redirect to: ${absoluteRedirectUrl}`);// Recursively follow redirect with resolved absolute URLthis.downloadRemoteImage(absoluteRedirectUrl, tempDir).then(resolve);return;⚠️ Potential issue | 🟠 Major
Handle relative redirects when downloading images.
Redirects such as
Location: /assets/img.pngare valid butnew URL(redirectUrl)will throw without the original request as a base, causing every relative redirect download to fail. Pass the original URL tonew URL(...)(or otherwise resolve before recursing) so remote images behind relative redirects work.🤖 Prompt for AI Agents
✅ Addressed in commits
7ac9e1fto4eb52d1Actionable comments posted: 1
🧹 Nitpick comments (1)
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📥 Commits
Reviewing files that changed from the base of the PR and between
4a0376ec2band4eb52d11c0.⛔ Files ignored due to path filters (1)
package-lock.jsonis excluded by!**/package-lock.json📒 Files selected for processing (27)
.gitignore(1 hunks)package.json(2 hunks)src/converters/MarkdownPreprocessor.ts(10 hunks)src/converters/PandocTypstConverter.ts(9 hunks)src/converters/PdfToImageConverter.ts(6 hunks)src/converters/pandoc/PandocCommandBuilder.ts(8 hunks)src/converters/pandoc/PandocExecutor.ts(4 hunks)src/core/DependencyChecker.ts(6 hunks)src/core/ExecutableChecker.ts(8 hunks)src/core/ExportErrorHandler.ts(9 hunks)src/core/ModalSettingsHelper.ts(5 hunks)src/core/PathUtils.ts(4 hunks)src/core/SecurityUtils.ts(4 hunks)src/core/TempDirectoryManager.ts(6 hunks)src/core/constants.ts(5 hunks)src/core/settings.ts(2 hunks)src/plugin/EmbedProcessor.ts(4 hunks)tests/ModalSettingsHelper.test.ts(1 hunks)tests/SecurityUtils.test.ts(1 hunks)tests/TempDirectoryManager.test.ts(1 hunks)tests/TypstVariableMapper.test.ts(1 hunks)tests/__mocks__/obsidian.ts(1 hunks)tests/basicCoverage.test.ts(1 hunks)tests/converterTypes.test.ts(1 hunks)tests/paperSizeMapper.test.ts(1 hunks)tests/setup.ts(1 hunks)vitest.config.ts(1 hunks)✅ Files skipped from review due to trivial changes (2)
🧰 Additional context used
📓 Path-based instructions (2)
package.json
📄 CodeRabbit inference engine (AGENTS.md)
Files:
package.jsonsrc/**/*.ts
📄 CodeRabbit inference engine (AGENTS.md)
Files:
src/converters/pandoc/PandocExecutor.tssrc/core/ModalSettingsHelper.tssrc/core/DependencyChecker.tssrc/plugin/EmbedProcessor.tssrc/core/SecurityUtils.tssrc/converters/PandocTypstConverter.tssrc/converters/MarkdownPreprocessor.tssrc/converters/PdfToImageConverter.tssrc/converters/pandoc/PandocCommandBuilder.tssrc/core/settings.tssrc/core/PathUtils.tssrc/core/TempDirectoryManager.tssrc/core/ExportErrorHandler.tssrc/core/ExecutableChecker.tssrc/core/constants.ts🧠 Learnings (5)
📚 Learning: 2025-09-25T14:48:20.040Z
Applied to files:
package.json📚 Learning: 2025-09-25T14:27:31.837Z
Applied to files:
src/plugin/EmbedProcessor.tstests/__mocks__/obsidian.tssrc/converters/PdfToImageConverter.tssrc/core/PathUtils.tssrc/core/TempDirectoryManager.tssrc/core/ExecutableChecker.tssrc/core/constants.ts📚 Learning: 2025-09-25T14:14:57.437Z
Applied to files:
src/plugin/EmbedProcessor.tssrc/converters/PdfToImageConverter.ts📚 Learning: 2025-09-25T14:48:20.040Z
Applied to files:
src/converters/pandoc/PandocCommandBuilder.ts📚 Learning: 2025-09-25T14:48:20.040Z
Applied to files:
src/core/settings.ts🧬 Code graph analysis (14)
tests/TempDirectoryManager.test.ts (2)
src/converters/pandoc/PandocExecutor.ts (2)
src/core/ModalSettingsHelper.ts (1)
tests/paperSizeMapper.test.ts (1)
src/plugin/EmbedProcessor.ts (3)
vitest.config.ts (1)
tests/basicCoverage.test.ts (2)
tests/TypstVariableMapper.test.ts (3)
src/converters/MarkdownPreprocessor.ts (2)
src/converters/PdfToImageConverter.ts (2)
src/converters/pandoc/PandocCommandBuilder.ts (4)
src/core/PathUtils.ts (1)
src/core/TempDirectoryManager.ts (2)
src/core/ExportErrorHandler.ts (1)
🔇 Additional comments (6)
@@ -9,6 +9,8 @@ import type { PreprocessingResult } from '../converters/MarkdownPreprocessor';import { ExportErrorHandler } from '../core/ExportErrorHandler';⚠️ Potential issue | 🟠 Major
Fix protocol selection for HTTPS URLs.
startsWith('https')is case-sensitive, so uppercase schemes likeHTTPS://…will hit the HTTP client. Node’shttp.get('HTTPS://...')throws “Protocol "https:" not supported,” and every such remote download fails. Use the parsed URL’s protocol instead so we always call the right module.🤖 Prompt for AI Agents
✅ Addressed in commits
1aeebedto35a5249Actionable comments posted: 0
🧹 Nitpick comments (1)
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📥 Commits
Reviewing files that changed from the base of the PR and between
4eb52d11c0and35a5249607.📒 Files selected for processing (5)
src/converters/PandocTypstConverter.ts(8 hunks)src/core/ExecutableChecker.ts(7 hunks)src/core/SecurityUtils.ts(4 hunks)src/core/TempDirectoryManager.ts(6 hunks)src/plugin/EmbedProcessor.ts(4 hunks)🧰 Additional context used
📓 Path-based instructions (1)
src/**/*.ts
📄 CodeRabbit inference engine (AGENTS.md)
Files:
src/plugin/EmbedProcessor.tssrc/core/TempDirectoryManager.tssrc/converters/PandocTypstConverter.tssrc/core/ExecutableChecker.tssrc/core/SecurityUtils.ts🧠 Learnings (2)
📚 Learning: 2025-09-25T14:27:31.837Z
Applied to files:
src/plugin/EmbedProcessor.tssrc/core/TempDirectoryManager.tssrc/core/ExecutableChecker.ts📚 Learning: 2025-09-25T14:14:57.437Z
Applied to files:
src/plugin/EmbedProcessor.ts🧬 Code graph analysis (4)
src/plugin/EmbedProcessor.ts (3)
src/core/TempDirectoryManager.ts (2)
src/converters/PandocTypstConverter.ts (2)
src/core/ExecutableChecker.ts (1)
🔇 Additional comments (3)