Fix issue #432: restore natural table width and horizontal scrolling#440
Merged
schuyler merged 1 commit intoJun 23, 2026
Conversation
…rolling
Two CSS regressions caused wide tables to be squeezed to the pane
width with no horizontal scrolling.
Fix A — GitHub-2020.css (default theme):
The 'body table' rule combined 'width: max-content' with 'max-width: 100%',
causing max-width to cancel max-content so the table could never exceed
the pane width and overflow: auto had nothing to scroll.
Replace with:
display: block;
width: max-content;
min-width: 100%; (fill pane; allow growth beyond it)
overflow-x: auto;
Fix B — export.css (all themes, loads last):
'td, th { word-break: break-word }' forced mid-word cell breaks
universally, collapsing column widths across every theme.
Drop word-break, keep overflow-wrap: break-word so cells size to
natural content width while truly unbreakable strings (e.g. long URLs)
still wrap rather than expanding the table infinitely.
Add a 10-column wide-table regression fixture to
MacDownTests/Fixtures/tables.md + tables.html to guard against
re-introducing either regression.
Related to schuyler#432
schuyler
pushed a commit
that referenced
this pull request
Jun 23, 2026
PR #440 restored natural table width and horizontal scrolling for the default GitHub-2020 theme (via its own `body table` rule) and removed the column-collapsing `word-break: break-word` from export.css for all themes. The other ten themes, however, declare bare `table` rules with no overflow handling, so a wide table there has no scroll container: it overflows the pane and relies on document-level scrolling that may not be available. Add a universal `table` scroll container to export.css (which loads last, so it applies to every theme except where a higher-specificity `body table` rule already wins, i.e. the default theme). Use the proven GitHub pattern -- `display: block; width: max-content; max-width: 100%; overflow-x: auto` -- so the scrollbar stays on the table itself. Scope it to `@media screen` so PDF/print layout remains governed by print.css; an overflow scroll container would otherwise clip wide tables on paper rather than scrolling them. Related to #432
schuyler
pushed a commit
that referenced
this pull request
Jun 23, 2026
PR #440 restored natural table width and horizontal scrolling for the default GitHub-2020 theme (via its own `body table` rule) and removed the column-collapsing `word-break: break-word` from export.css for all themes. The other ten themes, however, declare bare `table` rules with no overflow handling, so a wide table there has no scroll container: it overflows the pane and relies on document-level scrolling that may not be available. Add a universal `table` scroll container to export.css (which loads last, so it applies to every theme except where a higher-specificity `body table` rule already wins, i.e. the default theme). Use the proven GitHub pattern -- `display: block; width: max-content; max-width: 100%; overflow-x: auto` -- so the scrollbar stays on the table itself. Scope it to `@media screen` so PDF/print layout remains governed by print.css; an overflow scroll container would otherwise clip wide tables on paper rather than scrolling them. Related to #432
schuyler
added a commit
that referenced
this pull request
Jun 23, 2026
) ## Summary Follow-up to #440. That PR restored natural table width and horizontal scrolling for the **default GitHub-2020 theme** (via its own `body table` rule) and removed the column-collapsing `word-break: break-word` from `export.css` for all themes. The other ten themes, however, declare bare `table { ... }` rules with **no overflow handling**, so a wide table under those themes still has no scroll container — it overflows the pane and relies on document-level scrolling that may not be available. This PR closes that gap. ## Change A single rule added to `MacDown/Resources/Extensions/export.css` (which is appended last in the cascade): ```css @media screen { table { display: block; width: max-content; max-width: 100%; overflow-x: auto; } } ``` Design notes: - **Cascade, not specificity.** The non-default themes use bare `table` selectors of *equal* specificity; this rule wins because `export.css` loads last (see `MPRenderer.m`). The default GitHub-2020 theme uses a higher-specificity `body table` rule and is intentionally left untouched, keeping #440's behavior. - **`@media screen` is deliberate.** `export.css` is also present when the preview is printed to PDF, where WebKit switches to print media. An unscoped scroll container would *clip* wide tables on paper; the screen scope confines this to the live preview and browser-viewed HTML and leaves PDF layout to `print.css` (whose `overflow: visible` reset only covers `pre`, not tables). - **`max-width: 100%`** keeps the scrollbar attached to the table itself rather than relying on document-level horizontal scrolling. ## Testing Tables are rendered via CSS in the preview WebView, so the existing fixture tests (which only cover the markdown→HTML step) do not exercise this behavior. Verify manually on macOS: 1. Open a document containing a wide table (≥10 columns) — the `## Wide Table` block in `MacDownTests/Fixtures/tables.md` works well. 2. **Default theme (GitHub-2020):** confirm the table keeps its natural width and scrolls horizontally — i.e. no regression from #440. 3. **Each non-default theme** (Preferences → Rendering → Style): GitHub, GitHub2, GitHub Tomorrow, Github2 (dark), Google Docs, Gmail, Clearness, Clearness Dark, Solarized (Light), Solarized (Dark). For each, confirm the wide table now scrolls horizontally instead of compressing columns. This is the core thing the PR fixes. 4. **Narrow tables:** confirm small tables still render normally (they shrink-wrap to content width under this rule, which is expected). 5. **PDF export (regression guard):** with a wide table, File → Export → PDF under both a default and a non-default theme, and confirm the table is **not** clipped on the page (the `@media screen` scope should keep `print.css` in charge). 6. Long-URL cell content still wraps rather than expanding the table indefinitely (preserved via `overflow-wrap` from #440). Related to #432 --- _Generated by [Claude Code](https://claude.ai/code/session_01T1WVepxgPRKafX2wQsz8Fv)_ Co-authored-by: Claude <[email protected]>
This was referenced Jun 24, 2026
falcon-enoc
added a commit
to falcon-enoc/macdown3000
that referenced
this pull request
Jun 24, 2026
Regenerate tables.html golden so the "Wide Table" heading (added in schuyler#440) carries the slug id emitted by the anchor-id logic, keeping the exact-match rendering test green against current main.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Wide Markdown tables are squeezed to the visible pane width with no horizontal scrolling. Old MacDown v0.7.2 rendered wide tables at natural width and allowed horizontal scrolling via WebKit's
NSScrollView.Closes #432
Root Causes (both verified in
main)Cause 1 —
GitHub-2020.cssdefault themebody tablerulewidth: max-contentwas immediately cancelled bymax-width: 100%, clamping the table to the pane width sooverflow: autohad nothing to scroll.Cause 2 —
export.css(loads last, all themes)td, thruleword-break: break-wordforced mid-word cell breaks universally, collapsing column widths across every theme regardless of Cause 1.Changes
MacDown/Resources/Styles/GitHub-2020.cssMacDown/Resources/Extensions/export.cssMacDownTests/Fixtures/tables.md+tables.htmlAdded a 10-column wide-table regression fixture to guard against re-introducing either regression.
Testing
MPMarkdownRenderingTestsandMPHTMLExportTestspass (including the new wide-table fixture).