sytsereitsma / mdbook-plantuml

mdBook preprocessor to render PlantUML diagrams to png images in the book output directory
MIT License
76 stars 14 forks source link

Use with local jar file #71

Closed danieleades closed 1 year ago

danieleades commented 1 year ago

I've been using this plugin for ages, but i've only ever used it with a plantuml server. I'm now trying to get it to work with a local plantuml.jar file.

for reference, I'm caching this locally in ./bin/plantuml.jar

my book.toml looks like this-

[preprocessor.plantuml]
plantuml-cmd = "java -jar ./bin/plantuml.jar"  # note i've also tried this with an absolute path
clickable-img = true
command = "mdbook-plantuml -l"

this fails with the following error (rendered in the output document) -

PlantUML rendering error: PlantUML did not generate an image, did you forget the @startuml, @enduml block (java -jar bin/plantuml.jar -tsvg -nometadata /tmp/.tmpNFhM35/914707e8761a630447989e1386d673d287db4480.puml)?

the logs look like this-

INFO - --- Started preprocessor ---
DEBUG - Shell conversion "/tmp/.tmpte02kx/914707e8761a630447989e1386d673d287db4480.puml" -> "/tmp/.tmpte02kx/914707e8761a630447989e1386d673d287db4480.svg"
DEBUG - Executing 'java -jar bin/plantuml.jar -tsvg -nometadata /tmp/.tmpte02kx/914707e8761a630447989e1386d673d287db4480.puml'
DEBUG - Working dir '${WORKSPACE}'
INFO - Successfully generated PlantUML diagrams.
DEBUG - stdout: 
DEBUG - stderr: 
ERROR - Failed to generate PlantUML diagram.

any ideas? This is on ubuntu, but the idea is to use a portable approach.

GeoffMurray commented 1 year ago

Interesting. I'm curious, what's in your actual plantuml code block? I'm seeing some interactions with other addons that produces some interesting results across the set.

danieleades commented 1 year ago

Interesting. I'm curious, what's in your actual plantuml code block? I'm seeing some interactions with other addons that produces some interesting results across the set.

I can reproduce it with any old plantuml block. Has anyone gotten this to work with a .jar file at all? Or only with the bundled .exe?

sytsereitsma commented 1 year ago

What version of mdbook-plantuml are you using? 0.8.0 and present master both work for me on Windows. Have not tried on Linux yet.

I noticed the ./ is stripped from the command in log line so you might want to try a workaround. You could try creating a shell script file wrapping the command (so create ./plantuml.sh):

#!/usr/bin/bash
java -jar ./bin/plantuml.jar $@

Don't forget chmod u+x plantuml.sh.

And in your book:

[preprocessor.plantuml]
plantuml-cmd = "plantuml.sh"
clickable-img = true
command = "mdbook-plantuml -l"

I have not tried the suggestion.

danieleades commented 1 year ago
plantuml-cmd = "java -jar ./bin/plantuml.jar"

I've played around with this a little more. It does indeed seem to depend on the contents of the block.

For example, the gantt chart is supported using a local jar file, but the work breakdown structure diagram is not.

I wonder if this has anything to do with the versions available for download? I'm using the source here - http://sourceforge.net/projects/plantuml/files/plantuml.1.2022.1.jar/download

update: it's weirder than that- WBS diagram is supported with local jar file, so long as the diagram doesn't have a title. The title is supported if using the remote server.

this works-

```plantuml
@startwbs
* Business Process Modelling WBS
** Launch the project
*** Complete Stakeholder Research
*** Initial Implementation Plan
** Design phase
*** Model of AsIs Processes Completed
**** Model of AsIs Processes Completed1
**** Model of AsIs Processes Completed2
*** Measure AsIs performance metrics
*** Identify Quick Wins
** Complete innovate phase
@endwbs

but this doesn't

````md
```plantuml
@startwbs Title
* Business Process Modelling WBS
** Launch the project
*** Complete Stakeholder Research
*** Initial Implementation Plan
** Design phase
*** Model of AsIs Processes Completed
**** Model of AsIs Processes Completed1
**** Model of AsIs Processes Completed2
*** Measure AsIs performance metrics
*** Identify Quick Wins
** Complete innovate phase
@endwbs
danieleades commented 1 year ago

i think this can be closed. This seems to be more about a disparity between the behaviour of the server and local plantuml instances