Repository navigation
Draw Mermaid diagrams as pictures in generated Word, PDF and PowerPoint files - #1989
Merged
Paul Lizer (paullizer) merged 3 commits intoNov 30, 2026
Conversation
…nt files Files the assistant generates showed each Mermaid diagram as its raw code. Word and PDF reports now swap each top-level mermaid fence for a PNG drawn by the server's Chromium renderer, with its title as a caption. Slide decks gain a diagram shape that becomes a picture fitted to its box. A diagram that cannot be drawn keeps its code and the file is still produced. Version 0.261.497. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…into claude/diagram-png-rendering-issue-bba501 # Conflicts: # application/single_app/config.py
Paul Lizer (paullizer)
merged commit Nov 30, 2026
fa14902
into
microsoft:Development
20 of 22 checks passed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
When the assistant creates a Word document, PDF, or PowerPoint deck that includes a flowchart or another Mermaid diagram, the file shows the diagram's raw Mermaid code instead of a picture. This was reported from the V2 interface. Exporting an existing chat message was not affected, because that path already draws diagrams.
Cause
Generated files are rendered by
functions_office_file_renderers.pyfrom prepared content, and nothing on that path turned a diagram into a picture:markdown2turned each```mermaidfence into an ordinary code block.Fix
Diagrams are drawn with the server's existing Chromium renderer (
functions_mermaid_server_render.py, the same one the message export uses).PreparedReporthas a newdiagramsmap (normalized source to PNG). Each top-level fence that has a picture becomes the sameexport-inline-diagramfigure the message export uses, with the diagram's title as a caption. The report's text is unchanged, so the character-count completeness check still holds. Diagrams count toward the image limits and use at most half the pixel budget; a diagram over the budget stays code instead of failing the file.diagramslide shape (box,source,alt). At render time it becomes a picture fitted to its box. Validation before the deck is saved checks structure and geometry only, without starting Chromium.Version 0.261.498. Fix doc:
docs/explanation/fixes/GENERATED_OFFICE_FILE_DIAGRAM_PNG_FIX.md.Testing
functional_tests/test_office_diagram_png_rendering.py: 13 tests, all passing. They use synthetic PNGs, so they don't need a browser.test_generated_file_office_bridge,test_office_file_renderers,test_document_transform_rendering,test_pptx_render_file_mitigation,test_orchestration_services,test_orchestration_deliverables,test_orchestration_compose_output_retry,test_orchestration_dependency_runtime,test_orchestration_export_integration,test_orchestration_tabular_reconciliation,test_orchestration_v2_plan_backend, andtest_workflow_merge_task.Not covered
_render_docx_file_export) writes plain paragraphs without converting Markdown, so it is unchanged.🤖 Generated with Claude Code