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
+452 -136

No files matched your search

+66 -48
View File
@@ -1,50 +1,68 @@
import { defineConfig, globalIgnores } from "eslint/config";
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";
// @ts-check
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const compat = new FlatCompat({
baseDirectory: __dirname,
recommendedConfig: js.configs.recommended,
allConfig: js.configs.all
});
import eslint from '@eslint/js';
import globals from 'globals';
import tseslint from 'typescript-eslint';
export default defineConfig([globalIgnores(["**/node_modules/", "**/main.js"]), {
extends: compat.extends(
"eslint:recommended",
"plugin:@typescript-eslint/eslint-recommended",
"plugin:@typescript-eslint/recommended",
),
plugins: {
"@typescript-eslint": typescriptEslint,
},
languageOptions: {
globals: {
...globals.node,
},
parser: tsParser,
ecmaVersion: 5,
sourceType: "module",
},
rules: {
"no-unused-vars": "off",
"@typescript-eslint/no-unused-vars": ["error", {
args: "none",
}],
"@typescript-eslint/ban-ts-comment": "off",
"no-prototype-builtins": "off",
"@typescript-eslint/no-empty-function": "off",
},
}]);
export default tseslint.config(
// Apply ESLint recommended rules
eslint.configs.recommended,
// Apply TypeScript-ESLint recommended rules
...tseslint.configs.recommended,
{
// Configure language options
languageOptions: {
globals: {
...globals.node,
...globals.es2022,
},
parserOptions: {
sourceType: 'module',
ecmaVersion: 2022,
},
},
// Configure files to lint
files: ['**/*.ts', '**/*.js', 'main.ts'],
// Configure rules - incorporating Obsidian sample plugin settings
rules: {
// 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: '^_' }],
// Allow @ts-ignore comments (useful for Obsidian API quirks)
'@typescript-eslint/ban-ts-comment': 'off',
// Allow prototype builtins usage
'no-prototype-builtins': 'off',
// Allow empty functions (common in plugin architecture)
'@typescript-eslint/no-empty-function': 'off',
// Allow require() imports (Node.js environment with mixed modules)
'@typescript-eslint/no-require-imports': '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 {
App,
addIcon,
Plugin,
TFile,
TFolder,
TAbstractFile,
Notice,
Menu,
MarkdownView
} from 'obsidian';
import { obsidianTypstPDFExportSettings, DEFAULT_SETTINGS } from './src/core/settings';
import { DependencyChecker } from './src/core/DependencyChecker';
import type { PreprocessingResult } from './src/converters/MarkdownPreprocessor';
import { ExportErrorHandler } from './src/core/ExportErrorHandler';
import { PandocTypstConverter } from './src/converters/PandocTypstConverter';
import { TemplateManager } from './src/templates/TemplateManager';
import { EmbeddedTemplateManager } from './src/templates/embeddedTemplates';
@@ -30,8 +26,6 @@ import { FontManager } from './src/plugin/FontManager';
import { PathResolver } from './src/plugin/PathResolver';
import { ObsidianTypstPDFExportSettingTab } from './src/plugin/SettingsTab';
import { EmbedProcessor } from './src/plugin/EmbedProcessor';
import * as path from 'path';
import * as fs from 'fs';
export class obsidianTypstPDFExport extends Plugin {
settings: obsidianTypstPDFExportSettings;
+332 -13
View File
@@ -1,12 +1,12 @@
{
"name": "obsidian-typst-pdf-export",
"version": "1.1.0",
"version": "1.2.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "obsidian-typst-pdf-export",
"version": "1.1.0",
"version": "1.2.0",
"license": "MIT",
"dependencies": {
"gray-matter": "^4.0.3",
@@ -24,7 +24,8 @@
"globals": "^16.3.0",
"obsidian": "latest",
"tslib": "2.4.0",
"typescript": "4.7.4"
"typescript": "^5.9.2",
"typescript-eslint": "^8.43.0"
}
},
"node_modules/@codemirror/state": {
@@ -432,7 +433,6 @@
"integrity": "sha512-dyybb3AcajC7uha6CvhdVRJqaKyn7w2YKqKyAN37NKYgZT36w+iRb0Dymmc5qEJ549c/S31cMMSFd75bteCpCw==",
"dev": true,
"license": "MIT",
"peer": true,
"dependencies": {
"eslint-visitor-keys": "^3.4.3"
},
@@ -452,7 +452,6 @@
"integrity": "sha512-CCZCDJuduB9OUkFkY2IgppNZMi2lBQgD2qzwXkEia16cge2pijY/aXi96CJMquDMn3nJdlPV1A5KrJEXwfLNzQ==",
"dev": true,
"license": "MIT",
"peer": true,
"engines": {
"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": {
"version": "5.29.0",
"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"
}
},
"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": {
"version": "5.29.0",
"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",
"integrity": "sha512-EtKwoO6kxCL9WO5xipiHTZlSzBm7WLT627TqC/uVRd0HKmq8NXyebnNYxDoBi7wt8eTWrUrKXCOVaFq9x1kgag==",
"dev": true,
"license": "MIT",
"peer": true
"license": "MIT"
},
"node_modules/gray-matter": {
"version": "4.0.3",
@@ -3101,8 +3152,7 @@
"resolved": "https://registry.npmjs.org/natural-compare/-/natural-compare-1.4.0.tgz",
"integrity": "sha512-OWND8ei3VtNC9h7V60qff3SVobHr996CTwgxubgyQYEpg290h9J0buyECNNJexkFm5sOajh5G116RYA1c8ZMSw==",
"dev": true,
"license": "MIT",
"peer": true
"license": "MIT"
},
"node_modules/node-abi": {
"version": "3.75.0",
@@ -4057,6 +4107,19 @@
"license": "MIT",
"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": {
"version": "2.4.0",
"resolved": "https://registry.npmjs.org/tslib/-/tslib-2.4.0.tgz",
@@ -4128,9 +4191,9 @@
}
},
"node_modules/typescript": {
"version": "4.7.4",
"resolved": "https://registry.npmjs.org/typescript/-/typescript-4.7.4.tgz",
"integrity": "sha512-C0WQT0gezHuw6AdY1M2jxUO83Rjf0HP7Sk1DtXj6j1EwkQNZrHAg2XPWlq62oqEhYvONq5pkC2Y9oPljWToLmQ==",
"version": "5.9.2",
"resolved": "https://registry.npmjs.org/typescript/-/typescript-5.9.2.tgz",
"integrity": "sha512-CWBzXQrc/qOkhidw1OzBTQuYRbfyxDXJMVJ1XNwUHGROVmuaeiEm3OslpZ1RV96d7SKKjZKrSJu3+t/xlw3R9A==",
"dev": true,
"license": "Apache-2.0",
"bin": {
@@ -4138,7 +4201,263 @@
"tsserver": "bin/tsserver"
},
"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": {
+6 -3
View File
@@ -4,8 +4,10 @@
"description": "Exports a note or collection of notes to a pretty Typst PDF.",
"main": "main.js",
"scripts": {
"dev": "node esbuild.config.mjs",
"build": "tsc -noEmit -skipLibCheck && node esbuild.config.mjs production",
"typecheck": "tsc --noEmit",
"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",
"version": "node version-bump.mjs && git add manifest.json versions.json"
},
@@ -30,7 +32,8 @@
"globals": "^16.3.0",
"obsidian": "latest",
"tslib": "2.4.0",
"typescript": "4.7.4"
"typescript": "^5.9.2",
"typescript-eslint": "^8.43.0"
},
"dependencies": {
"gray-matter": "^4.0.3",
-3
View File
@@ -3,13 +3,10 @@
* Handles the conversion of Markdown to PDF using Pandoc with Typst engine
*/
import * as fs from 'fs';
import { promises as fsPromises } from 'fs';
import * as path from 'path';
import * as os from 'os';
import { mapToTypstPaperSize } from '../utils/paperSizeMapper';
import { PandocOptions, TypstSettings, ConversionResult, ProgressCallback } from './converterTypes';
import type { obsidianTypstPDFExportSettings } from '../core/settings';
import type { obsidianTypstPDFExport } from '../../main';
import { TempDirectoryManager } from '../core/TempDirectoryManager';
@@ -110,7 +110,7 @@ export class ResourcePathResolver {
if (hasImages) {
foundResourcePaths.push(itemPath);
}
} catch (e) {
} catch {
// Ignore directories we can't read
}
}
+1 -3
View File
@@ -26,15 +26,13 @@ export class BinaryLocator {
try {
// 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
let pluginDir: string;
// Try multiple strategies to find the plugin directory
const pluginDirName = plugin?.manifest?.dir || 'typst-pdf-export';
const configDir = plugin?.app.vault.configDir || '.obsidian';
const possiblePluginDirs = this.getPossiblePluginDirs(plugin, pluginDirName, configDir);
// Find the first directory that exists and has node_modules
pluginDir = possiblePluginDirs.find(dir => {
const pluginDir = possiblePluginDirs.find(dir => {
try {
const nodeModulesPath = path.join(dir, 'node_modules');
return require('fs').existsSync(nodeModulesPath);
+2 -2
View File
@@ -36,7 +36,7 @@ export class FileDiscovery {
filePath: expectedOutputPath,
found: true
};
} catch (error) {
} catch {
// File not found with expected name, try to find alternatives
return await this.findAlternativeFile(outputDir, expectedFileName, expectedOutputPath);
}
@@ -82,7 +82,7 @@ export class FileDiscovery {
filePath: actualOutputPath,
found: true
};
} catch (finalError) {
} catch {
return {
filePath: '',
found: false,
+2 -2
View File
@@ -29,7 +29,7 @@ export class PdfProcessor {
// Check PDF signature - all valid PDFs must start with %PDF
const signature = buffer.subarray(0, 4).toString();
return signature === '%PDF';
} catch (error) {
} catch {
return false;
}
}
@@ -83,7 +83,7 @@ export class PdfProcessor {
try {
await fs.access(filePath);
return { success: true };
} catch (error: unknown) {
} catch {
return {
success: false,
error: `PDF file not found: ${filePath}`
@@ -324,7 +324,7 @@ export class CalloutProcessor {
if (!text) return '';
// First, clean up problematic Unicode characters
let cleaned = text
const cleaned = text
// Replace various Unicode spaces with regular spaces
.replace(/[\u00A0\u1680\u2000-\u200B\u202F\u205F\u3000\uFEFF]/g, ' ')
// Replace Unicode line separators with regular newlines
@@ -55,7 +55,7 @@ export class EmbedProcessor {
private wikilinkProcessor: WikilinkProcessor;
// Regex patterns for embed matching
private readonly EMBED_PATTERN = /!\[\[([^\|\]]+)(?:\|([^\]]+))?\]\]/g;
private readonly EMBED_PATTERN = /!\[\[([^|\]]+)(?:\|([^\]]+))?\]\]/g;
private readonly EMBED_SIZE_PATTERN = /(\d+)(?:x(\d+))?/;
constructor(config: EmbedProcessorConfig) {
@@ -62,7 +62,7 @@ export class WikilinkProcessor {
private baseUrl?: string;
// 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) {
this.wikilinkConfig = config.wikilinkConfig;
@@ -137,7 +137,7 @@ export class WikilinkProcessor {
return filePath
.replace(/[<>:"|?*]/g, '_') // Replace problematic characters
.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
.toLowerCase()
.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
}
+2 -2
View File
@@ -85,7 +85,7 @@ export class ExecutableChecker {
const foundPath = stdout.trim();
return foundPath || null;
} catch (error) {
} catch {
return null;
}
}
@@ -198,7 +198,7 @@ export class ExecutableChecker {
isAvailable: true,
executablePath
};
} catch (error) {
} catch {
return {
name,
version: null,
+2 -1
View File
@@ -53,6 +53,7 @@ export class SecurityUtils {
// Check for command injection attempts
const dangerousPatterns = [
/[;&|`$(){}[\]]/, // Shell metacharacters
// eslint-disable-next-line no-control-regex
/\x00/, // Null bytes
/\n|\r/, // Newlines
/\s*[;&|]\s*/, // Command separators with whitespace
@@ -113,7 +114,7 @@ export class SecurityUtils {
if (/[;&|`$(){}[\]]/.test(normalizedPath)) {
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';
}
if (/\n|\r/.test(normalizedPath)) {
+6 -1
View File
@@ -25,6 +25,9 @@ export interface obsidianTypstPDFExportSettings {
additionalPaths: string[];
};
/** Custom environment variables for subprocess execution */
customEnvironmentVariables: { [key: string]: string };
/** Export defaults */
exportDefaults: {
/** Default template to use for exports */
@@ -108,6 +111,8 @@ export const DEFAULT_SETTINGS: obsidianTypstPDFExportSettings = {
additionalPaths: ['/opt/homebrew/bin', '/usr/local/bin', '/usr/bin']
},
customEnvironmentVariables: {},
exportDefaults: {
template: 'default',
format: ExportFormat.Standard,
@@ -156,4 +161,4 @@ export const DEFAULT_SETTINGS: obsidianTypstPDFExportSettings = {
embedAllFiles: true,
printFrontmatter: false
}
};;;;
};
+3 -3
View File
@@ -22,7 +22,7 @@ export class EmbedProcessor {
let updatedContent = processedResult.content;
for (const pdfEmbed of processedResult.metadata.pdfEmbeds) {
for (const pdfEmbed of processedResult.metadata?.pdfEmbeds || []) {
try {
// Resolve PDF path using helper method
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> {
let updatedContent = processedResult.content;
for (const imageEmbed of processedResult.metadata.imageEmbeds) {
for (const imageEmbed of processedResult.metadata?.imageEmbeds || []) {
try {
// Decode the URL-encoded sanitized path back to normal characters
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> {
let updatedContent = processedResult.content;
for (const fileEmbed of processedResult.metadata.fileEmbeds) {
for (const fileEmbed of processedResult.metadata?.fileEmbeds || []) {
try {
// Resolve file path using helper method (similar to PDF processing)
const fullFilePath = await this.resolveFilePath(fileEmbed.sanitizedPath, vaultBasePath, currentFile);
+1 -1
View File
@@ -81,7 +81,7 @@ export class PluginLifecycle {
try {
const vaultPath = (this.plugin.app.vault.adapter as any).basePath;
const cleanupManager = TempDirectoryManager.create(vaultPath, this.plugin.app.vault.configDir);
const result = cleanupManager.cleanupAllTempDirs();
const _result = cleanupManager.cleanupAllTempDirs();
if (this.plugin.settings.behavior.debugMode) {
// Debug logging was here but empty in original
+1 -1
View File
@@ -7,12 +7,12 @@ import {
App,
PluginSettingTab,
Setting,
Notice,
normalizePath
} from 'obsidian';
import type { obsidianTypstPDFExport } from '../../main';
import { ExportFormat } from '../core/settings';
import { SecurityUtils } from '../core/SecurityUtils';
import { ExportErrorHandler } from '../core/ExportErrorHandler';
import { FolderSuggest } from '../ui/components/FolderSuggest';
import { SUPPORTED_PAPER_SIZES } from '../utils/paperSizeMapper';
+2 -21
View File
@@ -112,27 +112,8 @@ export class ExportConfigModal extends Modal {
}
private handleReset(): void {
// Create plugin defaults object from settings tab values
const pluginDefaults = {
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);
// Reset state to plugin defaults using the full settings object
this.state.reset(this.plugin.settings);
// Re-render sections to update UI
this.renderer.refreshSections();
+1 -1
View File
@@ -121,7 +121,7 @@ export class ModalRenderer {
this.progressBar = progressBarContainer.createDiv('export-progress-bar');
// Progress percentage
const progressPercent = this.progressContainer.createEl('div', {
const _progressPercent = this.progressContainer.createEl('div', {
cls: 'export-progress-percent',
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
const filteredTemplates = templates.filter(template => template !== 'universal-wrapper.pandoc.typ');
this.templateDropdown.selectEl.empty();
this.templateDropdown?.selectEl.empty();
filteredTemplates.forEach(template => {
this.templateDropdown.addOption(template, this.getTemplateDisplayName(template));
this.templateDropdown?.addOption(template, this.getTemplateDisplayName(template));
});
// Restore selection if still available
if (filteredTemplates.includes(currentValue)) {
this.templateDropdown.setValue(currentValue);
this.templateDropdown?.setValue(currentValue);
} 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
this.settings = {
...this.settings,
template: pluginDefaults.template,
format: pluginDefaults.format,
template: pluginDefaults.exportDefaults.template,
format: pluginDefaults.exportDefaults.format,
outputFolder: pluginDefaults.outputFolder || 'exports',
templateVariables: {},
progressPercent: 0,
currentOperation: '',
isExporting: false,
canCancel: false,
openAfterExport: pluginDefaults.openAfterExport || false,
preserveFolderStructure: pluginDefaults.preserveFolderStructure || false
openAfterExport: pluginDefaults.behavior.openAfterExport || false,
preserveFolderStructure: pluginDefaults.behavior.preserveFolderStructure || false
};
this.templateVariables = {
pageSize: pluginDefaults.pageSize,
orientation: pluginDefaults.orientation,
flipped: pluginDefaults.orientation === 'landscape',
marginTop: pluginDefaults.marginTop,
marginBottom: pluginDefaults.marginBottom,
marginLeft: pluginDefaults.marginLeft,
marginRight: pluginDefaults.marginRight,
bodyFont: pluginDefaults.bodyFont,
headingFont: pluginDefaults.headingFont,
monospaceFont: pluginDefaults.monospaceFont,
bodyFontSize: pluginDefaults.bodyFontSize
pageSize: pluginDefaults.exportDefaults.pageSize,
orientation: pluginDefaults.exportDefaults.orientation,
flipped: pluginDefaults.exportDefaults.orientation === 'landscape',
marginTop: pluginDefaults.exportDefaults.marginTop,
marginBottom: pluginDefaults.exportDefaults.marginBottom,
marginLeft: pluginDefaults.exportDefaults.marginLeft,
marginRight: pluginDefaults.exportDefaults.marginRight,
bodyFont: pluginDefaults.exportDefaults.bodyFont,
headingFont: pluginDefaults.exportDefaults.headingFont,
monospaceFont: pluginDefaults.exportDefaults.monospaceFont,
bodyFontSize: pluginDefaults.exportDefaults.bodyFontSize
};
this.settings.templateVariables = this.templateVariables;