Repository navigation
Add optional Mermaid support via the Confluence mermaid-macro output - #1022
arturskavarada wants to merge 1 commit into
Conversation
|
There's no native renderer in confluence as far as I'm aware and only custom plugins. Is this using a custom plugin or has anything changed on confluence side? |
|
@mrueg |
590a2f4 to
27a3e16
Compare
|
Hi, just a gentle reminder about this PR. When you have a moment, I’d appreciate a review. Happy to make changes if needed. |
|
Checked out the branch: it merges cleanly into current master, and the Two small suggestions:
|
|
@flojon thanks for the review.
On your last point: |
|
Thanks @arturskavarada! Sorry, I've changed my mind on one of my earlier suggestions. Instead of documenting that Whether to take this feature is @mrueg's call. I'm just sharing my view. 1. Reject invalid flag combinations instead of documenting them
2. Make the macro key configurable, under a Your README notes that other plugins may use a different macro key. I'd add The prefix leaves room for other plugin types later, such as ones that take the diagram source as a parameter or an attachment, without changing these flags. I wouldn't implement those here, since each needs someone running that plugin to test it. |
|
@flojon thanks, both make sense.
One asymmetry worth flagging: the CLI rejects an explicitly-empty name, but Whether to take this feature is @mrueg call - happy to adjust either way. |
|
Thanks @arturskavarada, this is close. One blocker: with the CLI, Also, the |
|
@flojon Fixed:
|
|
Thanks! Looks good to me! |
|
Re-reviewed at
One optional nit: the pasted Thanks for the PR! |
|
@flojon thanks — also refreshed the pasted |
|
Hi, just a gentle reminder about this PR. When you have a moment, I’d appreciate a review. Happy to make changes if needed. |
|
Thanks for this. Review notes below; none of them are blockers on their own. Behavior
Tests Cleanup Note: I ran the tests locally (Windows). |
4af12a4 to
1ab256a
Compare
|
@flojon thanks, all eight addressed — and current master merged in. Behavior
Tests Cleanup Also merged current master (8 commits) and renormalised the Windows testdata checkout. CI may still need approval for the fork workflows. |
|
Thanks @arturskavarada, re-checked at Please change
Smaller
|
|
@flojon all of it is in, current master is merged, and the plugin check is Please change
Smaller
Current master was merged in (the CLI moved to commands, the docs to |
|
Re-checked at Worth changing
Tests and docs Minor: with the |
|
@flojon all eight points are in, on top of current master (the processFile Worth changing
Tests and docs The invalid
The "macro needs the feature" warning is emitted once per operation: once for a |
|
Review of 837d053, the commits since my last comment. These were checked by reading the code at that head; I did not build or run it, and I did not go through the test files and golden fixtures. The escaping holds: the macro name goes through
|
|
Follow-up on my comment above, against c1e3e9d, which landed after I wrote it.
|
|
@flojon thanks for the re-check. On 2: deliberate, and stated in the flag usage,
The PR is up to date with master and clean to merge. |
de815b3 to
d0ff8bc
Compare
|
@flojon @mrueg v17.0.0 is out, so I've ported the branch to it. The PR is now What changed is where the feature plugs in, not what it does:
CI needs its workflows approved again for the new head. |
d0ff8bc to
57fcf26
Compare
|
Thanks @arturskavarada, and thanks for your patience through all the review rounds. Everything has been addressed, the plugin check is done, and the port to v17 looks clean from where I sit. I'm only an outside reader here, so the call is @mrueg's. @mrueg, whenever you have a moment, could you say whether this is something you'd like in core? Even a short "not for now" would help Artur know where it stands. |
Ported to v17: MermaidOutput is its own type (png, svg or macro) rather than an imageformat.Format shared with d2 and math, because the macro is not an image; MermaidMacroName lives in markdown.Options and RenderingConfig, and the renderer normalises it where the DiagramConfig is consumed. The macro publishes the fence's source as a plain-text macro, adds no attachment, and makes --mermaid-engine/--mermaid-scale unused and --mermaid-bundle contradictory; those are refused or warned about in validate and the CLI, and no engine is created for a macro run. Golden fixtures, the ]]> and title tests, the name tests and the CLI/env/TOML tests are ported; the README help block and docs/formatting.md describe the output.
57fcf26 to
eefa0ff
Compare
|
@mrueg gentle nudge - the feature is ported to v17, flojon has signed off, and |
What
Adds a third value to
--mermaid-output:macro. With themermaidfeatureenabled, a ```mermaid block gets published as the Confluence macro
mermaid-macroinstead of an image rendered by mark:<ac:structured-macro ac:name="mermaid-macro">ac:plain-text-body<![CDATA[flowchart TD
A[Start] --> B[End]]]></ac:plain-text-body></ac:structured-macro>
The diagram source goes into the macro as-is, and the drawing itself is done
by the Mermaid macro installed on the instance. That means the instance needs
to have one installed - otherwise nothing renders.
Why
We run mark against a Confluence that already has the Mermaid macro, so going
through mark's own Chrome/merman pipeline is pure overhead: images,
attachments, checksums, none of it is needed.
I picked a new value on
--mermaid-outputinstead of a separate feature flagbecause
mermaidalready has an output flag (png/svg), so a third channelfits right in. The
plantumlfeature took the feature-flag route only becausethere was no output flag to extend.
Changes
renderer/fencedcodeblock.go- whenmermaidis on and--mermaid-output=macro, the block renders through the macro template.The check sits before the image branch, so
macrowins overpng/svg.stdlib/stdlib.go- newac:mermaid-macrotemplate, diagram source in aplain-text body CDATA.
util/flags.goandmark.go-macrois now accepted and validated onthe CLI and in the public Config path. Usage text updated.
types/types.go-MermaidOutputcomment now mentions all three values.markdown/mermaid_output_test.go(macro output, drop-h1, fallbackto a plain code block without the
mermaidfeature) andutil/cli_test.go(flag validation).Not changed
png/svg;--mermaid-bundleand the scale flagsare untouched.
--featuressemantics are the same - the macro output still needsmermaidto be enabled.