Commit 7ac3e8c
fix: inject inline color on foreignObject HTML to fix EPUB Mermaid text
Root cause: EPUB readers do NOT apply SVG <style> scoped rules to HTML
elements inside <foreignObject>. Mermaid renders node/edge labels as
<div>/<span>/<p> in foreignObject with NO inline color — so text color
is inherited from the EPUB reader's CSS, which can be white/invisible.
No amount of themeVariables or --theme flags can fix this because the
problem is in how EPUB readers scope SVG CSS, not in mmdc's rendering.
Fix: post-process the SVG in renderMermaidToSvg() to inject explicit
style="color:THEME.textColor" on every <div>, <span>, and <p>
inside foreignObject. Also injects fill:nodeBg on .label-container
shapes so the node background is explicit rather than CSS-dependent.
Verified: all 10 spans in test SVG now carry style="color:#2C2C2C".
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>1 parent eb6cc1f commit 7ac3e8c
1 file changed
Lines changed: 30 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
124 | 124 | | |
125 | 125 | | |
126 | 126 | | |
127 | | - | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
128 | 157 | | |
129 | 158 | | |
130 | 159 | | |
| |||
0 commit comments