mikitex70 / plantuml-markdown

PlantUML plugin for Python-Markdown
BSD 2-Clause "Simplified" License
192 stars 55 forks source link

Confused with how to use !include/source #49

Closed STEELBADGE closed 3 years ago

STEELBADGE commented 3 years ago

First of all thanks for this wonderful plugin!

I am trying to include a diagram within another diagram which is standard plantuml syntax like so on a remote plantuml server:

```plantuml
@startuml
title this contains only B and D
!includesub file1.puml!BASIC
@enduml

Now say my markdown lives in /home/user/doc/hello.md and my plantuml file lives under /home/user/doc/file1.puml

What should my base_dir be set to?

because no matter what I do I can't get it to render

I looked at the code and I see you do something with "source" which isn't part of the plantuml syntax but I feel like I am meant to sure it like this:

@startuml
title this contains only B and D
!includesub file1.puml!BASIC
@enduml

If you could help me then I could add some documentation so one else has issues with this.

mikitex70 commented 3 years ago

The default directory where PlantUML searches for file to include (if they use relative path) can be defined passing the option -Dplantuml.include.path to JVM. So, if for launching plantuml you used a script similar to the one mentioned in the README.md, you can set the environment variable PLANTUML_JAVAOPTS to something like -Dplantuml.include.path=$HOME/doc, where.$HOME/doc is the directory in your home which holds the files to include. Using the example from the README.md, you should use something like:

export PLANTUML_JAVAOPTS="-Dplantuml.include.path=$HOME/doc"
markdown_py -x plantuml_markdown $HOME/doc/hello.md > out.html

If you are using a plantuml server, you can try to set the PLANTUML_JAVAOPTS or the _JAVA_OPTIONS variable in the server before starting the service, or you can use a recent plantuml, which supports includes via http and place included files in a web server.

See also the README for the plantuml server: it seems that includes are disabled by default, but they can be enable by setting the environment variable ALLOW_PLANTUML_INCLUDE to true. Be aware of plantuml server security issues, like #122.

STEELBADGE commented 3 years ago

Thank you - I resolved my issue with your helpful advise above.