sytsereitsma / mdbook-plantuml

mdBook preprocessor to render PlantUML diagrams to png images in the book output directory

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Add support for outputting text diagrams via -txt flag

DhruvDh opened this issue · comments

(I tried to look through the code and try and see if I could implement it myself but I am kind of lost)

PlantUML can output ascii sequence diagrams if given the -txt flag. Support for the same would be much appreciated.

I can add this as an option to the PlantUML code block. Something like this:

```plantuml-txt
@startuml
A --|> B
@enduml
```

Would render:

,-.
|A|
|-|
|-|
`-'
 | 
 | 
,-.
|B|
|-|
|-|
`-'

That way you'd still be able to generate regular images in other PlantUML code sections.
Would that work for you?

Which part did you get lost/did you not understand? This is my first rust project, so there are parts that could probably be written in another, easier to understand, way. Any pointers are appreciated. I will be adding developer docs soon.

Sytse

Hey, sorry for the late reply. I ended up writing a hacky dirty python script that does basically what you described. It works well enough, but diagrams look bad on mobile because they usually don't fit in the viewport and and you need to scroll horizontally to see all of it which makes for a very bad experience.

PlantUML also only has limited support for ASCII diagrams, so it's probably best if this is not implemented. I would recommend this issue be closed unless you think this would be a nice to have.

I probably implement a generic version of what I suggested, so users are free to select the image output they want.

Fixed with #24
Usage:

```plantuml,format=txt
@startuml
C --> D
@enduml
```

Note that the PlantUML does not support all formats.