Markdown text rendering in a plugin
Answered
I have a custom tool window showing plain text. However, the text is being taken from .md file and I want to render it in the window as the markdown plugin itself does it. Can someone please outline the steps towards integrating the plugin functionality into my own so that I could render it accordingly? I examined the source code, but it left me clueless.
Thank you for any help!
Please sign in to leave a comment.
See com.intellij.ui.javafx.JavaFxHtmlPanel, for HTML generation see org.intellij.plugins.markdown.ui.preview.MarkdownUtil#generateMarkdownHtml which could be simplified if you dont' use code fences
Thank you, Yann! Can you please tell me why I can't access the method in MarkdownUtil? Do I need to specify some special configs?
Please make sure you follow steps to add Markdown plugin (ID: org.intellij.plugins.markdown) itself as dependency to yours: http://www.jetbrains.org/intellij/sdk/docs/basics/plugin_structure/plugin_dependencies.html
I already tried following the guide some time ago (using Gradle) and it keeps complaining with
What might be an issue?
In case of using IntelliJ Ultimate:
intellij {
version 'IU-2019.1.2'
plugins 'markdown'
}
The syntax for builtin plugins is to use directory name ('markdown'), not ID of plugin - see https://github.com/JetBrains/gradle-intellij-plugin/#configuration
Thanks for the reference, but I still somehow fail to get it to work. I have another plugin working in this manner, but markdown is highlighted as red in plugin.xml. Fetching 'markdown' by name still yields the same exception as above.
My definitions are following:
In plugin.xml "<depends"> tag, ID must be used.
Let me describe the problem in a little more detail. Integrating builtin plugin by the directory name still throws the following exception:
Therefore <depends> can't include the dependency. I tried both name and id. I can't figure out what's wrong.
Sorry, indeed my previous answer wrongly implied targeting Ultimate Edition where Markdown plugin is bundled.
When using Community Edition, the correct definition is:
intellij {
version '2019.1.2'
plugins 'org.intellij.plugins.markdown:191.7141.32'
}
Thanks a lot, Yann! It finally works.