asciidoctor / asciidoctor-vscode

AsciiDoc support for Visual Studio Code using Asciidoctor
Other
331 stars 97 forks source link

Plantuml preview with local kroki of the diagram with target doesn't work #818

Closed agrexgh closed 10 months ago

agrexgh commented 11 months ago

Please provide details about:

Please share relevant sample content. Or better yet, provide a link to a minimal reproducible example.

How to reproduce 1.docker run --rm -it -p 8000:8000 yuzutech/kroki 2.Set below to settings.json

  "asciidoc.preview.asciidoctorAttributes": {
      "kroki-server-url": "http://localhost:8000",
      "allow-uri-read": true,
      "kroki-fetch-diagram": true
  }
  1. Open the adoc file. The content is below.

    = test
    
    [plantuml]
    .without target
    ----
    @startuml sample
    bob -> alice : hello
    @enduml
    ----
    
    [plantuml,foo/bar]
    .with target
    ----
    @startuml sample
    marie -> john : good evening
    @enduml
    ----

We'll also need your system information (get it under "Help" -> "About" in VS Code). Share the installed extension version (Ctrl + Shift + X or Cmd + Shift + X on macOS). v3.1.7

Provide steps to reproduce the issue and, if applicable, add screenshots to make it easier to understand. There is also extension logs where errors show up. Go to the Command Palette and select the option 'Developer: Open Extension Logs Folder'. The screenshot shows that vs code doesn't show the Figure "with target" 's preview but the Figure "without target". previewOfDiagramWithTargetDoesnotWorkscreenshot

Look among the logs there for errors.

ggrossetie commented 10 months ago

:kroki-fetch-diagram: is not supported when running Asciidoctor Kroki in VS Code. The reason is that unxhr does not work in VS Code: https://github.com/ggrossetie/unxhr/issues/98

With the following configuration:

"asciidoc.preview.asciidoctorAttributes": {
    "allow-uri-read": true,
    "kroki-fetch-diagram": true
}

Asciidoctor Kroki won't work with either kroki.io or local instance.

I've updated the documentation: https://github.com/asciidoctor/asciidoctor-vscode/pull/820

agrexgh commented 10 months ago

@ggrossetie Thank you for replying.

I'd like to use local kroki to preview plantuml diagrams on asciidoc preview. I understood ‘kroki-fetch-diagram‘ is necessary to do that, but unfortunately it's not supported. Do you have any alternative solutions to preview plantuml diagrams with local kroki than ‘kroki-fetch-diagram‘?

ggrossetie commented 10 months ago

I'd like to use local kroki to preview plantuml diagrams on asciidoc preview. I understood ‘kroki-fetch-diagram‘ is necessary to do that, but unfortunately it's not supported.

You don't need kroki-fetch-diagram to use a local Kroki instance. This option is useful for publishing an HTML document without having a dependency on a Kroki instance. If it's just for local preview, there's no need for kroki-fetch-diagram. Otherwise, I recommend exporting to HTML outside of VS Code using the asciidoctor command line (where the kroki-fetch-diagram will work).

Did you understand that the option was necessary while reading the documentation? Maybe we need to clarify that.

agrexgh commented 10 months ago

@ggrossetie I understand that ‘kroki-fetch-diagram‘ was necessary based on the actual behavior of the extension, not from the documents.

I'll write "actual behavior". With ‘kroki-fetch-diagram‘ diagrams were shown in the preview and without it diagrams weren't shown. The version of this extension is v3.1.7.

ggrossetie commented 10 months ago

Do you still reproduce this issue with the latest version (3.1.8)?

Could you please try to reproduce in a clean environment:

Thanks!

agrexgh commented 10 months ago

@ggrossetie I tested with below

With v3.1.8: It works! The diagrams in preview was shown. With v3.1.7: It doesn't work.

It seems this issue was fixed in v3.1.8, I'd like to know what issue fixed this issue. Do you know this?

ggrossetie commented 10 months ago

I made a fix to allow the Kroki server defined in the preview attributes (by adding it to the CSP rules)

Please note that it should also work in 3.1.7 if you disable the preview security.

agrexgh commented 10 months ago

Please note that it should also work in 3.1.7 if you disable the preview security.

Excuse me, could you tell me how to disable the.preview security and enable it?

ggrossetie commented 10 months ago

When the preview is opened, open the command palette (https://code.visualstudio.com/docs/getstarted/tips-and-tricks#_command-palette) and search for "Manage Preview Security Settings".

agrexgh commented 10 months ago

Thank you, I'll try it after a few days!

agrexgh commented 10 months ago

When the preview is opened, open the command palette (https://code.visualstudio.com/docs/getstarted/tips-and-tricks#_command-palette) and search for "Manage Preview Security Settings".

I tried this. When preview security setting was "Allow insecure local content", the preview of plantuml was shown in also v3.9.7! Thank you for telling it to me!

My problems were all solved:)