DocumentationProvider: HTML with math formulas (MathML, MathJax, JS, CSS)

Answered

In the language my plugin supports, the built-in functions are often mathematical and their short documentation often contains formulas. The native usage docs look like this

and until now, I have approximated this native documentation with HTML only in my DocumentationProvider. When users open quick-doc on a function, it looks like this

It's not perfect but readable. However, I thought about improving the representation, and I tried the following when providing the string from com.intellij.lang.documentation.DocumentationProvider#generateDoc

  • MathML
  • load MathJax (Javascript)
  • include custom CSS that's supposed to mimic MathML

Nothing worked, and I guess the underlying JBHtmlFactory (if I traced that right) just isn't capable of these things.

Question: Is there something that I miss or am I stuck with plain HTML?

 

0
3 comments

Yes, only basic HTML can be used here. One workaround might be to generate a PNG on-the-fly and reference that instead.

1

Thanks Yann. The "creating images on the fly" was also something that crossed my mind, but then the input needs to be perfect. HTML is more forgiving when you provide not entirely correct things. I'll think about it.

0

You can always try to use the regular HTML and generate the formulas as PNG resources which you can refer to using inline <img> HTML elements.

0

Please sign in to leave a comment.