From 140db1bba244b9c95973b6d606094d662dac05e8 Mon Sep 17 00:00:00 2001 From: SeppiaBrilla Date: Sat, 21 Oct 2023 13:11:18 +0200 Subject: [PATCH] fix and package settings --- .gitignore | 2 +- .npmignore | 4 ++++ package.json | 9 +++++---- src/ObsidianElements.ts | 6 +++--- src/WebObsidianBuilder.ts | 4 ++-- tsconfig-cjs.json | 7 +++++++ tsconfig.json | 10 ++++++---- 7 files changed, 28 insertions(+), 14 deletions(-) create mode 100644 tsconfig-cjs.json diff --git a/.gitignore b/.gitignore index 402b80b..a739922 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,3 @@ -dist/* +lib/* node_modules/* diff --git a/.npmignore b/.npmignore index 516f022..09b3d08 100644 --- a/.npmignore +++ b/.npmignore @@ -3,3 +3,7 @@ tests/ .git jest.config.js node_modules/ +.github +tsconfig-cjs.json +.npmignore +.eslintrc.cjs diff --git a/package.json b/package.json index 8dcb679..8131108 100644 --- a/package.json +++ b/package.json @@ -2,8 +2,8 @@ "name": "WebObsidianBuilder", "version": "0.1.0", "description": "A typescript library to transform Obsidian notes into html", - "main": "index.js", - "types": "dist/index.d.ts", + "main": "lib/cjs/index.js", + "module": "lib/esm/index.js", "author": "SeppiaBrilla ", "keywords": [ "Obsidian", @@ -15,10 +15,11 @@ "marked": "^9.0.1" }, "scripts": { - "build": "tsc --build", + "build": "tsc --project tsconfig.json && tsc --project tsconfig-cjs.json", "clean": "tsc --build --clean", "test": "jest", - "check": "npx eslint src/" + "check": "npx eslint src/", + "prepublishOnly": "npm run build" }, "devDependencies": { "@types/jest": "^29.5.5", diff --git a/src/ObsidianElements.ts b/src/ObsidianElements.ts index 6d6a543..61a94eb 100644 --- a/src/ObsidianElements.ts +++ b/src/ObsidianElements.ts @@ -7,7 +7,7 @@ interface Element{ Id:string; } -const MathClass = "WebObsidianMath InlineMath"; +const MathClass = "ObsidianMath"; class MathElement implements Element{ public Value: string; @@ -20,9 +20,9 @@ class MathElement implements Element{ "displayMode":display, "output":"htmlAndMathml", "throwOnError": false - }).replace('aria-hidden="true"',`aria-hidden="true" class:"${MathClass}"`); + }).replace('class="katex-html" aria-hidden="true"',`class="katex-html ${MathClass}" aria-hidden="true"`); if(!display) - this.Value = this.Value.replace('display="block"',''); + this.Value = this.Value.replaceAll('display="block"',''); this.Id = id; } } diff --git a/src/WebObsidianBuilder.ts b/src/WebObsidianBuilder.ts index 168c6e7..e69ec23 100644 --- a/src/WebObsidianBuilder.ts +++ b/src/WebObsidianBuilder.ts @@ -58,7 +58,7 @@ class WebObsidianBuilder{ let css = ""; if(this.Mathcss){ css += `.${MathClass}{ -visibility: hidden; + display: none; }`; } return css; @@ -110,7 +110,7 @@ visibility: hidden; private ConvertInlineMathElement(element:MarkdownElement, mdString:string): string{ const id: string = randomUUID(); const currentMath:string = element.Value; - this.Elements.push(new MathElement(currentMath, id, true)); + this.Elements.push(new MathElement(currentMath, id, false)); return mdString.replace(`$${currentMath}$`, id); } diff --git a/tsconfig-cjs.json b/tsconfig-cjs.json new file mode 100644 index 0000000..c06daf2 --- /dev/null +++ b/tsconfig-cjs.json @@ -0,0 +1,7 @@ +{ + "extends": "./tsconfig.json", + "compilerOptions":{ + "module":"commonJS", + "outDir":"./lib/cjs" + } +} diff --git a/tsconfig.json b/tsconfig.json index 6fa5d2e..f179bc8 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,16 +1,18 @@ { "compilerOptions": { - "target": "es2016", - "module": "commonjs", + "target": "ES2016", + "module": "ES2020", "forceConsistentCasingInFileNames": true, "strict": true, + "declaration":true, "skipLibCheck": true, - "outDir":"dist/", + "esModuleInterop":true, + "outDir":"./lib/esm", "lib": [ "ES2021.String" ] }, "include": [ - "src/" + "./src" ] }