Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ Live **Markdown preview** for Neovim with first-class **Mermaid diagram** suppor
instance_mode = "takeover", -- "takeover" (one tab) or "multi" (tab per instance)
port = 0, -- 0 = auto (8421 for takeover, OS-assigned for multi)
open_browser = true,
theme = "dark", -- "dark" or "light"; initial preview theme
debounce_ms = 300,
})
end,
Expand Down Expand Up @@ -120,6 +121,8 @@ require("markdown_preview").setup({

mermaid_renderer = "js", -- "js" (browser mermaid.js) or "rust" (mmdr CLI, ~400x faster)

theme = "dark", -- "dark" or "light"; initial preview theme (toggleable in browser)

scroll_sync = true, -- browser follows cursor position

-- Fraction (0–1): vertical position of the final line when scrolled to end.
Expand Down
6 changes: 3 additions & 3 deletions assets/index.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<!doctype html>
<html lang="en" data-theme="dark" data-bottom-padding="__BOTTOM_PADDING__">
<html lang="en" data-theme="__THEME__" data-bottom-padding="__BOTTOM_PADDING__">

<head>
<meta charset="utf-8" />
Expand Down Expand Up @@ -879,7 +879,7 @@ <h1>Markdown Preview</h1>

// ── State ─────────────────────────────────────────────────────
let lastContent = null;
let currentTheme = 'dark';
let currentTheme = document.documentElement.dataset.theme || 'dark';
let mermaidIdCounter = 0;
let sseConnected = false;
const loadedPacks = new Set();
Expand Down Expand Up @@ -1427,7 +1427,7 @@ <h1>Markdown Preview</h1>
// ── Boot ──────────────────────────────────────────────────────
(async function boot() {
try {
applyTheme('dark');
applyTheme(currentTheme);
await sync(true);
} catch (e) {
console.error('[markdown-preview] boot error:', e);
Expand Down
4 changes: 4 additions & 0 deletions lua/markdown_preview/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ M.config = {

scroll_sync = true, -- sync browser scroll to cursor position

-- "dark" or "light"; determines the initial theme of the preview page
theme = "dark",

-- Fraction (0–1): vertical position of the final line when scrolled to end.
-- 0.5 = middle of viewport (default), 1.0 = bottom edge (no extra space)
bottom_padding = 0.5,
Expand Down Expand Up @@ -95,6 +98,7 @@ local function write_index(dir)
end
local content = util.read_text(src)
content = content:gsub("__BOTTOM_PADDING__", tostring(M.config.bottom_padding))
content = content:gsub("__THEME__", M.config.theme)
util.write_text(dst, content)
return dst
end
Expand Down