Skip to content

Address issue #18: Fix Mermaid gantt diagram rendering issues#151

Merged
schuyler merged 2 commits intomainfrom
claude/fix-issue-18-01VvFppPfidfrm55767bTco1
Nov 20, 2025
Merged

Address issue #18: Fix Mermaid gantt diagram rendering issues#151
schuyler merged 2 commits intomainfrom
claude/fix-issue-18-01VvFppPfidfrm55767bTco1

Conversation

@schuyler
Copy link
Copy Markdown
Owner

Summary

This PR fixes Mermaid gantt diagram rendering issues by removing external CSS and using Mermaid's modern theme API.

Changes Made

  • Removed mermaid.forest.css loading from MPRenderer.m
  • Added theme: 'forest' to mermaid.initialize() in mermaid.init.js
  • Removed mermaidStylesheets property and method
  • Updated both preview and HTML export paths

Issues Fixed

✅ Today's indicator line now appears correctly in gantt charts (with and without explicit dateFormat)
✅ X-axis date labels no longer overlap
✅ Forest theme appearance preserved
✅ All other Mermaid diagram types continue to work correctly

Technical Details

The root cause was that external CSS (mermaid.forest.css) interfered with Mermaid 8.0+'s internal theme system. Modern Mermaid versions expect theme configuration via the JavaScript API, not external stylesheets. This fix:

  1. Removes the conflicting external CSS
  2. Uses the official theme API (theme: 'forest')
  3. Achieves the same visual result with better compatibility

This approach follows the fix from MacDownApp/macdown#1156.

Code Changes

Files Modified:

  • MacDown/Resources/Extensions/mermaid.init.js (+3 lines)
  • MacDown/Code/Document/MPRenderer.m (-18 lines)

Net Change: -15 lines

Testing

Automated Tests: All unit tests pass on macOS runner (CI)
📋 Manual Testing Plan: Available at plans/MANUAL_TEST_PLAN_ISSUE_18.md

Code Review

Architectural review: Approved by Groucho (architectural guidance)
Code review: Approved by Chico - MERGE READY
Documentation review: Completed by Harpo - No updates needed
Testing plan: Provided by Zeppo - Comprehensive manual test plan available

Manual Testing

A comprehensive manual testing plan is available for visual verification:

  • Gantt charts with and without dateFormat
  • X-axis label spacing and readability
  • Today's indicator visibility
  • Forest theme appearance
  • Other Mermaid diagram types (flowchart, sequence, etc.)
  • HTML export functionality

Related Issue

Related to #18


Note: Per project convention, this PR uses "Related to" rather than "Fixes" or "Closes" to avoid auto-closing the issue. Manual verification is recommended before closing the issue.

- Remove mermaid.forest.css loading from MPRenderer.m
- Use Mermaid 8.0+ theme API with 'forest' theme in mermaid.init.js
- Fixes today's indicator disappearing when dateFormat not set
- Fixes x-axis date label overlap in gantt charts

This applies the fix from MacDownApp/macdown#1156 which addresses
the issue where external CSS interferes with Mermaid's internal
theming system. By using the modern theme API, Mermaid's built-in
rendering works correctly while maintaining the forest theme appearance.

Changes:
- Removed mermaidStylesheets property and method
- Removed CSS loading from preview rendering path
- Removed CSS loading from HTML export path
- Added theme: 'forest' to mermaid.initialize()

Related to #18
Comprehensive testing plan for verifying Mermaid gantt diagram rendering fix.
Includes test scenarios, expected results, and visual inspection guidelines.

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

github-actions bot commented Nov 20, 2025

Code Coverage Report

Current Coverage: 40.43%

Coverage Details (Summary)
Name                                                                                                                                   Coverage            
-------------------------------------------------------------------------------------------------------------------------------------- ------------------- 
MASPreferences.bundle                                                                                                                  0.00% (0/0)         
MacDown 3000.app                                                                                                                       53.94% (6708/12435) 
    /Users/runner/work/macdown3000/macdown3000/MacDown/Code/Extension/NSColor+HTML.m                                                   94.07% (333/354)    
        +[NSColor(HTML) colorWithHexString:]                                                                                           94.12% (16/17)      
        +[NSColor(HTML) colorWithHTMLName:]                                                                                            89.13% (164/184)    
        __35+[NSColor(HTML) colorWithHTMLName:]_block_invoke                                                                           100.00% (153/153)   
    /Users/runner/work/macdown3000/macdown3000/MacDown/Code/Document/MPDocument.m                                                      49.07% (739/1506)   
        MPEditorPreferenceKeyWithValueKey                                                                                              85.71% (6/7)        
        MPEditorKeysToObserve                                                                                                          100.00% (15/15)     
        __MPEditorKeysToObserve_block_invoke                                                                                           100.00% (10/10)     
        MPEditorPreferencesToObserve                                                                                                   100.00% (14/14)     
        __MPEditorPreferencesToObserve_block_invoke                                                                                    100.00% (9/9)       
        MPRectStringForAutosaveName                                                                                                    100.00% (6/6)       
        MPGetWebViewBackgroundColor                                                                                                    0.00% (0/10)        
        -[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                                                                                           100.00% (25/25)     
        __MPGetPreviewLoadingCompletionHandler_block_invoke                                                                            100.00% (22/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/8)         
        -[MPDocument setTotalCharacters:]                                                                                              0.00% (0/8)         
        -[MPDocument setTotalCharactersNoSpaces:]                                                                                      0.00% (0/9)         
        -[MPDocument setAutosaveName:]                                                                                                 100.00% (4/4)       
        -[MPDocument init]                                                                                                             88.89% (8/9)        
        -[MPDocument windowNibName]                                                                                                    100.00% (3/3)       
        -[MPDocument windowControllerDidLoadNib:]                                                                                      100.00% (84/84)     
        __41-[MPDocument windowControllerDidLoadNib:]_block_invoke                                                                     100.00% (5/5)       
        -[MPDocument reloadFromLoadedString]                                                                                           100.00% (9/9)       
        -[MPDocument close]                                                                                                            0.00% (0/19)        
        +[MPDocument autosavesInPlace]                                                                                                 100.00% (3/3)       
        +[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% (9/9)       
        -[MPDocument prepareSavePanel:]                                                                                                76.92% (30/39)      
        __31-[MPDocument prepareSavePanel:]_block_invoke                                                                               100.00% (12/12)     
        -[MPDocument printInfo]                                                                                                        0.00% (0/13)        
        -[MPDocument printOperationWithSettings:error:]                                                                                0.00% (0/7)         

... (2020 more lines truncated)

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

@schuyler schuyler merged commit b95333d into main Nov 20, 2025
3 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