shd101wyy / vscode-markdown-preview-enhanced

One of the "BEST" markdown preview extensions for Visual Studio Code
https://shd101wyy.github.io/markdown-preview-enhanced
Other
1.4k stars 171 forks source link

plantuml with ditaa not working #453

Open sandro-qiang opened 3 years ago

sandro-qiang commented 3 years ago

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.

yuruotong1 commented 2 years ago

Whether the problem has been solved?

shelling21 commented 2 months ago

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

kubo commented 6 days ago

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 commented 4 days ago

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:

I don't know what to do after that.