Merge branch 'master' into develop

This commit is contained in:
AlexKucera committed 2025-09-10 17:47:52 +02:00
commit 80fecbfab2
22 files changed
+446 -130

No files matched your search

+60 -42
View File
@@ -1,50 +1,68 @@
import { defineConfig, globalIgnores } from "eslint/config"; // @ts-check
import typescriptEslint from "@typescript-eslint/eslint-plugin";
import globals from "globals";
import tsParser from "@typescript-eslint/parser";
import path from "node:path";
import { fileURLToPath } from "node:url";
import js from "@eslint/js";
import { FlatCompat } from "@eslint/eslintrc";
const __filename = fileURLToPath(import.meta.url); import eslint from '@eslint/js';
const __dirname = path.dirname(__filename); import globals from 'globals';
const compat = new FlatCompat({ import tseslint from 'typescript-eslint';
baseDirectory: __dirname,
recommendedConfig: js.configs.recommended,
allConfig: js.configs.all
});
export default defineConfig([globalIgnores(["**/node_modules/", "**/main.js"]), { export default tseslint.config(
extends: compat.extends( // Apply ESLint recommended rules
"eslint:recommended", eslint.configs.recommended,
"plugin:@typescript-eslint/eslint-recommended", // Apply TypeScript-ESLint recommended rules
"plugin:@typescript-eslint/recommended", ...tseslint.configs.recommended,
), {
// Configure language options
languageOptions: {
globals: {
...globals.node,
...globals.es2022,
},
parserOptions: {
sourceType: 'module',
ecmaVersion: 2022,
},
},
plugins: { // Configure files to lint
"@typescript-eslint": typescriptEslint, files: ['**/*.ts', '**/*.js', 'main.ts'],
},
languageOptions: { // Configure rules - incorporating Obsidian sample plugin settings
globals: { rules: {
...globals.node, // Disable base ESLint no-unused-vars in favor of TypeScript version
}, 'no-unused-vars': 'off',
'@typescript-eslint/no-unused-vars': ['warn', { args: 'none', varsIgnorePattern: '^_', argsIgnorePattern: '^_' }],
parser: tsParser, // Allow @ts-ignore comments (useful for Obsidian API quirks)
ecmaVersion: 5, '@typescript-eslint/ban-ts-comment': 'off',
sourceType: "module",
},
rules: { // Allow prototype builtins usage
"no-unused-vars": "off", 'no-prototype-builtins': 'off',
"@typescript-eslint/no-unused-vars": ["error", { // Allow empty functions (common in plugin architecture)
args: "none", '@typescript-eslint/no-empty-function': 'off',
}],
"@typescript-eslint/ban-ts-comment": "off", // Allow require() imports (Node.js environment with mixed modules)
"no-prototype-builtins": "off", '@typescript-eslint/no-require-imports': 'off',
"@typescript-eslint/no-empty-function": "off", '@typescript-eslint/no-var-requires': 'off',
},
}]); // Obsidian plugins often use 'any' type for API flexibility
'@typescript-eslint/no-explicit-any': 'warn',
// Allow lexical declarations in case blocks
'no-case-declarations': 'off',
// Prefer const is good but not critical for existing code
'prefer-const': 'warn',
},
},
{
// Global ignores configuration
ignores: [
'node_modules/**',
'main.js',
'dist/**',
'build/**',
'*.min.js',
'coverage/**',
],
}
);
-6
View File
@@ -4,21 +4,17 @@
*/ */
import { import {
App,
addIcon, addIcon,
Plugin, Plugin,
TFile, TFile,
TFolder,
TAbstractFile, TAbstractFile,
Notice, Notice,
Menu,
MarkdownView MarkdownView
} from 'obsidian'; } from 'obsidian';
import { obsidianTypstPDFExportSettings, DEFAULT_SETTINGS } from './src/core/settings'; import { obsidianTypstPDFExportSettings, DEFAULT_SETTINGS } from './src/core/settings';
import { DependencyChecker } from './src/core/DependencyChecker'; import { DependencyChecker } from './src/core/DependencyChecker';
import type { PreprocessingResult } from './src/converters/MarkdownPreprocessor'; import type { PreprocessingResult } from './src/converters/MarkdownPreprocessor';
import { ExportErrorHandler } from './src/core/ExportErrorHandler';
import { PandocTypstConverter } from './src/converters/PandocTypstConverter'; import { PandocTypstConverter } from './src/converters/PandocTypstConverter';
import { TemplateManager } from './src/templates/TemplateManager'; import { TemplateManager } from './src/templates/TemplateManager';
import { EmbeddedTemplateManager } from './src/templates/embeddedTemplates'; import { EmbeddedTemplateManager } from './src/templates/embeddedTemplates';
@@ -30,8 +26,6 @@ import { FontManager } from './src/plugin/FontManager';
import { PathResolver } from './src/plugin/PathResolver'; import { PathResolver } from './src/plugin/PathResolver';
import { ObsidianTypstPDFExportSettingTab } from './src/plugin/SettingsTab'; import { ObsidianTypstPDFExportSettingTab } from './src/plugin/SettingsTab';
import { EmbedProcessor } from './src/plugin/EmbedProcessor'; import { EmbedProcessor } from './src/plugin/EmbedProcessor';
import * as path from 'path';
import * as fs from 'fs';
export class obsidianTypstPDFExport extends Plugin { export class obsidianTypstPDFExport extends Plugin {
settings: obsidianTypstPDFExportSettings; settings: obsidianTypstPDFExportSettings;
+332 -13
View File
@@ -1,12 +1,12 @@
{ {
"name": "obsidian-typst-pdf-export", "name": "obsidian-typst-pdf-export",
"version": "1.1.0", "version": "1.2.0",
"lockfileVersion": 3, "lockfileVersion": 3,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "obsidian-typst-pdf-export", "name": "obsidian-typst-pdf-export",
"version": "1.1.0", "version": "1.2.0",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"gray-matter": "^4.0.3", "gray-matter": "^4.0.3",
@@ -24,7 +24,8 @@
"globals": "^16.3.0", "globals": "^16.3.0",
"obsidian": "latest", "obsidian": "latest",
"tslib": "2.4.0", "tslib": "2.4.0",
"typescript": "4.7.4" "typescript": "^5.9.2",
"typescript-eslint": "^8.43.0"
} }
}, },
"node_modules/@codemirror/state": { "node_modules/@codemirror/state": {
@@ -432,7 +433,6 @@
"integrity": "sha512-dyybb3AcajC7uha6CvhdVRJqaKyn7w2YKqKyAN37NKYgZT36w+iRb0Dymmc5qEJ549c/S31cMMSFd75bteCpCw==", "integrity": "sha512-dyybb3AcajC7uha6CvhdVRJqaKyn7w2YKqKyAN37NKYgZT36w+iRb0Dymmc5qEJ549c/S31cMMSFd75bteCpCw==",
"dev": true, "dev": true,
"license": "MIT", "license": "MIT",
"peer": true,
"dependencies": { "dependencies": {
"eslint-visitor-keys": "^3.4.3" "eslint-visitor-keys": "^3.4.3"
}, },
@@ -452,7 +452,6 @@
"integrity": "sha512-CCZCDJuduB9OUkFkY2IgppNZMi2lBQgD2qzwXkEia16cge2pijY/aXi96CJMquDMn3nJdlPV1A5KrJEXwfLNzQ==", "integrity": "sha512-CCZCDJuduB9OUkFkY2IgppNZMi2lBQgD2qzwXkEia16cge2pijY/aXi96CJMquDMn3nJdlPV1A5KrJEXwfLNzQ==",
"dev": true, "dev": true,
"license": "MIT", "license": "MIT",
"peer": true,
"engines": { "engines": {
"node": "^12.0.0 || ^14.0.0 || >=16.0.0" "node": "^12.0.0 || ^14.0.0 || >=16.0.0"
} }
@@ -832,6 +831,42 @@
} }
} }
}, },
"node_modules/@typescript-eslint/project-service": {
"version": "8.43.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/project-service/-/project-service-8.43.0.tgz",
"integrity": "sha512-htB/+D/BIGoNTQYffZw4uM4NzzuolCoaA/BusuSIcC8YjmBYQioew5VUZAYdAETPjeed0hqCaW7EHg+Robq8uw==",
"dev": true,
"license": "MIT",
"dependencies": {
"@typescript-eslint/tsconfig-utils": "^8.43.0",
"@typescript-eslint/types": "^8.43.0",
"debug": "^4.3.4"
},
"engines": {
"node": "^18.18.0 || ^20.9.0 || >=21.1.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/typescript-eslint"
},
"peerDependencies": {
"typescript": ">=4.8.4 <6.0.0"
}
},
"node_modules/@typescript-eslint/project-service/node_modules/@typescript-eslint/types": {
"version": "8.43.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-8.43.0.tgz",
"integrity": "sha512-vQ2FZaxJpydjSZJKiSW/LJsabFFvV7KgLC5DiLhkBcykhQj8iK9BOaDmQt74nnKdLvceM5xmhaTF+pLekrxEkw==",
"dev": true,
"license": "MIT",
"engines": {
"node": "^18.18.0 || ^20.9.0 || >=21.1.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/typescript-eslint"
}
},
"node_modules/@typescript-eslint/scope-manager": { "node_modules/@typescript-eslint/scope-manager": {
"version": "5.29.0", "version": "5.29.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-5.29.0.tgz", "resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-5.29.0.tgz",
@@ -850,6 +885,23 @@
"url": "https://opencollective.com/typescript-eslint" "url": "https://opencollective.com/typescript-eslint"
} }
}, },
"node_modules/@typescript-eslint/tsconfig-utils": {
"version": "8.43.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/tsconfig-utils/-/tsconfig-utils-8.43.0.tgz",
"integrity": "sha512-ALC2prjZcj2YqqL5X/bwWQmHA2em6/94GcbB/KKu5SX3EBDOsqztmmX1kMkvAJHzxk7TazKzJfFiEIagNV3qEA==",
"dev": true,
"license": "MIT",
"engines": {
"node": "^18.18.0 || ^20.9.0 || >=21.1.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/typescript-eslint"
},
"peerDependencies": {
"typescript": ">=4.8.4 <6.0.0"
}
},
"node_modules/@typescript-eslint/type-utils": { "node_modules/@typescript-eslint/type-utils": {
"version": "5.29.0", "version": "5.29.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-5.29.0.tgz", "resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-5.29.0.tgz",
@@ -2510,8 +2562,7 @@
"resolved": "https://registry.npmjs.org/graphemer/-/graphemer-1.4.0.tgz", "resolved": "https://registry.npmjs.org/graphemer/-/graphemer-1.4.0.tgz",
"integrity": "sha512-EtKwoO6kxCL9WO5xipiHTZlSzBm7WLT627TqC/uVRd0HKmq8NXyebnNYxDoBi7wt8eTWrUrKXCOVaFq9x1kgag==", "integrity": "sha512-EtKwoO6kxCL9WO5xipiHTZlSzBm7WLT627TqC/uVRd0HKmq8NXyebnNYxDoBi7wt8eTWrUrKXCOVaFq9x1kgag==",
"dev": true, "dev": true,
"license": "MIT", "license": "MIT"
"peer": true
}, },
"node_modules/gray-matter": { "node_modules/gray-matter": {
"version": "4.0.3", "version": "4.0.3",
@@ -3101,8 +3152,7 @@
"resolved": "https://registry.npmjs.org/natural-compare/-/natural-compare-1.4.0.tgz", "resolved": "https://registry.npmjs.org/natural-compare/-/natural-compare-1.4.0.tgz",
"integrity": "sha512-OWND8ei3VtNC9h7V60qff3SVobHr996CTwgxubgyQYEpg290h9J0buyECNNJexkFm5sOajh5G116RYA1c8ZMSw==", "integrity": "sha512-OWND8ei3VtNC9h7V60qff3SVobHr996CTwgxubgyQYEpg290h9J0buyECNNJexkFm5sOajh5G116RYA1c8ZMSw==",
"dev": true, "dev": true,
"license": "MIT", "license": "MIT"
"peer": true
}, },
"node_modules/node-abi": { "node_modules/node-abi": {
"version": "3.75.0", "version": "3.75.0",
@@ -4057,6 +4107,19 @@
"license": "MIT", "license": "MIT",
"optional": true "optional": true
}, },
"node_modules/ts-api-utils": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/ts-api-utils/-/ts-api-utils-2.1.0.tgz",
"integrity": "sha512-CUgTZL1irw8u29bzrOD/nH85jqyc74D6SshFgujOIA7osm2Rz7dYH77agkx7H4FBNxDq7Cjf+IjaX/8zwFW+ZQ==",
"dev": true,
"license": "MIT",
"engines": {
"node": ">=18.12"
},
"peerDependencies": {
"typescript": ">=4.8.4"
}
},
"node_modules/tslib": { "node_modules/tslib": {
"version": "2.4.0", "version": "2.4.0",
"resolved": "https://registry.npmjs.org/tslib/-/tslib-2.4.0.tgz", "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.4.0.tgz",
@@ -4128,9 +4191,9 @@
} }
}, },
"node_modules/typescript": { "node_modules/typescript": {
"version": "4.7.4", "version": "5.9.2",
"resolved": "https://registry.npmjs.org/typescript/-/typescript-4.7.4.tgz", "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.9.2.tgz",
"integrity": "sha512-C0WQT0gezHuw6AdY1M2jxUO83Rjf0HP7Sk1DtXj6j1EwkQNZrHAg2XPWlq62oqEhYvONq5pkC2Y9oPljWToLmQ==", "integrity": "sha512-CWBzXQrc/qOkhidw1OzBTQuYRbfyxDXJMVJ1XNwUHGROVmuaeiEm3OslpZ1RV96d7SKKjZKrSJu3+t/xlw3R9A==",
"dev": true, "dev": true,
"license": "Apache-2.0", "license": "Apache-2.0",
"bin": { "bin": {
@@ -4138,7 +4201,263 @@
"tsserver": "bin/tsserver" "tsserver": "bin/tsserver"
}, },
"engines": { "engines": {
"node": ">=4.2.0" "node": ">=14.17"
}
},
"node_modules/typescript-eslint": {
"version": "8.43.0",
"resolved": "https://registry.npmjs.org/typescript-eslint/-/typescript-eslint-8.43.0.tgz",
"integrity": "sha512-FyRGJKUGvcFekRRcBKFBlAhnp4Ng8rhe8tuvvkR9OiU0gfd4vyvTRQHEckO6VDlH57jbeUQem2IpqPq9kLJH+w==",
"dev": true,
"license": "MIT",
"dependencies": {
"@typescript-eslint/eslint-plugin": "8.43.0",
"@typescript-eslint/parser": "8.43.0",
"@typescript-eslint/typescript-estree": "8.43.0",
"@typescript-eslint/utils": "8.43.0"
},
"engines": {
"node": "^18.18.0 || ^20.9.0 || >=21.1.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/typescript-eslint"
},
"peerDependencies": {
"eslint": "^8.57.0 || ^9.0.0",
"typescript": ">=4.8.4 <6.0.0"
}
},
"node_modules/typescript-eslint/node_modules/@typescript-eslint/eslint-plugin": {
"version": "8.43.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-8.43.0.tgz",
"integrity": "sha512-8tg+gt7ENL7KewsKMKDHXR1vm8tt9eMxjJBYINf6swonlWgkYn5NwyIgXpbbDxTNU5DgpDFfj95prcTq2clIQQ==",
"dev": true,
"license": "MIT",
"dependencies": {
"@eslint-community/regexpp": "^4.10.0",
"@typescript-eslint/scope-manager": "8.43.0",
"@typescript-eslint/type-utils": "8.43.0",
"@typescript-eslint/utils": "8.43.0",
"@typescript-eslint/visitor-keys": "8.43.0",
"graphemer": "^1.4.0",
"ignore": "^7.0.0",
"natural-compare": "^1.4.0",
"ts-api-utils": "^2.1.0"
},
"engines": {
"node": "^18.18.0 || ^20.9.0 || >=21.1.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/typescript-eslint"
},
"peerDependencies": {
"@typescript-eslint/parser": "^8.43.0",
"eslint": "^8.57.0 || ^9.0.0",
"typescript": ">=4.8.4 <6.0.0"
}
},
"node_modules/typescript-eslint/node_modules/@typescript-eslint/parser": {
"version": "8.43.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-8.43.0.tgz",
"integrity": "sha512-B7RIQiTsCBBmY+yW4+ILd6mF5h1FUwJsVvpqkrgpszYifetQ2Ke+Z4u6aZh0CblkUGIdR59iYVyXqqZGkZ3aBw==",
"dev": true,
"license": "MIT",
"dependencies": {
"@typescript-eslint/scope-manager": "8.43.0",
"@typescript-eslint/types": "8.43.0",
"@typescript-eslint/typescript-estree": "8.43.0",
"@typescript-eslint/visitor-keys": "8.43.0",
"debug": "^4.3.4"
},
"engines": {
"node": "^18.18.0 || ^20.9.0 || >=21.1.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/typescript-eslint"
},
"peerDependencies": {
"eslint": "^8.57.0 || ^9.0.0",
"typescript": ">=4.8.4 <6.0.0"
}
},
"node_modules/typescript-eslint/node_modules/@typescript-eslint/scope-manager": {
"version": "8.43.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/scope-manager/-/scope-manager-8.43.0.tgz",
"integrity": "sha512-daSWlQ87ZhsjrbMLvpuuMAt3y4ba57AuvadcR7f3nl8eS3BjRc8L9VLxFLk92RL5xdXOg6IQ+qKjjqNEimGuAg==",
"dev": true,
"license": "MIT",
"dependencies": {
"@typescript-eslint/types": "8.43.0",
"@typescript-eslint/visitor-keys": "8.43.0"
},
"engines": {
"node": "^18.18.0 || ^20.9.0 || >=21.1.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/typescript-eslint"
}
},
"node_modules/typescript-eslint/node_modules/@typescript-eslint/type-utils": {
"version": "8.43.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/type-utils/-/type-utils-8.43.0.tgz",
"integrity": "sha512-qaH1uLBpBuBBuRf8c1mLJ6swOfzCXryhKND04Igr4pckzSEW9JX5Aw9AgW00kwfjWJF0kk0ps9ExKTfvXfw4Qg==",
"dev": true,
"license": "MIT",
"dependencies": {
"@typescript-eslint/types": "8.43.0",
"@typescript-eslint/typescript-estree": "8.43.0",
"@typescript-eslint/utils": "8.43.0",
"debug": "^4.3.4",
"ts-api-utils": "^2.1.0"
},
"engines": {
"node": "^18.18.0 || ^20.9.0 || >=21.1.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/typescript-eslint"
},
"peerDependencies": {
"eslint": "^8.57.0 || ^9.0.0",
"typescript": ">=4.8.4 <6.0.0"
}
},
"node_modules/typescript-eslint/node_modules/@typescript-eslint/types": {
"version": "8.43.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-8.43.0.tgz",
"integrity": "sha512-vQ2FZaxJpydjSZJKiSW/LJsabFFvV7KgLC5DiLhkBcykhQj8iK9BOaDmQt74nnKdLvceM5xmhaTF+pLekrxEkw==",
"dev": true,
"license": "MIT",
"engines": {
"node": "^18.18.0 || ^20.9.0 || >=21.1.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/typescript-eslint"
}
},
"node_modules/typescript-eslint/node_modules/@typescript-eslint/typescript-estree": {
"version": "8.43.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/typescript-estree/-/typescript-estree-8.43.0.tgz",
"integrity": "sha512-7Vv6zlAhPb+cvEpP06WXXy/ZByph9iL6BQRBDj4kmBsW98AqEeQHlj/13X+sZOrKSo9/rNKH4Ul4f6EICREFdw==",
"dev": true,
"license": "MIT",
"dependencies": {
"@typescript-eslint/project-service": "8.43.0",
"@typescript-eslint/tsconfig-utils": "8.43.0",
"@typescript-eslint/types": "8.43.0",
"@typescript-eslint/visitor-keys": "8.43.0",
"debug": "^4.3.4",
"fast-glob": "^3.3.2",
"is-glob": "^4.0.3",
"minimatch": "^9.0.4",
"semver": "^7.6.0",
"ts-api-utils": "^2.1.0"
},
"engines": {
"node": "^18.18.0 || ^20.9.0 || >=21.1.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/typescript-eslint"
},
"peerDependencies": {
"typescript": ">=4.8.4 <6.0.0"
}
},
"node_modules/typescript-eslint/node_modules/@typescript-eslint/utils": {
"version": "8.43.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-8.43.0.tgz",
"integrity": "sha512-S1/tEmkUeeswxd0GGcnwuVQPFWo8NzZTOMxCvw8BX7OMxnNae+i8Tm7REQen/SwUIPoPqfKn7EaZ+YLpiB3k9g==",
"dev": true,
"license": "MIT",
"dependencies": {
"@eslint-community/eslint-utils": "^4.7.0",
"@typescript-eslint/scope-manager": "8.43.0",
"@typescript-eslint/types": "8.43.0",
"@typescript-eslint/typescript-estree": "8.43.0"
},
"engines": {
"node": "^18.18.0 || ^20.9.0 || >=21.1.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/typescript-eslint"
},
"peerDependencies": {
"eslint": "^8.57.0 || ^9.0.0",
"typescript": ">=4.8.4 <6.0.0"
}
},
"node_modules/typescript-eslint/node_modules/@typescript-eslint/visitor-keys": {
"version": "8.43.0",
"resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-8.43.0.tgz",
"integrity": "sha512-T+S1KqRD4sg/bHfLwrpF/K3gQLBM1n7Rp7OjjikjTEssI2YJzQpi5WXoynOaQ93ERIuq3O8RBTOUYDKszUCEHw==",
"dev": true,
"license": "MIT",
"dependencies": {
"@typescript-eslint/types": "8.43.0",
"eslint-visitor-keys": "^4.2.1"
},
"engines": {
"node": "^18.18.0 || ^20.9.0 || >=21.1.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/typescript-eslint"
}
},
"node_modules/typescript-eslint/node_modules/brace-expansion": {
"version": "2.0.2",
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.2.tgz",
"integrity": "sha512-Jt0vHyM+jmUBqojB7E1NIYadt0vI0Qxjxd2TErW94wDz+E2LAm5vKMXXwg6ZZBTHPuUlDgQHKXvjGBdfcF1ZDQ==",
"dev": true,
"license": "MIT",
"dependencies": {
"balanced-match": "^1.0.0"
}
},
"node_modules/typescript-eslint/node_modules/eslint-visitor-keys": {
"version": "4.2.1",
"resolved": "https://registry.npmjs.org/eslint-visitor-keys/-/eslint-visitor-keys-4.2.1.tgz",
"integrity": "sha512-Uhdk5sfqcee/9H/rCOJikYz67o0a2Tw2hGRPOG2Y1R2dg7brRe1uG0yaNQDHu+TO/uQPF/5eCapvYSmHUjt7JQ==",
"dev": true,
"license": "Apache-2.0",
"engines": {
"node": "^18.18.0 || ^20.9.0 || >=21.1.0"
},
"funding": {
"url": "https://opencollective.com/eslint"
}
},
"node_modules/typescript-eslint/node_modules/ignore": {
"version": "7.0.5",
"resolved": "https://registry.npmjs.org/ignore/-/ignore-7.0.5.tgz",
"integrity": "sha512-Hs59xBNfUIunMFgWAbGX5cq6893IbWg4KnrjbYwX3tx0ztorVgTDA6B2sxf8ejHJ4wz8BqGUMYlnzNBer5NvGg==",
"dev": true,
"license": "MIT",
"engines": {
"node": ">= 4"
}
},
"node_modules/typescript-eslint/node_modules/minimatch": {
"version": "9.0.5",
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.5.tgz",
"integrity": "sha512-G6T0ZX48xgozx7587koeX9Ys2NYy6Gmv//P89sEte9V9whIapMNF4idKxnW2QtCcLiTWlb/wfCabAtAFWhhBow==",
"dev": true,
"license": "ISC",
"dependencies": {
"brace-expansion": "^2.0.1"
},
"engines": {
"node": ">=16 || 14 >=14.17"
},
"funding": {
"url": "https://github.com/sponsors/isaacs"
} }
}, },
"node_modules/uri-js": { "node_modules/uri-js": {
+6 -3
View File
@@ -4,8 +4,10 @@
"description": "Exports a note or collection of notes to a pretty Typst PDF.", "description": "Exports a note or collection of notes to a pretty Typst PDF.",
"main": "main.js", "main": "main.js",
"scripts": { "scripts": {
"dev": "node esbuild.config.mjs", "typecheck": "tsc --noEmit",
"build": "tsc -noEmit -skipLibCheck && node esbuild.config.mjs production", "lint": "eslint src/ main.ts",
"dev": "npm run typecheck && node esbuild.config.mjs",
"build": "npm run typecheck && npm run lint && node esbuild.config.mjs production",
"package": "node scripts/package-plugin.js", "package": "node scripts/package-plugin.js",
"version": "node version-bump.mjs && git add manifest.json versions.json" "version": "node version-bump.mjs && git add manifest.json versions.json"
}, },
@@ -30,7 +32,8 @@
"globals": "^16.3.0", "globals": "^16.3.0",
"obsidian": "latest", "obsidian": "latest",
"tslib": "2.4.0", "tslib": "2.4.0",
"typescript": "4.7.4" "typescript": "^5.9.2",
"typescript-eslint": "^8.43.0"
}, },
"dependencies": { "dependencies": {
"gray-matter": "^4.0.3", "gray-matter": "^4.0.3",
-3
View File
@@ -3,13 +3,10 @@
* Handles the conversion of Markdown to PDF using Pandoc with Typst engine * Handles the conversion of Markdown to PDF using Pandoc with Typst engine
*/ */
import * as fs from 'fs';
import { promises as fsPromises } from 'fs'; import { promises as fsPromises } from 'fs';
import * as path from 'path'; import * as path from 'path';
import * as os from 'os'; import * as os from 'os';
import { mapToTypstPaperSize } from '../utils/paperSizeMapper';
import { PandocOptions, TypstSettings, ConversionResult, ProgressCallback } from './converterTypes'; import { PandocOptions, TypstSettings, ConversionResult, ProgressCallback } from './converterTypes';
import type { obsidianTypstPDFExportSettings } from '../core/settings';
import type { obsidianTypstPDFExport } from '../../main'; import type { obsidianTypstPDFExport } from '../../main';
import { TempDirectoryManager } from '../core/TempDirectoryManager'; import { TempDirectoryManager } from '../core/TempDirectoryManager';
@@ -110,7 +110,7 @@ export class ResourcePathResolver {
if (hasImages) { if (hasImages) {
foundResourcePaths.push(itemPath); foundResourcePaths.push(itemPath);
} }
} catch (e) { } catch {
// Ignore directories we can't read // Ignore directories we can't read
} }
} }
+1 -3
View File
@@ -26,15 +26,13 @@ export class BinaryLocator {
try { try {
// Get the plugin directory - need to handle Obsidian's environment // Get the plugin directory - need to handle Obsidian's environment
// In Obsidian, __dirname points to electron.asar, so we need to find the actual plugin path // In Obsidian, __dirname points to electron.asar, so we need to find the actual plugin path
let pluginDir: string;
// Try multiple strategies to find the plugin directory // Try multiple strategies to find the plugin directory
const pluginDirName = plugin?.manifest?.dir || 'typst-pdf-export'; const pluginDirName = plugin?.manifest?.dir || 'typst-pdf-export';
const configDir = plugin?.app.vault.configDir || '.obsidian'; const configDir = plugin?.app.vault.configDir || '.obsidian';
const possiblePluginDirs = this.getPossiblePluginDirs(plugin, pluginDirName, configDir); const possiblePluginDirs = this.getPossiblePluginDirs(plugin, pluginDirName, configDir);
// Find the first directory that exists and has node_modules // Find the first directory that exists and has node_modules
pluginDir = possiblePluginDirs.find(dir => { const pluginDir = possiblePluginDirs.find(dir => {
try { try {
const nodeModulesPath = path.join(dir, 'node_modules'); const nodeModulesPath = path.join(dir, 'node_modules');
return require('fs').existsSync(nodeModulesPath); return require('fs').existsSync(nodeModulesPath);
+2 -2
View File
@@ -36,7 +36,7 @@ export class FileDiscovery {
filePath: expectedOutputPath, filePath: expectedOutputPath,
found: true found: true
}; };
} catch (error) { } catch {
// File not found with expected name, try to find alternatives // File not found with expected name, try to find alternatives
return await this.findAlternativeFile(outputDir, expectedFileName, expectedOutputPath); return await this.findAlternativeFile(outputDir, expectedFileName, expectedOutputPath);
} }
@@ -82,7 +82,7 @@ export class FileDiscovery {
filePath: actualOutputPath, filePath: actualOutputPath,
found: true found: true
}; };
} catch (finalError) { } catch {
return { return {
filePath: '', filePath: '',
found: false, found: false,
+2 -2
View File
@@ -29,7 +29,7 @@ export class PdfProcessor {
// Check PDF signature - all valid PDFs must start with %PDF // Check PDF signature - all valid PDFs must start with %PDF
const signature = buffer.subarray(0, 4).toString(); const signature = buffer.subarray(0, 4).toString();
return signature === '%PDF'; return signature === '%PDF';
} catch (error) { } catch {
return false; return false;
} }
} }
@@ -83,7 +83,7 @@ export class PdfProcessor {
try { try {
await fs.access(filePath); await fs.access(filePath);
return { success: true }; return { success: true };
} catch (error: unknown) { } catch {
return { return {
success: false, success: false,
error: `PDF file not found: ${filePath}` error: `PDF file not found: ${filePath}`
@@ -324,7 +324,7 @@ export class CalloutProcessor {
if (!text) return ''; if (!text) return '';
// First, clean up problematic Unicode characters // First, clean up problematic Unicode characters
let cleaned = text const cleaned = text
// Replace various Unicode spaces with regular spaces // Replace various Unicode spaces with regular spaces
.replace(/[\u00A0\u1680\u2000-\u200B\u202F\u205F\u3000\uFEFF]/g, ' ') .replace(/[\u00A0\u1680\u2000-\u200B\u202F\u205F\u3000\uFEFF]/g, ' ')
// Replace Unicode line separators with regular newlines // Replace Unicode line separators with regular newlines
@@ -55,7 +55,7 @@ export class EmbedProcessor {
private wikilinkProcessor: WikilinkProcessor; private wikilinkProcessor: WikilinkProcessor;
// Regex patterns for embed matching // Regex patterns for embed matching
private readonly EMBED_PATTERN = /!\[\[([^\|\]]+)(?:\|([^\]]+))?\]\]/g; private readonly EMBED_PATTERN = /!\[\[([^|\]]+)(?:\|([^\]]+))?\]\]/g;
private readonly EMBED_SIZE_PATTERN = /(\d+)(?:x(\d+))?/; private readonly EMBED_SIZE_PATTERN = /(\d+)(?:x(\d+))?/;
constructor(config: EmbedProcessorConfig) { constructor(config: EmbedProcessorConfig) {
@@ -62,7 +62,7 @@ export class WikilinkProcessor {
private baseUrl?: string; private baseUrl?: string;
// Regex pattern for comprehensive wikilink matching with headings // Regex pattern for comprehensive wikilink matching with headings
private readonly WIKILINK_WITH_HEADING_PATTERN = /\[\[([^#\|\]]+)(?:#([^|\]]+))?(?:\|([^\]]+))?\]\]/g; private readonly WIKILINK_WITH_HEADING_PATTERN = /\[\[([^#|\]]+)(?:#([^|\]]+))?(?:\|([^\]]+))?\]\]/g;
constructor(config: WikilinkProcessorConfig) { constructor(config: WikilinkProcessorConfig) {
this.wikilinkConfig = config.wikilinkConfig; this.wikilinkConfig = config.wikilinkConfig;
@@ -137,7 +137,7 @@ export class WikilinkProcessor {
return filePath return filePath
.replace(/[<>:"|?*]/g, '_') // Replace problematic characters .replace(/[<>:"|?*]/g, '_') // Replace problematic characters
.replace(/\s+/g, '%20') // URL encode spaces .replace(/\s+/g, '%20') // URL encode spaces
.replace(/[\\\/]/g, '/'); // Normalize path separators .replace(/[\\]/g, '/'); // Normalize path separators
} }
/** /**
@@ -147,7 +147,7 @@ export class WikilinkProcessor {
return heading return heading
.toLowerCase() .toLowerCase()
.replace(/\s+/g, '-') // Replace spaces with dashes .replace(/\s+/g, '-') // Replace spaces with dashes
.replace(/[^\w\-]/g, '') // Remove special characters except dashes .replace(/[^\w-]/g, '') // Remove special characters except dashes
.replace(/--+/g, '-'); // Collapse multiple dashes .replace(/--+/g, '-'); // Collapse multiple dashes
} }
+2 -2
View File
@@ -85,7 +85,7 @@ export class ExecutableChecker {
const foundPath = stdout.trim(); const foundPath = stdout.trim();
return foundPath || null; return foundPath || null;
} catch (error) { } catch {
return null; return null;
} }
} }
@@ -198,7 +198,7 @@ export class ExecutableChecker {
isAvailable: true, isAvailable: true,
executablePath executablePath
}; };
} catch (error) { } catch {
return { return {
name, name,
version: null, version: null,
+2 -1
View File
@@ -53,6 +53,7 @@ export class SecurityUtils {
// Check for command injection attempts // Check for command injection attempts
const dangerousPatterns = [ const dangerousPatterns = [
/[;&|`$(){}[\]]/, // Shell metacharacters /[;&|`$(){}[\]]/, // Shell metacharacters
// eslint-disable-next-line no-control-regex
/\x00/, // Null bytes /\x00/, // Null bytes
/\n|\r/, // Newlines /\n|\r/, // Newlines
/\s*[;&|]\s*/, // Command separators with whitespace /\s*[;&|]\s*/, // Command separators with whitespace
@@ -113,7 +114,7 @@ export class SecurityUtils {
if (/[;&|`$(){}[\]]/.test(normalizedPath)) { if (/[;&|`$(){}[\]]/.test(normalizedPath)) {
return 'Shell metacharacters are not allowed in executable paths'; return 'Shell metacharacters are not allowed in executable paths';
} }
if (/\x00/.test(normalizedPath)) { if (/\x00/.test(normalizedPath)) { // eslint-disable-line no-control-regex
return 'Null bytes are not allowed in paths'; return 'Null bytes are not allowed in paths';
} }
if (/\n|\r/.test(normalizedPath)) { if (/\n|\r/.test(normalizedPath)) {
+6 -1
View File
@@ -25,6 +25,9 @@ export interface obsidianTypstPDFExportSettings {
additionalPaths: string[]; additionalPaths: string[];
}; };
/** Custom environment variables for subprocess execution */
customEnvironmentVariables: { [key: string]: string };
/** Export defaults */ /** Export defaults */
exportDefaults: { exportDefaults: {
/** Default template to use for exports */ /** Default template to use for exports */
@@ -108,6 +111,8 @@ export const DEFAULT_SETTINGS: obsidianTypstPDFExportSettings = {
additionalPaths: ['/opt/homebrew/bin', '/usr/local/bin', '/usr/bin'] additionalPaths: ['/opt/homebrew/bin', '/usr/local/bin', '/usr/bin']
}, },
customEnvironmentVariables: {},
exportDefaults: { exportDefaults: {
template: 'default', template: 'default',
format: ExportFormat.Standard, format: ExportFormat.Standard,
@@ -156,4 +161,4 @@ export const DEFAULT_SETTINGS: obsidianTypstPDFExportSettings = {
embedAllFiles: true, embedAllFiles: true,
printFrontmatter: false printFrontmatter: false
} }
};;;; };
+3 -3
View File
@@ -22,7 +22,7 @@ export class EmbedProcessor {
let updatedContent = processedResult.content; let updatedContent = processedResult.content;
for (const pdfEmbed of processedResult.metadata.pdfEmbeds) { for (const pdfEmbed of processedResult.metadata?.pdfEmbeds || []) {
try { try {
// Resolve PDF path using helper method // Resolve PDF path using helper method
const fullPdfPath = await this.resolvePdfPath(pdfEmbed.sanitizedPath, vaultBasePath, currentFile); const fullPdfPath = await this.resolvePdfPath(pdfEmbed.sanitizedPath, vaultBasePath, currentFile);
@@ -106,7 +106,7 @@ export class EmbedProcessor {
async processImageEmbeds(processedResult: PreprocessingResult, vaultBasePath: string, tempDir: string, currentFile?: TFile): Promise<void> { async processImageEmbeds(processedResult: PreprocessingResult, vaultBasePath: string, tempDir: string, currentFile?: TFile): Promise<void> {
let updatedContent = processedResult.content; let updatedContent = processedResult.content;
for (const imageEmbed of processedResult.metadata.imageEmbeds) { for (const imageEmbed of processedResult.metadata?.imageEmbeds || []) {
try { try {
// Decode the URL-encoded sanitized path back to normal characters // Decode the URL-encoded sanitized path back to normal characters
const decodedPath = decodeURIComponent(imageEmbed.sanitizedPath); const decodedPath = decodeURIComponent(imageEmbed.sanitizedPath);
@@ -232,7 +232,7 @@ export class EmbedProcessor {
async processFileEmbeds(processedResult: PreprocessingResult, vaultBasePath: string, tempDir: string, currentFile?: TFile, embedAllFiles: boolean = true): Promise<void> { async processFileEmbeds(processedResult: PreprocessingResult, vaultBasePath: string, tempDir: string, currentFile?: TFile, embedAllFiles: boolean = true): Promise<void> {
let updatedContent = processedResult.content; let updatedContent = processedResult.content;
for (const fileEmbed of processedResult.metadata.fileEmbeds) { for (const fileEmbed of processedResult.metadata?.fileEmbeds || []) {
try { try {
// Resolve file path using helper method (similar to PDF processing) // Resolve file path using helper method (similar to PDF processing)
const fullFilePath = await this.resolveFilePath(fileEmbed.sanitizedPath, vaultBasePath, currentFile); const fullFilePath = await this.resolveFilePath(fileEmbed.sanitizedPath, vaultBasePath, currentFile);
+1 -1
View File
@@ -81,7 +81,7 @@ export class PluginLifecycle {
try { try {
const vaultPath = (this.plugin.app.vault.adapter as any).basePath; const vaultPath = (this.plugin.app.vault.adapter as any).basePath;
const cleanupManager = TempDirectoryManager.create(vaultPath, this.plugin.app.vault.configDir); const cleanupManager = TempDirectoryManager.create(vaultPath, this.plugin.app.vault.configDir);
const result = cleanupManager.cleanupAllTempDirs(); const _result = cleanupManager.cleanupAllTempDirs();
if (this.plugin.settings.behavior.debugMode) { if (this.plugin.settings.behavior.debugMode) {
// Debug logging was here but empty in original // Debug logging was here but empty in original
+1 -1
View File
@@ -7,12 +7,12 @@ import {
App, App,
PluginSettingTab, PluginSettingTab,
Setting, Setting,
Notice,
normalizePath normalizePath
} from 'obsidian'; } from 'obsidian';
import type { obsidianTypstPDFExport } from '../../main'; import type { obsidianTypstPDFExport } from '../../main';
import { ExportFormat } from '../core/settings'; import { ExportFormat } from '../core/settings';
import { SecurityUtils } from '../core/SecurityUtils'; import { SecurityUtils } from '../core/SecurityUtils';
import { ExportErrorHandler } from '../core/ExportErrorHandler';
import { FolderSuggest } from '../ui/components/FolderSuggest'; import { FolderSuggest } from '../ui/components/FolderSuggest';
import { SUPPORTED_PAPER_SIZES } from '../utils/paperSizeMapper'; import { SUPPORTED_PAPER_SIZES } from '../utils/paperSizeMapper';
+2 -21
View File
@@ -112,27 +112,8 @@ export class ExportConfigModal extends Modal {
} }
private handleReset(): void { private handleReset(): void {
// Create plugin defaults object from settings tab values // Reset state to plugin defaults using the full settings object
const pluginDefaults = { this.state.reset(this.plugin.settings);
template: this.plugin.settings.exportDefaults.template,
format: this.plugin.settings.exportDefaults.format,
outputFolder: this.plugin.settings.outputFolder,
openAfterExport: this.plugin.settings.behavior.openAfterExport,
preserveFolderStructure: this.plugin.settings.behavior.preserveFolderStructure,
pageSize: this.plugin.settings.pageSetup.size,
orientation: this.plugin.settings.pageSetup.orientation,
marginTop: this.plugin.settings.pageSetup.margins.top.toString(),
marginBottom: this.plugin.settings.pageSetup.margins.bottom.toString(),
marginLeft: this.plugin.settings.pageSetup.margins.left.toString(),
marginRight: this.plugin.settings.pageSetup.margins.right.toString(),
bodyFont: this.plugin.settings.typography.fonts.body,
headingFont: this.plugin.settings.typography.fonts.heading,
monospaceFont: this.plugin.settings.typography.fonts.monospace,
bodyFontSize: this.plugin.settings.typography.fontSizes.body
};
// Reset state to plugin defaults
this.state.reset(pluginDefaults);
// Re-render sections to update UI // Re-render sections to update UI
this.renderer.refreshSections(); this.renderer.refreshSections();
+1 -1
View File
@@ -121,7 +121,7 @@ export class ModalRenderer {
this.progressBar = progressBarContainer.createDiv('export-progress-bar'); this.progressBar = progressBarContainer.createDiv('export-progress-bar');
// Progress percentage // Progress percentage
const progressPercent = this.progressContainer.createEl('div', { const _progressPercent = this.progressContainer.createEl('div', {
cls: 'export-progress-percent', cls: 'export-progress-percent',
text: '0%' text: '0%'
}); });
+4 -4
View File
@@ -128,16 +128,16 @@ export class GeneralSection implements ModalSection {
// Filter out universal-wrapper.pandoc.typ and clear/repopulate dropdown // Filter out universal-wrapper.pandoc.typ and clear/repopulate dropdown
const filteredTemplates = templates.filter(template => template !== 'universal-wrapper.pandoc.typ'); const filteredTemplates = templates.filter(template => template !== 'universal-wrapper.pandoc.typ');
this.templateDropdown.selectEl.empty(); this.templateDropdown?.selectEl.empty();
filteredTemplates.forEach(template => { filteredTemplates.forEach(template => {
this.templateDropdown.addOption(template, this.getTemplateDisplayName(template)); this.templateDropdown?.addOption(template, this.getTemplateDisplayName(template));
}); });
// Restore selection if still available // Restore selection if still available
if (filteredTemplates.includes(currentValue)) { if (filteredTemplates.includes(currentValue)) {
this.templateDropdown.setValue(currentValue); this.templateDropdown?.setValue(currentValue);
} else if (filteredTemplates.length > 0) { } else if (filteredTemplates.length > 0) {
this.templateDropdown.setValue(filteredTemplates[0]); this.templateDropdown?.setValue(filteredTemplates[0]);
} }
} }
+15 -15
View File
@@ -142,30 +142,30 @@ export class ModalState implements IModalState {
// Reset to plugin defaults, not hardcoded defaults // Reset to plugin defaults, not hardcoded defaults
this.settings = { this.settings = {
...this.settings, ...this.settings,
template: pluginDefaults.template, template: pluginDefaults.exportDefaults.template,
format: pluginDefaults.format, format: pluginDefaults.exportDefaults.format,
outputFolder: pluginDefaults.outputFolder || 'exports', outputFolder: pluginDefaults.outputFolder || 'exports',
templateVariables: {}, templateVariables: {},
progressPercent: 0, progressPercent: 0,
currentOperation: '', currentOperation: '',
isExporting: false, isExporting: false,
canCancel: false, canCancel: false,
openAfterExport: pluginDefaults.openAfterExport || false, openAfterExport: pluginDefaults.behavior.openAfterExport || false,
preserveFolderStructure: pluginDefaults.preserveFolderStructure || false preserveFolderStructure: pluginDefaults.behavior.preserveFolderStructure || false
}; };
this.templateVariables = { this.templateVariables = {
pageSize: pluginDefaults.pageSize, pageSize: pluginDefaults.exportDefaults.pageSize,
orientation: pluginDefaults.orientation, orientation: pluginDefaults.exportDefaults.orientation,
flipped: pluginDefaults.orientation === 'landscape', flipped: pluginDefaults.exportDefaults.orientation === 'landscape',
marginTop: pluginDefaults.marginTop, marginTop: pluginDefaults.exportDefaults.marginTop,
marginBottom: pluginDefaults.marginBottom, marginBottom: pluginDefaults.exportDefaults.marginBottom,
marginLeft: pluginDefaults.marginLeft, marginLeft: pluginDefaults.exportDefaults.marginLeft,
marginRight: pluginDefaults.marginRight, marginRight: pluginDefaults.exportDefaults.marginRight,
bodyFont: pluginDefaults.bodyFont, bodyFont: pluginDefaults.exportDefaults.bodyFont,
headingFont: pluginDefaults.headingFont, headingFont: pluginDefaults.exportDefaults.headingFont,
monospaceFont: pluginDefaults.monospaceFont, monospaceFont: pluginDefaults.exportDefaults.monospaceFont,
bodyFontSize: pluginDefaults.bodyFontSize bodyFontSize: pluginDefaults.exportDefaults.bodyFontSize
}; };
this.settings.templateVariables = this.templateVariables; this.settings.templateVariables = this.templateVariables;