Skip to content

Extend wide-table horizontal scrolling to all themes (screen only)#468

Merged
schuyler merged 1 commit into
mainfrom
claude/pr-432-review-alternative-teir3o
Jun 23, 2026
Merged

Extend wide-table horizontal scrolling to all themes (screen only)#468
schuyler merged 1 commit into
mainfrom
claude/pr-432-review-alternative-teir3o

Conversation

@schuyler

@schuyler schuyler commented Jun 23, 2026

Copy link
Copy Markdown
Owner

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):

@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 Fix issue #432: restore natural table width and horizontal scrolling #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 Fix issue #432: restore natural table width and horizontal scrolling #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 Fix issue #432: restore natural table width and horizontal scrolling #440).

Related to #432

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
@github-actions

github-actions Bot commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

Code Coverage Report

Current Coverage: 62.82%

Coverage Details (Summary)
Name                                                                                                                                   Coverage             
-------------------------------------------------------------------------------------------------------------------------------------- -------------------- 
MASPreferences.bundle                                                                                                                  0.00% (0/0)          
MacDown 3000.app                                                                                                                       63.50% (9227/14531)  
    /Users/runner/work/macdown3000/macdown3000/MacDown/Code/Document/MPAsset.m                                                         92.86% (104/112)     
        -[MPAsset typeName]                                                                                                            100.00% (3/3)        
        -[MPAsset defaultTypeName]                                                                                                     100.00% (3/3)        
        +[MPAsset assetWithURL:andType:]                                                                                               100.00% (3/3)        
        -[MPAsset initWithURL:andType:]                                                                                                87.50% (7/8)         
        -[MPAsset init]                                                                                                                100.00% (3/3)        
        -[MPAsset templateForOption:]                                                                                                  0.00% (0/7)          
        -[MPAsset htmlForOption:]                                                                                                      100.00% (28/28)      
        -[MPStyleSheet defaultTypeName]                                                                                                100.00% (3/3)        
        +[MPStyleSheet CSSWithURL:]                                                                                                    100.00% (3/3)        
        -[MPStyleSheet templateForOption:]                                                                                             100.00% (20/20)      
        -[MPScript defaultTypeName]                                                                                                    100.00% (3/3)        
        +[MPScript javaScriptWithURL:]                                                                                                 100.00% (3/3)        
        -[MPScript templateForOption:]                                                                                                 100.00% (20/20)      
        -[MPEmbeddedScript htmlForOption:]                                                                                             100.00% (5/5)        
    /Users/runner/work/macdown3000/macdown3000/MacDown/Code/Extension/DOMNode+Text.m                                                   100.00% (111/111)    
        MPAccumulatedTextCountMake                                                                                                     100.00% (7/7)        
        MPAccumulatedTextCountZero                                                                                                     100.00% (3/3)        
        MPAccumulatedTextCountAdd                                                                                                      100.00% (5/5)        
        MPGetStringAccumulatedTextCount                                                                                                100.00% (34/34)      
        __MPGetStringAccumulatedTextCount_block_invoke                                                                                 100.00% (3/3)        
        __MPGetStringAccumulatedTextCount_block_invoke.2                                                                               100.00% (4/4)        
        MPGetChildrenAccumulatedTextCount                                                                                              100.00% (6/6)        
        MPGetNodeAccumulatedTextCount                                                                                                  100.00% (32/32)      
        MPTextCountForString                                                                                                           100.00% (9/9)        
        -[DOMNode(Text) textCount]                                                                                                     100.00% (8/8)        
    /Users/runner/work/macdown3000/macdown3000/MacDown/Code/Utility/FileURLInlining.m                                                  27.37% (26/95)       
        +[FileURLInlining inlineFromIterable:]                                                                                         0.00% (0/11)         
        -[FileURLInlining initWithURL:]                                                                                                0.00% (0/6)          
        -[FileURLInlining init]                                                                                                        100.00% (4/4)        
        -[FileURLInlining inlineContent]                                                                                               0.00% (0/9)          
        -[FileURLInlining imageContent]                                                                                                0.00% (0/12)         
        +[FileURLInlining mimeTypeForFilePath:]                                                                                        100.00% (22/22)      
        -[FileURLInlining clippingContent]                                                                                             0.00% (0/4)          
        +[FileURLInlining isTextClippingAtPath:]                                                                                       0.00% (0/12)         
        +[FileURLInlining textContentFromClipping:]                                                                                    0.00% (0/15)         
    /Users/runner/work/macdown3000/macdown3000/Dependency/peg-markdown-highlight/HGMarkdownHighlightingStyle.m                         89.23% (58/65)       
        +[HGMarkdownHighlightingStyle colorFromARGBColor:]                                                                             100.00% (6/6)        
        -[HGMarkdownHighlightingStyle initWithType:attributesToAdd:toRemove:fontTraitsToAdd:]                                          88.89% (8/9)         
        -[HGMarkdownHighlightingStyle initWithStyleAttributes:baseFont:]                                                               88.00% (44/50)       
    /Users/runner/work/macdown3000/macdown3000/MacDown/Code/Utility/MPResourceWatcherSet.m                                             93.62% (88/94)       
        -[MPResourceWatcherSet init]                                                                                                   100.00% (6/6)        
        -[MPResourceWatcherSet dealloc]                                                                                                0.00% (0/3)          
        -[MPResourceWatcherSet watchedPaths]                                                                                           100.00% (3/3)        
        -[MPResourceWatcherSet updateWatchedPaths:]                                                                                    100.00% (16/16)      
        -[MPResourceWatcherSet addWatcherForPath:]                                                                                     100.00% (32/32)      

... (3320 more lines truncated)

📊 **Full coverage report available in workflow artifacts**

@schuyler schuyler merged commit 152763f into main Jun 23, 2026
8 of 9 checks passed
@schuyler schuyler deleted the claude/pr-432-review-alternative-teir3o branch June 23, 2026 01:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants