asciidoctor-diagram
asciidoctor-diagram copied to clipboard
Ability to set diagram output format (PNG vs SVG) via a document attribute
I want to have SVG output when built via Gradle, but when editing in IntelliJ I have to use PNG for preview mode to work. So I'm trying to do something like this:
:pumloutformat: png
ifeval::[{env}!=idea]
:pumloutformat: svg
endif::[]
plantuml::uml/entities.puml[format='{pumloutformat}', alt="Entity Relationships"]
I spent some time Googling and reading docs and can't see a way to do this (or equivalent.) If there is a way to do this, let's make it easier to find in the documentation or create an example, and if there isn't it sure would be helpful to create a way to do it.
I've added a test case for this. Attribute reference substitution in the format attribute seems to work correctly there. No idea why this isn't getting picked up. What behaviour are you seeing? Are you always getting PNG output or are you getting errors?
I'm getting errors in the Gradle build (.svg file not found). Note that I was using single quotes, not double quotes. I'll try again soon and give you updated info. Thanks for adding the test case!
Were you able to get this to work?
This issue made me think that perhaps it should be possible to set the output format globally. We have something similar in core for icons (icontype), so perhaps you can build on that terminology.
I wasn't able to get it to work. I reverted everything to PNG temporarily.
(Sorry for not providing additional info -- I do hope to return to this after the current crunch)
@mojavelinux I've added global format support in 642f17283834405088d6784e95d8b8dac62c17dc. Configurable per diagram type; overridable at the block level.
@pepijnve Perfect!
@msgilligan Does it work if you specify SVG as the format directly? I'm trying to understand exactly what doesn't work.
I think the problem is getting a configuration that works in Gradle and with the IntelliJ Asciidoctor plugin. We also use the Gradle script to build both HTML and PDF. So I think I removed SVG to make previews in IntelliJ work.
Can you share the gradle script (or an extract of it) that you're using? In the intellij plugin the attribute seems to be picked up correctly.
I'll have to create a clone of it, because it's a closed-source project. I'll try to do it this weekend. Sorry I can't do it sooner.
Starting from May 2018 this is no longer necessary in the IntelliJ plugin for Asciidoc: it forces the output to be PNG in the preview. No user interaction or additional attribute settings are necessary.
@msgilligan - I stumbled across this issue by accident, and thought this comment would be helpful for you. If you still experience problems in the preview, please open an issue on https://github.com/asciidoctor/asciidoctor-intellij-plugin.