fix(export_to_docx): render Mermaid diagrams with <br> labels — v0.5.2#104
Conversation
Mermaid 11 emits <foreignObject> HTML labels despite the per-diagram flowchart.htmlLabels:false setting, and a label containing an unclosed <br> makes the rendered SVG invalid XML — so it fails to load for the SVG→PNG rasterization step and the diagram exports as a blank square. Set htmlLabels:false at the top level of mermaid.initialize, which suppresses foreignObject entirely; labels then render as native SVG <text> and the diagram rasterizes correctly.
There was a problem hiding this comment.
Code Review
This pull request updates the Export to Word (Enhanced) plugin to version 0.5.2, which resolves an issue where Mermaid diagrams containing
labels render as blank squares by setting htmlLabels: false at the top level of mermaid.initialize. The reviewer correctly noted that this version bump requires updating several documentation files under the docs/ directory to comply with the repository's Documentation Sync style guide rule.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
| author_url: https://github.com/Fu-Jie/openwebui-extensions | ||
| funding_url: https://github.com/open-webui | ||
| version: 0.5.1 | ||
| version: 0.5.2 |
There was a problem hiding this comment.
根据仓库样式指南(Repository Style Guide)中的 Documentation Sync 规则,当修改插件版本时,必须同步更新以下所有文档,否则 PR 检查会失败:\n\n1. docs/plugins/actions/export_to_docx.md(或对应的镜像 README)\n2. docs/plugins/actions/export_to_docx.zh.md(或对应的镜像 README_CN)\n3. docs/plugins/actions/index.md(版本徽章)\n4. docs/plugins/actions/index.zh.md(版本徽章)\n\n当前 PR 中未包含对这些 docs/ 目录下文件的更新,请务必同步修改以确保 PR 检查顺利通过。
References
- Must update ALL of these or the PR check fails: plugins/{type}/{name}/{name}.py — version in docstring, plugins/{type}/{name}/README.md — version, What's New, plugins/{type}/{name}/README_CN.md — same, docs/plugins/{type}/{name}.md — mirror README, docs/plugins/{type}/{name}.zh.md — mirror README_CN, docs/plugins/{type}/index.md — version badge, docs/plugins/{type}/index.zh.md — version badge (link)
…105) The contributor-attribution step injected a "## New Contributors" section for ANY external contributor, not just first-time ones. first_time only changed the bullet wording ("made their first contribution" vs "contributed in"), but the section header always said "New Contributors" — so returning contributors (e.g. @rbb-dev in #104, who already had #103 merged) were mislabeled as new. Now the section is only emitted when CONTRIBUTOR_FIRST_TIME=true. Returning contributors are already credited via their PR in the changelog and don't need a separate callout. Also fixed the already-published release-2026.07.09 body by removing the incorrect "New Contributors" section. Co-authored-by: Fu-Jie <Fu-Jie@users.noreply.github.com>
Summary
Mermaid diagrams whose node or edge labels contain
<br>line breaks exported as a blank square.Mermaid 11 emits
<foreignObject>HTML labels even when the per-diagramflowchart.htmlLabelsis set tofalse, and an unclosed<br>inside that HTML makes the rendered SVG invalid XML. The plugin rasterizes each diagram by loading its SVG into an<img>and drawing it onto a<canvas>— the invalid SVG fails to load (img.onerror), so nothing is drawn (a correctly-sized but blank square).Fix
Set
htmlLabels: falseat the top level ofmermaid.initialize(the per-diagram flag alone is ignored by Mermaid 11). This suppresses<foreignObject>entirely: labels render as native SVG<text>, the SVG stays valid XML, and the diagram rasterizes correctly. Applied toexport_to_word.pyandexport_to_word_cn.py.Verified
Reproduced and fixed headlessly against Mermaid 11.12.2 with the plugin's exact config:
flowchart.htmlLabels:false)htmlLabels:falseAlso confirmed on a real multi-diagram export (flowchart + pie + xychart + timeline): every diagram renders as a valid,
foreignObject-free, PNG-backed SVG.Compatibility
No dependency or requirement changes. Still requires Open WebUI ≥ 0.10.2.