From c8d3d6ba370dbf63950a77feb097f2e498f778c0 Mon Sep 17 00:00:00 2001 From: andev0x Date: Fri, 29 Aug 2025 16:24:16 +0700 Subject: [PATCH] fix: pandoc template compilation error --- client_ws.js | 19 +++++++++++++++++- server.js | 3 +++ template.html | 53 +++------------------------------------------------ 3 files changed, 24 insertions(+), 51 deletions(-) diff --git a/client_ws.js b/client_ws.js index cee904e..1abefa6 100644 --- a/client_ws.js +++ b/client_ws.js @@ -32,13 +32,30 @@ const height = doc.scrollHeight - window.innerHeight; window.scrollTo(0, Math.round(height * percent)); } else if (msg.type === "toggleTheme") { - document.documentElement.classList.toggle("mdview-dark"); + document.body.classList.toggle("mdview-dark"); } } catch (e) { console.error("bad msg", e); } }); + // Keyboard shortcut "t" to toggle theme + window.addEventListener("keydown", (e) => { + if ((e.key || "").toLowerCase() === "t") { + document.body.classList.toggle("mdview-dark"); + } + }); + + // Click handler for theme toggle button + window.addEventListener("DOMContentLoaded", () => { + const btn = document.getElementById("theme-toggle-btn"); + if (btn) { + btn.addEventListener("click", () => { + document.body.classList.toggle("mdview-dark"); + }); + } + }); + // Enhanced image zoom UI with better error handling document.addEventListener("click", (e) => { const t = e.target; diff --git a/server.js b/server.js index 1675735..3a87868 100644 --- a/server.js +++ b/server.js @@ -29,11 +29,14 @@ function renderMarkdown() { const templatePath = path.join(__dirname, "template.html"); const args = [ MARKDOWN_FILE, + "--from=gfm+tex_math_dollars+tex_math_single_backslash+pipe_tables+table_captions+task_lists+smart+emoji", + "--to=html5", "--template=" + templatePath, "-s", "--mathjax", // Enable MathJax for mathematical expressions "--standalone", "--metadata", "title=MDView", + "--resource-path=" + path.dirname(MARKDOWN_FILE), "-o", "-" // output to stdout ]; diff --git a/template.html b/template.html index ee618f7..c689780 100644 --- a/template.html +++ b/template.html @@ -11,8 +11,8 @@ +