diff --git a/app/server/http.ts b/app/server/http.ts index 7de05f2..c1c15b0 100644 --- a/app/server/http.ts +++ b/app/server/http.ts @@ -75,6 +75,29 @@ export function httpHandler(app: GithubPreview) { }); } + if (requested === "/katex.css") { + const katexCss = Bun.resolveSync("katex/dist/katex.min.css", import.meta.dir); + const file = Bun.file(katexCss); + return new Response(file, { + headers: { "content-type": "text/css" }, + }); + } + + if (requested.startsWith("/fonts/KaTeX_")) { + const fontPath = Bun.resolveSync("katex/dist" + requested, import.meta.dir); + const file = Bun.file(fontPath); + const ext = requested.split(".").pop(); + const contentType = + ext === "woff2" + ? "font/woff2" + : ext === "woff" + ? "font/woff" + : "font/ttf"; + return new Response(file, { + headers: { "content-type": contentType }, + }); + } + if (requested === "/mermaid.js") { const mermaid = Bun.resolveSync("mermaid/dist/mermaid.min.js", import.meta.dir); const file = Bun.file(mermaid); diff --git a/app/web/index.html b/app/web/index.html index 925ad6d..e018a21 100644 --- a/app/web/index.html +++ b/app/web/index.html @@ -7,6 +7,7 @@ + LIVE (github-preview) diff --git a/bun.lock b/bun.lock index 1bc719c..e6d2107 100644 --- a/bun.lock +++ b/bun.lock @@ -1,5 +1,6 @@ { "lockfileVersion": 1, + "configVersion": 0, "workspaces": { "": { "name": "github-preview.nvim", @@ -10,7 +11,7 @@ "isbinaryfile": "5.0.4", "mermaid": "^11.4.1", "opener": "^1.5.2", - "pantsdown": "2.1.6", + "pantsdown": "2.2.0", "react": "^19.0.0", "react-dom": "^19.0.0", "reconnecting-websocket": "^4.4.0", @@ -1122,7 +1123,7 @@ "package-manager-detector": ["package-manager-detector@1.3.0", "", {}, "sha512-ZsEbbZORsyHuO00lY1kV3/t72yp6Ysay6Pd17ZAlNGuGwmWDLCJxFpRs0IzfXfj1o4icJOkUEioexFHzyPurSQ=="], - "pantsdown": ["pantsdown@2.1.6", "", { "dependencies": { "github-slugger": "^2.0.0", "highlight.js": "^11.10.0" } }, "sha512-ayvf1rgurFp8Zl6jbhxNg1Jl5rnZ4PV3fnBt0YLJhL1CnIM6Oj+RMv9mQX4RKvJL42xJHj/kw26JMuMPmQAQCg=="], + "pantsdown": ["pantsdown@2.2.0", "", { "dependencies": { "github-slugger": "^2.0.0", "highlight.js": "^11.11.1", "katex": "^0.16.28" } }, "sha512-qe7doilipoJxGkZOzv8Y2vxgABNRs/S48rVYKwvPXpAg401moiSgznePeFSLgnAN6Pi/5Z5pg0XDEaBDOg6mMQ=="], "parent-module": ["parent-module@1.0.1", "", { "dependencies": { "callsites": "^3.0.0" } }, "sha512-GQ2EWRpQV8/o+Aw8YqtfZZPfNRWZYkbidE9k5rpl/hC3vtHHBfGm2Ifi6qWV+coDGkrUKZAxE3Lot5kcsRlh+g=="], @@ -1942,6 +1943,8 @@ "ora/chalk": ["chalk@4.1.2", "", { "dependencies": { "ansi-styles": "^4.1.0", "supports-color": "^7.1.0" } }, "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA=="], + "pantsdown/katex": ["katex@0.16.28", "", { "dependencies": { "commander": "^8.3.0" }, "bin": { "katex": "cli.js" } }, "sha512-YHzO7721WbmAL6Ov1uzN/l5mY5WWWhJBSW+jq4tkfZfsxmo1hu6frS0EOswvjBUnWE6NtjEs48SFn5CQESRLZg=="], + "parse5-htmlparser2-tree-adapter/parse5": ["parse5@6.0.1", "", {}, "sha512-Ofn/CTFzRGTTxwpNEs9PP93gXShHcTq255nzRYSKe8AkVpZY7e1fpmTfOyoIvjP5HG7Z2ZM7VS9PPhQGW2pOpw=="], "pkg-conf/find-up": ["find-up@2.1.0", "", { "dependencies": { "locate-path": "^2.0.0" } }, "sha512-NWzkk0jSJtTt08+FBFMvXoeZnOJD+jTtsRmBYbAIzJdX6l7dLgR7CTubCM5/eDdPUBvLCeVasP1brfVR/9/EZQ=="], @@ -2088,6 +2091,8 @@ "npm/wrap-ansi-cjs/ansi-styles": ["ansi-styles@4.3.0", "", { "dependencies": { "color-convert": "^2.0.1" } }, "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg=="], + "pantsdown/katex/commander": ["commander@8.3.0", "", {}, "sha512-OkTL9umf+He2DZkUq8f8J9of7yL6RJKI24dVITBmNfZBmri9zYZQrKkuXiKhyfPSu8tUhnVBB1iKXevvnlR4Ww=="], + "pkg-conf/find-up/locate-path": ["locate-path@2.0.0", "", { "dependencies": { "p-locate": "^2.0.0", "path-exists": "^3.0.0" } }, "sha512-NCI2kiDkyR7VeEKm27Kda/iQHyKJe1Bu0FlTbYp3CqJu+9IFe9bLyAjMxf5ZDDbEg+iMPzB5zYyUTSm8wVTKmA=="], "restore-cursor/onetime/mimic-fn": ["mimic-fn@2.1.0", "", {}, "sha512-OqbOk5oEQeAZ8WXWydlu9HJjz9WVdEIvamMCcXmuqUYjTknH/sqsWvhQ3vgwKFRR1HpjvNBKQ37nbJgYzGqGcg=="], diff --git a/package.json b/package.json index 1548c11..dccb968 100644 --- a/package.json +++ b/package.json @@ -48,7 +48,7 @@ "isbinaryfile": "5.0.4", "mermaid": "^11.4.1", "opener": "^1.5.2", - "pantsdown": "2.1.6", + "pantsdown": "2.2.0", "react": "^19.0.0", "react-dom": "^19.0.0", "reconnecting-websocket": "^4.4.0",