vscode-markdown-preview-enhanced
vscode-markdown-preview-enhanced copied to clipboard
plantuml with ditaa not working
plantuml support syntax like
@startuml
ditaa
+--------+ +-------+ +-------+
| +---+ ditaa +--> | |
| Text | +-------+ |diagram|
|Document| |!magic!| | |
| {d}| | | | |
+---+----+ +-------+ +-------+
: ^
| Lots of work |
+-------------------------+
@enduml
or
@startditaa
+---------+ /--------\ +-------+
| cBLU +--+cAAA +---+Version|
| | | Data | | V3 |
| +----+ | Base | |cRED{d}|
| |cPNK| | {s}| +-------+
| | | \---+----/
+----+----+
@endditaa
but not working in markdown-preview-enhanced's preview window, it hang forever.
I tested manually in terminal with plantuml.jar in markdown-preview-enhanced's dependencies directroy, it not hang.
Whether the problem has been solved?
When inserting a similar example as on the top:
@startditaa
+--------+ +-------+ +-------+
| +---+ ditaa +-->| |
| Text | +-------+ |diagram|
|Document| |!magic!| | |
| | | | | |
+---+----+ +-------+ +-------+
: ^
| Lots of work |
+------------------------+
@endditaa
I get the following gibberish added to my document:
I guess that other plantuml diagrams generate SVG images but ditaa can't so plantuml with ditaa doesn't work.
In https://plantuml.com/en/ditaa:
On PlantUML, only PNG generation is supported.
It seems that the workaround is to use Kroki.
In 0.7.0 Release:
🗑 Removed
ditaa.jar
file from themume
project. Also removed the native support of rendering ditaa diagrams. But you can now use Kroki to render theditaa
diagrams. ...🎉 Added Kroki support to render diagrams. This is a beta feature. For example:
```ditaa {kroki=true} +--------+ +-------+ +-------+ | | --+ ditaa +--> | | | Text | +-------+ |diagram| |Document| |!magic!| | | | {d}| | | | | +---+----+ +-------+ +-------+ : ^ | Lots of work | +-------------------------+ ```
I think that either one of the following will fix it.
- Plantuml with ditaa supports SVG.
- Markdown preview enhanced captures PNG in addition to SVG.
As for the former, though ditaa 0.11 supports SVG, plantuml drops the feature. See https://github.com/plantuml/plantuml/issues/389
As for the latter, in https://github.com/shd101wyy/crossnote/blob/0.9.9/src/renderers/puml.ts#L62-L82, markdown preview enhanced captures output of plantuml process and detects the end by checking </svg>
. I think that both SVG and PNG can be captured there as follows:
- Read the first 4 bytes.
- If it is
<svg
, read the rest as string until</svg>
as the present code does. - If it is 137, 80, 78, 71 (4 bytes in decimal), read rest chunks as binary until an
IEND
chunk. See https://www.w3.org/TR/PNG-Structure.html
I don't know what to do after that.