Skip to content

Address issue #35: Upgrade Mermaid to v11.12.1 for flowchart rendering#193

Closed
schuyler wants to merge 3 commits intomainfrom
claude/resolve-issue-35-01Sm7Qua1TdWcT47LPvfggET
Closed

Address issue #35: Upgrade Mermaid to v11.12.1 for flowchart rendering#193
schuyler wants to merge 3 commits intomainfrom
claude/resolve-issue-35-01Sm7Qua1TdWcT47LPvfggET

Conversation

@schuyler
Copy link
Copy Markdown
Owner

Summary

  • Upgrade Mermaid library from v8.4.3 (2020) to v11.12.1
  • Update mermaid.init.js to use Promise-based API (Mermaid 10.x+)
  • Add async/await pattern for rendering with proper error handling
  • Add unique ID generation to prevent collisions on document re-renders
  • Add securityLevel: 'loose' and logLevel: 'error' to configuration
  • Update documentation to reflect Mermaid 11.x

Related Issue

Related to #35

Manual Testing Plan

A comprehensive 16-test manual testing plan was created covering:

  • Basic flowchart rendering (graph TD, LR, BT, RL)
  • Decision nodes, subgraphs, styled nodes, long text labels
  • Error handling for malformed syntax
  • Multiple diagrams without ID collisions
  • Live preview re-rendering
  • Regression testing for gantt charts (issue Mermaid issue on latest release 0.8.0d71 #18)
  • Regression testing for other diagram types (sequence, class, state, pie)
  • HTML export verification
  • Unicode/emoji support
  • Performance with large diagrams

Review Notes

  • Groucho (Architect): Identified mermaid.min.js and mermaid.init.js as the key files
  • Chico (Code Review): Approved with one fix for ID collisions (addressed)
  • Harpo (Documentation): Updated MANUAL_TEST_PLAN_ISSUE_18.md
  • Zeppo (Testing): Created comprehensive 16-test manual testing plan

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Nov 26, 2025

Code Coverage Report

Current Coverage: 51.49%

Coverage Details (Summary)
Name                                                                                                                                   Coverage            
-------------------------------------------------------------------------------------------------------------------------------------- ------------------- 
MASPreferences.bundle                                                                                                                  0.00% (0/0)         
MacDown 3000.app                                                                                                                       57.90% (7271/12558) 
    /Users/runner/work/macdown3000/macdown3000/MacDown/Code/Preferences/MPHtmlPreferencesViewController.m                              0.00% (0/87)        
        MPPrismDefaultThemeName                                                                                                        0.00% (0/2)         
        -[MPHtmlPreferencesViewController viewIdentifier]                                                                              0.00% (0/3)         
        -[MPHtmlPreferencesViewController toolbarItemImage]                                                                            0.00% (0/3)         
        -[MPHtmlPreferencesViewController toolbarItemLabel]                                                                            0.00% (0/2)         
        -[MPHtmlPreferencesViewController viewWillAppear]                                                                              0.00% (0/4)         
        -[MPHtmlPreferencesViewController changeStylesheet:]                                                                           0.00% (0/7)         
        -[MPHtmlPreferencesViewController changeHighlightingTheme:]                                                                    0.00% (0/7)         
        -[MPHtmlPreferencesViewController invokeStylesheetFunction:]                                                                   0.00% (0/23)        
        -[MPHtmlPreferencesViewController loadStylesheets]                                                                             0.00% (0/13)        
        -[MPHtmlPreferencesViewController loadHighlightingThemes]                                                                      0.00% (0/23)        
    /Users/runner/work/macdown3000/macdown3000/MacDown/Code/Extension/DOMNode+Text.m                                                   0.00% (0/94)        
        -[NSString(WordCount) numberOfWords]                                                                                           0.00% (0/11)        
        __36-[NSString(WordCount) numberOfWords]_block_invoke                                                                          0.00% (0/3)         
        -[NSString(WordCount) lengthWithoutNewlines]                                                                                   0.00% (0/11)        
        __44-[NSString(WordCount) lengthWithoutNewlines]_block_invoke                                                                  0.00% (0/3)         
        -[NSString(WordCount) lengthWithoutWhitespacesAndNewlines]                                                                     0.00% (0/11)        
        __58-[NSString(WordCount) lengthWithoutWhitespacesAndNewlines]_block_invoke                                                    0.00% (0/3)         
        MPGetChildrenNodetextCount                                                                                                     0.00% (0/6)         
        MPGetNodeTextCount                                                                                                             0.00% (0/38)        
        -[DOMNode(Text) textCount]                                                                                                     0.00% (0/8)         
    /Users/runner/work/macdown3000/macdown3000/Dependency/peg-markdown-highlight/HGMarkdownHighlightingStyle.m                         87.69% (57/65)      
        +[HGMarkdownHighlightingStyle colorFromARGBColor:]                                                                             100.00% (6/6)       
        -[HGMarkdownHighlightingStyle initWithType:attributesToAdd:toRemove:fontTraitsToAdd:]                                          88.89% (8/9)        
        -[HGMarkdownHighlightingStyle initWithStyleAttributes:baseFont:]                                                               86.00% (43/50)      
    /Users/runner/work/macdown3000/macdown3000/MacDown/Code/Extension/hoedown_html_patch.c                                             88.37% (114/129)    
        hoedown_patch_render_blockcode                                                                                                 89.09% (49/55)      
        hoedown_patch_render_listitem                                                                                                  100.00% (46/46)     
        hoedown_patch_render_toc_header                                                                                                67.86% (19/28)      
    /Users/runner/work/macdown3000/macdown3000/MacDown/Code/Application/MPMainController.m                                             42.91% (106/247)    
        MPOpenBundledFile                                                                                                              96.67% (29/30)      
        __MPOpenBundledFile_block_invoke                                                                                               85.71% (6/7)        
        treat                                                                                                                          20.00% (6/30)       
        __treat_block_invoke                                                                                                           0.00% (0/3)         
        -[MPMainController applicationDidFinishLaunching:]                                                                             100.00% (6/6)       
        -[MPMainController openUrlSchemeAppleEvent:withReplyEvent:]                                                                    0.00% (0/45)        
        __59-[MPMainController openUrlSchemeAppleEvent:withReplyEvent:]_block_invoke                                                   0.00% (0/7)         
        -[MPMainController valueForKey:fromQueryItems:]                                                                                0.00% (0/5)         
        -[MPMainController preferences]                                                                                                100.00% (3/3)       
        -[MPMainController preferencesWindowController]                                                                                0.00% (0/18)        
        -[MPMainController showPreferencesWindow:]                                                                                     0.00% (0/2)         
        -[MPMainController showHelp:]                                                                                                  100.00% (3/3)       
        -[MPMainController showContributing:]                                                                                          100.00% (3/3)       
        -[MPMainController init]                                                                                                       90.91% (10/11)      
        -[MPMainController applicationShouldOpenUntitledFile:]                                                                         80.00% (4/5)        
        -[MPMainController applicationDidBecomeActive:]                                                                                100.00% (5/5)       

... (2383 more lines truncated)

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

schuyler added a commit that referenced this pull request Nov 26, 2025
- Add MPMermaidRenderingTests.m with 9 tests covering:
  - HTML structure preservation (code block class, source content)
  - Export includes mermaid scripts
  - Multiple diagram blocks
  - Error handling (malformed syntax, empty blocks)
  - Special characters and Unicode support
  - Mermaid disabled behavior

These tests verify the HTML output from MPRenderer. Actual SVG
rendering in JavaScript is tracked in issue #194 (Puppeteer tests).

Related to #193
schuyler added a commit that referenced this pull request Nov 26, 2025
- Add MPMermaidRenderingTests.m with 9 tests covering:
  - HTML structure preservation (code block class, source content)
  - Export includes mermaid scripts
  - Multiple diagram blocks
  - Error handling (malformed syntax, empty blocks)
  - Special characters and Unicode support
  - Mermaid disabled behavior

These tests verify the HTML output from MPRenderer. Actual SVG
rendering in JavaScript is tracked in issue #194 (Puppeteer tests).

Related to #193
claude added 3 commits January 8, 2026 16:11
- Upgrade Mermaid library from v8.4.3 to v11.12.1
- Update mermaid.init.js to use Promise-based API (Mermaid 10.x+)
- Add async/await pattern for rendering calls
- Add error handling with user-visible error messages
- Add securityLevel: 'loose' for cross-origin rendering support

The previous version (8.4.3 from 2020) had issues rendering flowchart
diagrams with the graph TD syntax. The new version should resolve
these rendering issues.

Related to #35
- Add unique ID generation to prevent collisions on re-renders
- Add check for mermaid library being loaded before initialization
- Add logLevel: 'error' to suppress verbose console logging
- Improve error message styling with padding and background

Related to #35
Updated MANUAL_TEST_PLAN_ISSUE_18.md to reference the new Mermaid 11.x
Promise-based API instead of the older Mermaid 8.0+ version.

Related to #35
@schuyler
Copy link
Copy Markdown
Owner Author

Merge Conflicts Resolved

The merge conflicts in this PR have been resolved. Since I couldn't push directly to the original branch, I've created a new PR with the resolved conflicts:

#262 - Contains all the changes from this PR plus the merge from main to resolve conflicts.

I recommend closing this PR in favor of #262.

schuyler added a commit that referenced this pull request Jan 10, 2026
#262)

## Summary

This PR supersedes #193 with merge conflicts resolved.

- Upgrade Mermaid library from v8.4.3 (2020) to v11.12.1
- Update mermaid.init.js to use Promise-based API (Mermaid 10.x+)
- Add async/await pattern for rendering with proper error handling
- Add unique ID generation to prevent collisions on document re-renders
- Add `securityLevel: 'loose'` and `logLevel: 'error'` to configuration
- Update documentation to reflect Mermaid 11.x

## Related Issue

Related to #35
Supersedes #193

## Manual Testing Plan

A comprehensive 16-test manual testing plan was created covering:
- Basic flowchart rendering (graph TD, LR, BT, RL)
- Decision nodes, subgraphs, styled nodes, long text labels
- Error handling for malformed syntax
- Multiple diagrams without ID collisions
- Live preview re-rendering
- Regression testing for gantt charts (issue #18)
- Regression testing for other diagram types (sequence, class, state,
pie)
- HTML export verification
- Unicode/emoji support
- Performance with large diagrams

## Review Notes

- **Groucho (Architect):** Identified mermaid.min.js and mermaid.init.js
as the key files
- **Chico (Code Review):** Approved with one fix for ID collisions
(addressed)
- **Harpo (Documentation):** Updated MANUAL_TEST_PLAN_ISSUE_18.md
- **Zeppo (Testing):** Created comprehensive 16-test manual testing plan

---------

Co-authored-by: Claude <noreply@anthropic.com>
@schuyler schuyler closed this Jan 10, 2026
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