pandoc-ext / diagram

Generate diagrams from embedded code; supports Mermaid, Dot/GraphViz, PlantUML, Asymptote, and TikZ.
MIT License
53 stars 9 forks source link

PLantUML regression ? #3

Closed lsignac closed 1 year ago

lsignac commented 1 year ago

This commit 97c6362115238051209de4d7f9bff81167c08b9e works like a charm for my use case (generation of PDF) : TikZ, mermaid, plantUML, asymptote.

But with the last commit : 81681438eb3d97d37dc69ecf5e901586a6f9cb7f plantUML does not work anymore :

java.lang.ClassNotFoundException: org.apache.batik.apps.rasterizer.SVGConverter
    at java.net.URLClassLoader.findClass(URLClassLoader.java:387)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:418)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:352)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:351)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Class.java:264)
    at net.sourceforge.plantuml.pdf.PdfConverter.convert(PdfConverter.java:61)
    at net.sourceforge.plantuml.UmlDiagram.exportDiagramInternalPdf(UmlDiagram.java:289)
    at net.sourceforge.plantuml.UmlDiagram.exportDiagramNow(UmlDiagram.java:138)
    at net.sourceforge.plantuml.AbstractPSystem.exportDiagram(AbstractPSystem.java:198)
    at net.sourceforge.plantuml.SourceStringReader.outputImage(SourceStringReader.java:165)
    at net.sourceforge.plantuml.Pipe.generateDiagram(Pipe.java:103)
    at net.sourceforge.plantuml.Pipe.managePipe(Pipe.java:94)
    at net.sourceforge.plantuml.Run.managePipe(Run.java:361)
    at net.sourceforge.plantuml.Run.main(Run.java:187)
Exception in thread "main" java.lang.UnsupportedOperationException
    at net.sourceforge.plantuml.pdf.PdfConverter.convert(PdfConverter.java:80)
    at net.sourceforge.plantuml.UmlDiagram.exportDiagramInternalPdf(UmlDiagram.java:289)
    at net.sourceforge.plantuml.UmlDiagram.exportDiagramNow(UmlDiagram.java:138)
    at net.sourceforge.plantuml.AbstractPSystem.exportDiagram(AbstractPSystem.java:198)
    at net.sourceforge.plantuml.SourceStringReader.outputImage(SourceStringReader.java:165)
    at net.sourceforge.plantuml.Pipe.generateDiagram(Pipe.java:103)
    at net.sourceforge.plantuml.Pipe.managePipe(Pipe.java:94)
    at net.sourceforge.plantuml.Run.managePipe(Run.java:361)
    at net.sourceforge.plantuml.Run.main(Run.java:187)
Lua warning: /home/signac/dev/pandoc/diagram.lua: Error running plantuml (error code 1): <no output>

The sample file used contains :

    Example usage:
    ```{.plantuml caption="This is an image, created by **PlantUML**." width=50%}
    @startuml
    Alice -> Bob: Authentication Request Bob --> Alice: Authentication Response
    Alice -> Bob: Another authentication Request Alice <-- Bob: another Response
    @enduml
    ```
tarleb commented 1 year ago

Thanks for the report. What's the exact pandoc command that you are using, and how did you install plantuml?

It looks like your installation is missing some plugins, so we'll have to make the filter more configurable in that regard.

lsignac commented 1 year ago

(Two shots message... separated by hline... the poblem is not related to diagram.lua but to plantuml as you guessed).

Test file : sample_plantuml.md

Pandoc comment used :

pandoc -t latex --lua-filter diagram_8168143.lua  --pdf-engine=xelatex sample_plantuml.md -o sample_plantuml.pdf

==> Produces the error above

or

pandoc -t latex --lua-filter diagram_97c6362.lua --pdf-engine=xelatex sample_plantuml.md -o sample_plantuml.pdf

==> Perfect result

The two filters correspond to the two commits mentioned above (I just downloaded the diagram.lua file and renamed it , is it OK ?)

plantuml has been installed by my package manager (Arch Linux) :

community/plantuml 1.2023.4-1 (10.1 MiB 10.9 MiB) (Installed)
    Component that allows to quickly write uml diagrams

The only difference between the two commits seed to be the format....


I tried a simpler test with just plantuml, and this test file :

@startuml
Alice -> Bob: test
@enduml

This command succeeds : cat plantuml_diagram.txt | plantuml -tsvg -pipe -charset UTF8 > out.svg But this one fails ( same error as above) : cat plantuml_diagram.txt | plantuml -tpdf -pipe -charset UTF8 > out.pdf

So I guess this is a plantuml problem, or more precisely a "plantuml on my personal computer problem".

Don't know if it's possible to force formats (final format, intermediary format) to tell diagram.lua that the tool (plantuml) should produce a svg file, and this svg file should be translated to a pdf file before if is included by pandoc. Something like this :

```{.plantuml caption="This is an image, created by **PlantUML**." width=50% engine_format="svg"  output_format="pdf"}
@startuml
Alice -> Bob: Authentication Request Bob --> Alice: Authentication Response
Alice -> Bob: Another authentication Request Alice <-- Bob: another Response
@enduml
```

I dont need this feature (I dont need plantuml...) but this kind of thing would (perhaps) solve my plantuml problem, and the mermaid problem we had to face so may be it could be a good design choice to struggle in the jungle of diagramming tools :)

tarleb commented 1 year ago

It's now possible to disable/enable certain image types for each engine. Please try this:

---
diagram:
  engine:
    plantuml:
      mime-types:
        application/pdf: false
        image/png: false
---