Closed jcravi closed 4 years ago
Yes... maybe interesting and I understand the use case. One solution maybe to define in markdown a simple diagram with an include statement (already supported by PlantUML, no code change); this should work when using local PlantUML binary. When using a PlantUML service is not so easy: maybe we could use an option to set the source filename, which will be resolved relative to markdown file path.
Here's my initial take. https://github.com/mikitex70/plantuml-markdown/pull/43
I was not sure how to get the location of the current file we are dealing with. Also, I was not able to figure out how to first check source
and base_dir
.
Thanks for your pull request.
I've made a small change to let code a bit more readable.
I've also added a test to check the diagram inclusion.
The code is in the develop
branch: give it a try, so I can release it in the master
branch.
Thanks for the quick turnaround! Will test it out!
Okay, it works. I had to change how I was passing the source value. Initially I was passing source="/dir/abc.puml"
, since I was doing string concatenation. I changed it to source="dir/abc.puml"
and it worked correctly. I do not know if this is common knowledge or it needs to be mentioned in the docs explicitly.
I've used a os.path.join
to concatenate path and source, so it works also on Windows.
The documentation says that base_dir
is a directory where to search files to include, so I think it is sufficiently clear.
But I'm open to suggestions.
Oh, I'm on board with your change. Sorry if that wasn't clear. I was just asking if it makes sense to add any documentation to specify that the source=
value follows certain rules.
To be precise, the reason I am mentioning this is that when I used source="/dir/abc.puml"
and base_dir
of .
,
os.path.join('.','/dir/abc.puml')
gives the output as /dir/abc.puml
, and not ./dir/abc.puml
, which is what I expected.
Yes, you are right, but I think gives you more flexibility:
source="dir/abc.puml"
then the file is relative to the current working directory (usually the markdown sources directory, but it would be great if were relative to the markdown source)source="/dir/abc.puml"
then the file path is absolute, giving the possibility to access a file outside document tree (less portable, but maybe usefull).If simply concatenating strings, it would be impossible (with the original code) to access files outside markdown sources directory.
I've released your contribution in version 3.3.0. Thanks for your work.
You are welcome. Thanks for the library and the fast turnaround!
Is is possible to include a source
file but also not ignore the inline code?
I'm trying to locally include a theme but PlantUML !include
doesn't work with the remote server option.
Most editors like Intellij and vs code have plugins for locally rendering .puml files, side by side with the code. This allows creating the plantuml diagram while viewing the output simultaneously.
Would you be open to supporting an additional parameter that can take in a
source
? I sort of got this working locally, but I am not too familiar with Python, so the code is very hacky...