asciidoctor / asciidoctor-intellij-plugin

AsciiDoc plugin for products on the IntelliJ platform (IDEA, RubyMine, etc)
https://intellij-asciidoc-plugin.ahus1.de/
Apache License 2.0
355 stars 145 forks source link

Mermaid support out of the box without needing local Node environment (like IntelliJ Markdown) #1199

Closed mklueh closed 1 year ago

mklueh commented 2 years ago

Why the new feature should be added

Usability and security reasons

How the new feature should work

I'm wondering if it would be possible to make this plugin work as seamless as the official markdown plugin of IntelliJ when it comes to mermaid diagram rendering without the need of manual installation and configuration of tools.

https://github.com/JetBrains/intellij-community/tree/28ce2f43360fd1abcfe9ee39ce436578c0783a03/plugins/markdown/core/src/org/intellij/plugins/markdown/extensions/jcef/mermaid

I'm not exactly sure how they do it, but with the Markdown Plugin you don't have to have Node.js installed on your Windows machine and it kind of works out of the box. It seems they are using mermaid.js and do the rendering in a browser, rather than local.

For security reasons we can't install Node.js on our PC at work and have to go with WSL2 instead. However, this comes with other drawbacks, which is why we develop our Java applications on the local machine rather than in WSL2.

The options to display diagrams with ascidoc are now limited to Kroki, and running an extra server just to render some diagrams in the editor seems too overkill.

Would it be an option to copy what IntelliJ is doing to work exactly like there plugin does?

ahus1 commented 1 year ago

Thanks for suggesting this. I'll look into this, still I can't promise a date for this yet.

ahus1 commented 1 year ago

The new option is now available in the settings:

image

I'll update this issue once a pre-release is available.

ahus1 commented 1 year ago

Version 0.38.2 is now available as a pre-release. Please give it a try and let me know how this works for you.

If it works well and we don't consider it to be experimental, I might enable it by default in a future release.

The pre-release of the plugin is available from GitHub releases and the IntelliJ AsciiDoc EAP repository.

jop-di commented 1 year ago

Works on my machine (Fedora, Goland 2022.3, asciidoc plugin 0.38.2), thanks!

Tested using:

[mermaid]
....
graph TD;
    A-->B;
    A-->C;
    B-->D;
    C-->D;
....

Resulting in the expected image

ahus1 commented 1 year ago

Hi - thanks for confirming that this is working for you! I plan to publish a new release to cover some changes needed for 2022.3 this weekend or early next week, and then those changes will be available to the general public.

mklueh commented 1 year ago

Just one small thing, it seems you need to restart the IDE after enabling the new function, but there is no hint or anything. It just does not render at all and you wonder why. But maybe there was another reason, as nothing was rendering at all

jop-di commented 1 year ago

do you need a complete restart of the IDE, or does it also work when you close and re-open the relevant file (I noticed you sometimes need to close and re-open a file when changing an option related to the filetype already opened)

mklueh commented 1 year ago

@jop-di Not sure anymore, but I think the first time after updating the plugin and activating the new feature it was a reboot. Then I witnessed I had to close and reopen each file after renaming .md to .adoc

ahus1 commented 1 year ago

Hi @mklueh - your observations are correct:

convert-markdown