From 510325c64dfbdfcca43a3437ce353cb00e62ee25 Mon Sep 17 00:00:00 2001 From: Roni Axelrad Date: Sat, 16 May 2026 13:18:46 -0400 Subject: [PATCH 1/4] fix: make sure the find do not skip CODE and PRE areas. The find did not find text in those area editors before, with this fix, it does. --- src/lib/components/FindBar.svelte | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/lib/components/FindBar.svelte b/src/lib/components/FindBar.svelte index fc0c7cab..8f6425f4 100644 --- a/src/lib/components/FindBar.svelte +++ b/src/lib/components/FindBar.svelte @@ -30,10 +30,13 @@ function isHostElement(el: Element | null): boolean { if (!el) return false; + // Skip elements whose text is not user-visible (script/style/noscript) + // and our own find marks (to avoid re-walking already-highlighted text). + // CODE and PRE intentionally NOT skipped: code blocks contain real + // content the user expects to be searchable, even when highlight.js + // has wrapped tokens in nested s. const tag = el.tagName; return ( - tag === 'CODE' || - tag === 'PRE' || tag === 'SCRIPT' || tag === 'STYLE' || tag === 'NOSCRIPT' || From e230134f417c54087090797022313d30d233753c Mon Sep 17 00:00:00 2001 From: Roni Axelrad Date: Thu, 21 May 2026 08:54:22 -0400 Subject: [PATCH 2/4] fix: correct PDF export rendering bugs The exported PDF previously had three issues: - The first few characters of the first line were hidden behind the top-fade-mask gradient overlay. - The TOC overlay, TOC toggle button, and find bar (if open) were visible in the exported PDF. - Long lines inside code blocks were trimmed at the right edge because .viewer-content kept overflow: hidden during print, and the invalid `word-break: break-word` did not actually wrap long tokens. Extend the @media print block in styles.css to hide the overlays, release overflow on .viewer-content, and replace the bad word-break rule with overflow-wrap: anywhere on pre / pre code. --- src/styles.css | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/styles.css b/src/styles.css index 99b80e29..d4b29d92 100644 --- a/src/styles.css +++ b/src/styles.css @@ -1146,7 +1146,11 @@ body { .title-action-btn, .theme-dropdown-container, .control-btn, - .lang-label { + .lang-label, + .top-fade-mask, + .toc-overlay-wrapper, + .toc-toggle-floating, + .find-bar { display: none !important; } @@ -1155,7 +1159,8 @@ body { #app, .markdown-container, .layout-container, - .pane.viewer-pane { + .pane.viewer-pane, + .viewer-content { background: white !important; overflow: visible !important; height: auto !important; @@ -1179,10 +1184,12 @@ body { position: static !important; } - .markdown-body pre { + .markdown-body pre, + .markdown-body pre code { white-space: pre-wrap !important; - word-break: break-word !important; - overflow-x: visible !important; + overflow-wrap: anywhere !important; + word-break: normal !important; + overflow: visible !important; } .markdown-container { From 627f1948f35fbf1c6e0b7fced52669d88903f40e Mon Sep 17 00:00:00 2001 From: Roni Axelrad Date: Thu, 21 May 2026 08:54:49 -0400 Subject: [PATCH 3/4] fix: avoid awkward page breaks in PDF export Reduce content getting split unnaturally across pages in the exported PDF: - Headings get `break-after: avoid` so they no longer get stranded at the bottom of a page with their content on the next. - Code blocks, blockquotes, tables, figures, images, mermaid diagrams, and KaTeX displays get `break-inside: avoid` so they stay on one page when they fit. - Paragraphs and list items use `orphans: 3; widows: 3;` so prose can still split across pages but never with only one or two stranded lines at the top or bottom. Note: blocks taller than a single page will still split (the browser ignores break-inside in that case), but this fixes the common "first line of a paragraph alone at the bottom" pattern. --- src/styles.css | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/src/styles.css b/src/styles.css index d4b29d92..ca405e1f 100644 --- a/src/styles.css +++ b/src/styles.css @@ -1192,6 +1192,32 @@ body { overflow: visible !important; } + .markdown-body p, + .markdown-body li { + orphans: 3; + widows: 3; + } + + .markdown-body h1, + .markdown-body h2, + .markdown-body h3, + .markdown-body h4, + .markdown-body h5, + .markdown-body h6 { + break-after: avoid; + break-inside: avoid; + } + + .markdown-body pre, + .markdown-body blockquote, + .markdown-body table, + .markdown-body figure, + .markdown-body img, + .markdown-body .mermaid-diagram, + .markdown-body .katex-display { + break-inside: avoid; + } + .markdown-container { zoom: 1 !important; } From e956f29b35b07999b06c47eacfaa482df4bf1fe8 Mon Sep 17 00:00:00 2001 From: Roni Axelrad Date: Sun, 24 May 2026 17:58:44 -0400 Subject: [PATCH 4/4] fix: adjust markdown body styles for full-width toggle functionality --- src/lib/MarkdownViewer.svelte | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/lib/MarkdownViewer.svelte b/src/lib/MarkdownViewer.svelte index d4e3de27..51e4a6b7 100644 --- a/src/lib/MarkdownViewer.svelte +++ b/src/lib/MarkdownViewer.svelte @@ -2927,13 +2927,13 @@ import { t } from './utils/i18n.js'; .markdown-body { box-sizing: border-box; min-width: 200px; - margin: 0; + margin: 0 auto; padding: 50px clamp(24px, 5vw, 50px); height: 100%; overflow-y: auto; overflow-x: hidden; transform: translate3d(0, 0, 0); - max-width: 100%; + max-width: 880px; text-align: left; overflow-wrap: anywhere; } @@ -2989,8 +2989,8 @@ import { t } from './utils/i18n.js'; } .markdown-body.full-width { - padding: 50px clamp(24px, 5vw, 50px); max-width: 100%; + margin: 0; }