Tables with 3+ columns render wider than Settings -> Preview -> Max width
Version: 2.8.3, Windows 11 (Tauri 2.12 / Rust)
What happens
With Settings → Preview → Max width set to 960, a pipe table with three or more columns renders wider than that setting — it grows to nearly the full pane width. Two-column tables are fine.
Why
src/lib/MarkdownViewer.svelte's component <style> lifts the table's width cap from the text column to the pane itself:
.viewer-content :global(.markdown-body table:not(:is(li, blockquote, td, th, details, .markdown-alert, .footnotes) table)) {
max-width: max(100%, 100cqi - 2 * var(--breakout-inset));
translate: min(0px, (var(--measure) - 2 * var(--gutter)) / 2 - 50%);
}
With --measure: min(100cqi, var(--preview-max-width, 880px)) and --breakout-inset: var(--gutter), this compiles to something like .viewer-content.svelte-xxxx .markdown-body table:not(...) — specificity 0,2,1 — so it wins over .markdown-body table { max-width: 100% } in styles.css (0,1,1). It is the only cap that reaches the table.
Numbers on a 1920 px window with the setting at 960:
| quantity | value |
|---|---|
--measure |
960 |
--gutter |
clamp(24px, 5vw, 50px) = 50 |
| padding | max(50, (1920 - 960) / 2 + 50) = 530 |
| text column | 1920 - 1060 = 860 |
table max-width |
max(100%, 1920 - 100) = 1820 |
So any table whose natural width exceeds the text column (860) is allowed to grow to 1820, with translate shifting it left by half the excess to keep it centred on the column — exactly the "grow into the margins" behaviour the comment above the rule describes.
That is also why the two cases that don't reproduce look the way they do: a two-column table rarely reaches 860 px of natural width, and in full-width mode (--measure: 100cqi) the expression collapses to the column width, so nothing can break out.
Suggested fix
Cap the table at the text column like every other block: drop the runtime override and let styles.css's max-width: 100% stand. A table too wide for the column then keeps its natural column widths and scrolls horizontally inside the column — which is what that overflow-x: auto is there for (and matches the GitHub behaviour the comment in styles.css asks for).
Doing exactly that locally (removing the rule, plus --breakout-inset and .markdown-body.toc-in-gutter, which exist only to feed it) keeps three-column tables inside the configured width. Happy to send a PR if you want it.
This is intended. #840 lets a table wider than the text column use the side margins so it can be read without scrolling. The trigger is the table's natural width exceeding the column, not the column count. I'm not going to revert it, but I'm open to a setting that turns the breakout off and keeps tables inside the max width with horizontal scroll.
Fair point on the styles.css comment: it still describes GitHub's scroll-within-the-column behaviour, which #840 overrides in the viewer. We'll consider making that behaviour available again and decide later.
2.8.4 (https://github.com/sftwrdotdev/Markpad/releases/tag/v2.8.4) adds Wide Tables Can Exceed Max Width in Settings → Preview, off by default, so tables now stay within Max width and scroll sideways when they don't fit. Turn it on for the old margin behaviour.