asciidoctor / asciidoctor-diagram

:left_right_arrow: Asciidoctor diagram extension, with support for AsciiToSVG, BlockDiag (BlockDiag, SeqDiag, ActDiag, NwDiag), Ditaa, Erd, GraphViz, Mermaid, Msc, PlantUML, Shaape, SvgBob, Syntrax, UMLet, Vega, Vega-Lite and WaveDrom.
http://asciidoctor.org
MIT License
432 stars 106 forks source link

Positional target attribute output same filename #305

Closed edl7878 closed 3 years ago

edl7878 commented 3 years ago
[plantuml,,svg]
.Sequence diagram
----
actor Foo1
boundary Foo2
control Foo3
entity Foo4
database Foo5
collections Foo6
Foo1 -> Foo2 : To boundary
Foo1 -> Foo3 : To control
Foo1 -> Foo4 : To entity
Foo1 -> Foo5 : To database
Foo1 -> Foo6 : To collections
----

[plantuml,,svg]
----
@startmindmap
skinparam monochrome true
+ OS
++ Ubuntu
+++ Linux Mint
+++ Kubuntu
+++ Lubuntu
+++ KDE Neon
++ LMDE
++ SolydXK
++ SteamOS
++ Raspbian
-- Windows 95
-- Windows 98
-- Windows NT
--- Windows 8
--- Windows 10
@endmindmap
----

[plantuml,,svg]
----
actor Foo1
boundary Foo2
control Foo3
entity Foo4
database Foo5
collections Foo6
Foo1 -> Foo2 : To boundary
Foo1 -> Foo3 : To control
Foo1 -> Foo4 : To entity
Foo1 -> Foo5 : To database
Foo1 -> Foo6 : To collections
----

the upper asciidoctor code will output the same image which is the last diagram when use asciidoctor binary as render, while privewing with asciidoctor.js and kroki, the diagrams outputted individually.

evinonment: hugo + asciidoctor binary + asciidoctor-diagram

pepijnve commented 3 years ago

I can reproduce this locally, but I don't think there's much I can do about this. The positional attributes are actually not mapped the way you think they are. As far as I can tell the parsing of attribute lists will not allow you to skip positional attributes. What the extension actually receives is

1 => "plantuml"
2 => "svg"

while you're expecting it to receive

1 => "plantuml"
2 => nil
3 => "svg"

The consequence is that asciidoctor-diagram is receiving svg as target value twice and the target of the block is used to derive the output filename.

The simplest workaround for this is to use format="svg" instead or set the format at the document level using :plantuml-format: svg.

pepijnve commented 3 years ago

@mojavelinux is there a difference between asciidoctor and asciidoctor.js in how it parses an attribute list like [plantuml,,svg] when it comes to handling the middle empty attribute?

edl7878 commented 3 years ago

@pepijnve Got it. Thanks.

mojavelinux commented 3 years ago

@pepijnve Not to my knowledge. It's the same code. The variation probably comes from the kroki extension itself.

mojavelinux commented 3 years ago

This actually looks like a parsing bug. The parser allows the first position to be blank (e.g., ,ruby), but not any other position. It should retain the positional offset so it's consistent with the number of delimiters. Please file an issue in core.

mojavelinux commented 3 years ago

https://github.com/asciidoctor/asciidoctor/issues/3813

pepijnve commented 3 years ago

Thanks for logging this @mojavelinux. @edl7878 once the asciidoctor issue has been resolved the workaround(s) I mentioned will no longer be necessary.