Closed enikao closed 2 years ago
Thanks for reporting this, I was able to reproduce the issue locally.
As I'm short on time, a fix might take some time (>1 week). For now I can offer you a workaround using ifdef like the following:
= Inline Diagram Example
:plantuml-opts: opts="inline"
// workaround: set no opts when running IntelliJ live preview
ifdef::env-idea[:plantuml-opts: ]
[plantuml, format=svg, {plantuml-opts}]
----
skinparam Legend {
BackgroundColor transparent
BorderColor transparent
FontName "Noto Serif", "DejaVu Serif", serif
FontSize 17
}
legend
Root
|_ Element 1
|_ Element 1.1
|_ Element 1.2
|_ Element 2
|_ Element 2.1
end legend
----
I finally found the time to dive to the source of Asciidoctor Diagram and to find the source of this:
Your original code snippet used opts="inline"
- this is the correct syntax to inline a SVG image. This also works in some cases when using Asciidoctor Diagram, but not in cases where an output folder for temporarily created images is used (as with this plugin).
To specify a SVG type with Asciidoctor Diagram, use svg-type="inline"
instead as stated in the docs: https://docs.asciidoctor.org/diagram-extension/latest/#shared-attributes
Unfortunately, when using Kroki to render diagrams, it needs to be opts="inline"
.
Consider adding both attributes to make it work in both cases. I now remember that I added this to the docs some time ago: https://intellij-asciidoc-plugin.ahus1.de/docs/users-guide/features/preview/diagrams.html#interative-vs-inlined
Please let me know if this solves your problem. Feel free to discuss how the situation can be improved for future users trying to accomplish the same (be it workarounds, changes in Asciidoctor Diagram, hints in the IDE, etc).
Your original code snippet used opts="inline" - this is the correct syntax to inline a SVG image. This also works in some cases when using Asciidoctor Diagram, but not in cases where an output folder for temporarily created images is used (as with this plugin).
This doesn't seem right (not saying you're wrong, just questioning the behavior itself). If opts=inline
is specified, it should always create an embedded SVG (assuming the output format for the diagram is SVG). If that's not happening, then the extensions are not conforming the the contract in Asciidoctor core.
@mojavelinux - I've created an upstream issue for this to see if the behavior could be changed: https://github.com/asciidoctor/asciidoctor-diagram/issues/368
I'm closing this issue for now until an action item for the plugin appears.
Observed vs. expected behavior
I'm using plantuml SVG with inline option, as in
[plantuml, format=svg, opts="inline"]
.Expected: Render the diagram. It works in exported HTML:
(I'm (mis-)using diagram to render a hierarchical tree, as described in my blog.)
Actual: Diagram is missing, Problems tab shows "<stdin>: SVG does not exist or cannot be read: path/to/folder/containing/adoc/file/diag-86be25546dbb3a09b281c7da49534bcb.svg"
Steps to reproduce
Paste this content in an .adoc file in IntelliJ:
Environment
Plugin Version: 0.33.3
IntelliJ Details: IntelliJ IDEA 2021.1.3 (Ultimate Edition) Build #IU-211.7628.21, built on June 30, 2021 Runtime version: 11.0.11+9-b1341.60 amd64 VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o. Windows 10 10.0 GC: ParNew, ConcurrentMarkSweep Memory: 1959M Cores: 8 Non-Bundled Plugins: org.jetbrains.kotlin (211-1.5.10-release-909-IJ7142.45), org.asciidoctor.intellij.asciidoc (0.33.3) Kotlin: 211-1.5.10-release-909-IJ7142.45