Skip to content

fix(export_to_docx): render Mermaid diagrams with <br> labels — v0.5.2#104

Merged
Fu-Jie merged 1 commit into
Fu-Jie:mainfrom
rbb-dev:fix/mermaid-br-labels
Jul 9, 2026
Merged

fix(export_to_docx): render Mermaid diagrams with <br> labels — v0.5.2#104
Fu-Jie merged 1 commit into
Fu-Jie:mainfrom
rbb-dev:fix/mermaid-br-labels

Conversation

@rbb-dev

@rbb-dev rbb-dev commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

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-diagram flowchart.htmlLabels is set to false, 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: false at the top level of mermaid.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 to export_to_word.py and export_to_word_cn.py.

Verified

Reproduced and fixed headlessly against Mermaid 11.12.2 with the plugin's exact config:

config foreignObject SVG loads rasterized pixels
current (flowchart.htmlLabels:false) yes fails 0 (blank)
+ top-level htmlLabels:false no ok 186,927

Also 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.

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.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

根据仓库样式指南(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
  1. 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)

@Fu-Jie
Fu-Jie merged commit b130968 into Fu-Jie:main Jul 9, 2026
1 check passed
Fu-Jie added a commit that referenced this pull request Jul 9, 2026
…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>
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