Skip to content

Address issue #30: Fix line breaking in HTML exports#191

Merged
schuyler merged 6 commits intomainfrom
claude/resolve-issue-30-01X7a4Y5icp4sPWZfYxzDUTa
Nov 26, 2025
Merged

Address issue #30: Fix line breaking in HTML exports#191
schuyler merged 6 commits intomainfrom
claude/resolve-issue-30-01X7a4Y5icp4sPWZfYxzDUTa

Conversation

@schuyler
Copy link
Copy Markdown
Owner

Summary

Add universal export.css stylesheet for paragraph text wrapping in HTML exports and screen preview. This ensures long words and URLs wrap properly within their containers instead of causing horizontal overflow.

Changes:

  • Create MacDown/Resources/Extensions/export.css with word-breaking rules for p, li, td, th, blockquote, dd, and body elements
  • Modify MPRenderer.m to load export.css LAST in stylesheet cascade for both screen preview and HTML exports
  • Add comprehensive test suite in MPHTMLExportTests.m (18 test cases covering file existence, content validation, loading order, and integration)
  • Update planning documentation to reflect implementation

Architecture:

Related Issue

Related to #30

Manual Testing Plan

Key Scenarios to Test

  1. Long URLs in Paragraphs: URLs should wrap within containers without horizontal overflow
  2. Long Words Without Spaces: Words break at container boundaries
  3. Table Cells with Long Content: Table cells wrap content appropriately
  4. Lists with Long URLs/Words: List items wrap without overflowing
  5. Blockquotes with Long Content: Content wraps within blockquote styling
  6. Code Blocks (Regression): Should maintain horizontal scrolling (NOT wrap)
  7. Mixed Content Document: All elements wrap appropriately together

Testing Steps

  1. Open test Markdown documents with long URLs/words in various elements
  2. Verify screen preview wraps content properly (no horizontal scrollbar)
  3. Export to HTML and verify in multiple browsers (Safari, Chrome, Firefox)
  4. Test at different viewport widths (desktop, tablet, mobile)
  5. Verify across different rendering themes
  6. Confirm code blocks still allow horizontal scrolling

Review Notes

  • Groucho (Architect): Recommended universal stylesheet pattern following issue Improve code block rendering in PDF exports (handle overflow) #28
  • Chico (Code Review): Identified CSS loading order issue (fixed - export.css now loads LAST)
  • Harpo (Documentation): Updated planning docs to reflect implementation
  • Zeppo (Testing): Provided comprehensive manual testing plan

Add universal export.css stylesheet for paragraph text wrapping in HTML
exports and screen preview. This ensures long words and URLs wrap properly
within their containers instead of causing horizontal overflow.

Changes:
- Create MacDown/Resources/Extensions/export.css with word-breaking rules
  for p, li, td, th, blockquote, dd, and body elements
- Modify MPRenderer.m to load export.css in both stylesheets method (for
  screen preview) and HTMLForExportWithStyles method (for HTML exports)
- Add comprehensive test suite in MPHTMLExportTests.m covering file
  existence, CSS content validation, stylesheet loading order, and
  HTML export integration

The implementation follows the established pattern from issue #28 (PDF
export fix) using a universal stylesheet loaded in the cascade.

Related to #30
Move export.css loading to the END of the HTMLForExportWithStyles method
to ensure proper cascade order. Previously, export.css was loaded before
Prism stylesheets when highlighting was enabled, violating the principle
that export.css should always be last.

Also add test to verify CSS loading order in HTML exports with highlighting.

Changes:
- MPRenderer.m: Move export.css loading after all other stylesheets
- MPHTMLExportTests.m: Add testExportCSSIsLastStylesheetInHTMLExportWithHighlighting

Related to #30
- CSS_SPECIFICITY_ISSUE.md: Add section on export.css implementation
- ISSUE_28_INVESTIGATION.md: Document parallel HTML export implementation
- PDF_EXPORT_CSS_DEBUG_REPORT.md: Reference export.css as proof of pattern
- infrastructure_evaluation.md: Update test coverage status
- test_coverage_improvement_plan.md: Mark MPHTMLExportTests.m as completed

Related to #30
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Nov 26, 2025

Code Coverage Report

Current Coverage: 42.14%

Coverage Details (Summary)
Name                                                                                                                                   Coverage            
-------------------------------------------------------------------------------------------------------------------------------------- ------------------- 
MASPreferences.bundle                                                                                                                  0.00% (0/0)         
MacDown 3000.app                                                                                                                       53.77% (6698/12457) 
    /Users/runner/work/macdown3000/macdown3000/MacDown/Code/Document/MPDocument.m                                                      42.42% (624/1471)   
        MPEditorPreferenceKeyWithValueKey                                                                                              85.71% (6/7)        
        MPEditorKeysToObserve                                                                                                          100.00% (14/14)     
        __MPEditorKeysToObserve_block_invoke                                                                                           100.00% (9/9)       
        MPEditorPreferencesToObserve                                                                                                   100.00% (13/13)     
        __MPEditorPreferencesToObserve_block_invoke                                                                                    100.00% (8/8)       
        MPRectStringForAutosaveName                                                                                                    100.00% (6/6)       
        MPGetWebViewBackgroundColor                                                                                                    0.00% (0/9)         
        -[NSURL(Convert) absoluteBaseURLString]                                                                                        0.00% (0/6)         
        -[WebView(Shortcut) enclosingScrollView]                                                                                       100.00% (3/3)       
        -[MPPreferences(Hoedown) extensionFlags]                                                                                       71.43% (20/28)      
        -[MPPreferences(Hoedown) rendererFlags]                                                                                        66.67% (8/12)       
        MPGetPreviewLoadingCompletionHandler                                                                                           0.00% (0/25)        
        __MPGetPreviewLoadingCompletionHandler_block_invoke                                                                            0.00% (0/22)        
        -[MPDocument preferences]                                                                                                      100.00% (3/3)       
        -[MPDocument markdown]                                                                                                         100.00% (3/3)       
        -[MPDocument setMarkdown:]                                                                                                     100.00% (3/3)       
        -[MPDocument html]                                                                                                             0.00% (0/3)         
        -[MPDocument toolbarVisible]                                                                                                   0.00% (0/3)         
        -[MPDocument previewVisible]                                                                                                   100.00% (3/3)       
        -[MPDocument editorVisible]                                                                                                    100.00% (3/3)       
        -[MPDocument needsHtml]                                                                                                        0.00% (0/5)         
        -[MPDocument setTotalWords:]                                                                                                   0.00% (0/7)         
        -[MPDocument setTotalCharacters:]                                                                                              0.00% (0/7)         
        -[MPDocument setTotalCharactersNoSpaces:]                                                                                      0.00% (0/8)         
        -[MPDocument setAutosaveName:]                                                                                                 100.00% (4/4)       
        -[MPDocument init]                                                                                                             88.89% (8/9)        
        -[MPDocument windowNibName]                                                                                                    100.00% (3/3)       
        -[MPDocument windowControllerDidLoadNib:]                                                                                      98.81% (83/84)      
        __41-[MPDocument windowControllerDidLoadNib:]_block_invoke                                                                     100.00% (4/4)       
        -[MPDocument reloadFromLoadedString]                                                                                           100.00% (8/8)       
        -[MPDocument close]                                                                                                            0.00% (0/19)        
        +[MPDocument autosavesInPlace]                                                                                                 100.00% (2/2)       
        +[MPDocument writableTypes]                                                                                                    100.00% (3/3)       
        -[MPDocument isDocumentEdited]                                                                                                 100.00% (5/5)       
        -[MPDocument writeToURL:ofType:error:]                                                                                         0.00% (0/15)        
        -[MPDocument dataOfType:error:]                                                                                                0.00% (0/3)         
        -[MPDocument readFromData:ofType:error:]                                                                                       100.00% (8/8)       
        -[MPDocument prepareSavePanel:]                                                                                                76.92% (30/39)      
        __31-[MPDocument prepareSavePanel:]_block_invoke                                                                               100.00% (12/12)     
        -[MPDocument printInfo]                                                                                                        0.00% (0/12)        
        -[MPDocument printOperationWithSettings:error:]                                                                                0.00% (0/7)         
        -[MPDocument printDocumentWithSettings:showPrintPanel:delegate:didPrintSelector:contextInfo:]                                  0.00% (0/17)        
        -[MPDocument validateUserInterfaceItem:]                                                                                       0.00% (0/32)        
        -[MPDocument splitViewDidResizeSubviews:]                                                                                      100.00% (4/4)       
        -[MPDocument textView:doCommandBySelector:]                                                                                    0.00% (0/13)        

... (2120 more lines truncated)

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

- Update category to properly expose 'stylesheets' method
- Simplify stylesheet tests to avoid accessing private 'url' property
- Use public htmlForOption: method to verify export.css content instead

Related to #30
Replace MPExtensionURL calls with direct NSBundle resource lookups
since the utility function isn't available to the test target.
The table test was failing because HOEDOWN_EXT_TABLES extension
was not enabled in the mock delegate.
@schuyler
Copy link
Copy Markdown
Owner Author

Closes #30

@schuyler schuyler merged commit 9d04cde into main Nov 26, 2025
4 checks passed
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