vscode-markdown-preview-enhanced icon indicating copy to clipboard operation
vscode-markdown-preview-enhanced copied to clipboard

plantuml with ditaa not working

Open sandro-qiang opened this issue 4 years ago • 4 comments

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.

sandro-qiang avatar Jan 27 '21 10:01 sandro-qiang

Whether the problem has been solved?

yuruotong1 avatar Jul 08 '21 06:07 yuruotong1

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: image

shelling21 avatar Apr 30 '24 09:04 shelling21

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 the mume project. Also removed the native support of rendering ditaa diagrams. But you can now use Kroki to render the ditaa 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      |
        +-------------------------+
    ```
    

kubo avatar Jun 23 '24 23:06 kubo

I think that either one of the following will fix it.

  1. Plantuml with ditaa supports SVG.
  2. 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.

kubo avatar Jun 26 '24 15:06 kubo