Skip to content

Remove "forest.css" in Mermaid#1156

Closed
Gowa2017 wants to merge 1 commit intoMacDownApp:masterfrom
Gowa2017:iss1138_del_memriad_css_file
Closed

Remove "forest.css" in Mermaid#1156
Gowa2017 wants to merge 1 commit intoMacDownApp:masterfrom
Gowa2017:iss1138_del_memriad_css_file

Conversation

@Gowa2017
Copy link
Copy Markdown
Contributor

@Gowa2017 Gowa2017 commented Feb 24, 2020

在新版本的Mermaid中已经不需要。而加上这个css文件会影响graphviz里面node的样式


This is unnecessary in new Mermaid. This CSS file will affect node style in Graphviz.

Closes #1138

@FranklinYu
Copy link
Copy Markdown
Member

Both the method mermaidStylesheets and the file mermaid.forest.css were introduced in #865. The CSS file looks like a theme. According to unpkg, Mermaid team stop providing those theme files (including “forest”, “neutral”, and “dark”) since 7.0.11 release. Do you know what’s the current way to apply the forest theme?


你知道最新的Mermaid怎么改主题么?最好能保持使用Forest主题。

@FranklinYu FranklinYu changed the title 取消mermaid的forest.css 文件,在新版本的mermaid 中已经不需要。而加上这个css 文件会影响graphviz 里面… Remove "forest.css" in Mermaid Feb 26, 2020
@Gowa2017
Copy link
Copy Markdown
Contributor Author

Gowa2017 commented Feb 27, 2020

From the mermaid official document, http://mermaid-js.github.io/mermaid/#/mermaidAPI?id=mermaidapi-configuration-defaults, in version 8, we can use mermaid.initialize(config); to setting the mermaid, like

var config = {
    theme:'default',
    logLevel:'fatal',
    securityLevel:'strict',
    startOnLoad:true
}
mermaid.initialize(config);

theme can be http://mermaid-js.github.io/mermaid/#/mermaidAPI?id=theme.

@FranklinYu
Copy link
Copy Markdown
Member

That's nice. I would prefer to do all related things in a single PR.

  1. Remove the related part in MPRenderer.m (instead of only commenting it out). We can easily revert the change if we regret. That's the point for Git.
  2. Remove the Mermaid style sheet.
  3. Update MacDown/Resources/Extensions/mermaid.init.js accordingly.

@Gowa2017
Copy link
Copy Markdown
Contributor Author

#1165

Now, please close this issue

@Gowa2017 Gowa2017 closed this Mar 16, 2020
schuyler pushed a commit to schuyler/macdown3000 that referenced this pull request Nov 20, 2025
- 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
schuyler pushed a commit to schuyler/macdown3000 that referenced this pull request Nov 20, 2025
- 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
schuyler added a commit to schuyler/macdown3000 that referenced this pull request Nov 20, 2025
## 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.

---------

Co-authored-by: Claude <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Graphviz's filled and color attributes doesn't work

2 participants