asciidoctor / asciidoctor-intellij-plugin

AsciiDoc plugin for products on the IntelliJ platform (IDEA, RubyMine, etc)
https://intellij-asciidoc-plugin.ahus1.de/
Apache License 2.0
342 stars 146 forks source link

ADOC preview not working properly with PUML -> !include: #1459

Closed alexps99 closed 6 months ago

alexps99 commented 8 months ago

Info

IntelliJ IDEA 2023.2.2 (Community Edition) Build #IC-232.9921.47, built on September 12, 2023 Runtime version: 17.0.8+7-b1000.22 amd64

Adoc v. 0.40.7

PlantUML Integration v. 7.3.0-IJ2023.2

Disclaimer

I'm not totally sure if i should address the problem here but i m going to explain it.

Explanation and request

I read in the Plant UML documentation that it is a common practice to create a file containing many components. Then, you can remove all and restore selectively. This allows you to declare the components, their parts, and relationships just once.

I tried to implement this strategy with my diagrams, but I encountered an issue with the plugin I'm using. Specifically, the "remove *" command didn't work as expected, so, I decided to use tags instead. I noticed that this approach worked well within Plant UML.

However, when I integrated these diagrams into my AsciiDoc document, I noticed that they weren't displaying correctly. I suspect that the plugin I'm using might not handle the inclusion of external components properly, at least when they are removed and restored.

My question is whether this behavior is due to limitations in the plugin itself. And if that's the case, I'd like to get a fix so i can use this working strategy.

Source Plant UML files

(Showing the PUML plugin preview)

imagen imagen

Result

(Showing the ADOC plugin preview)

imagen

Expected

(I cheated to get this result by not getting C1 by include)

imagen

Zip of the files used

test.zip

ahus1 commented 6 months ago

I was able to trace this down to the following situation: Looking the shape of the "C" in the preview, it seems that Kroki is used to generate the preview.

Kroki's Asciidoctor Ruby extension (which is used in this plugin) doesn't support the !include yet. Technically it submits only the source of the included file to the rendering server and returns the image. It seems that it just drops it when rendering it remotely.

Kroki's Asciidoctor JavaScript extension supports it by pre-processing the files and embedding the contents locally.

As this AsciiDoc plugin uses Asciidoctor Ruby, it can't use Kroki's JavaScript implementation, so it is bound to the Ruby implementation.

When you disable Kroki in the AsciiDoc plugin for IntelliJ settings and instead use the Asciidoctor Diagram of the plugin, it will work as expected - but only if you make the diagram identifier unique (the AsciiDoc plugin for IntelliJ will warn you about that) as the contents of the second diagram will otherwise overwrite the contents of the first diagram as the would use the same file name. See below for a fixed version:

[plantuml,exp-ref-erd1,svg]
----
include::test.puml[]
----

Diagram 2

[plantuml,exp-ref-erd2,svg]
----
include::test2.puml[]
----

To to summarize: Use the Asciidoctor Diagram extension when using a local preview when using !include... in PlantUML diagrams when using this plugin.

In additional to that, you might want to raise an issue with https://github.com/asciidoctor/asciidoctor-kroki and/or provide a pull request to enhance the Ruby extension to support preprocessing diagram content. / cc: @ggrossetie