dokka icon indicating copy to clipboard operation
dokka copied to clipboard

Square brackets are not rendered correctly in formulas by MathJax

Open lounres opened this issue 2 years ago • 2 comments
trafficstars

Describe the bug Brackets are dropped in formulas. For example, \[f[x]\] is rendered not as $f[x]$ but as $fx$.

Expected behaviour Brackets are not dropped in formulas.

Screenshots изображение изображение

To Reproduce

  1. Add the MathJax plugin to usual dokka configuration.
  2. Add any top-level function with docstring
    /**
     * \[f[x]\]
     * 
     * @usesMathJax
     */
    
  3. Compile the documentation.

Dokka configuration Configuration of dokka used to reproduce the bug

dependencies {
    dokkaPlugin("org.jetbrains.dokka:mathjax-plugin:1.8.10")
}

Installation

  • Operating system: Windows
  • Build tool: Gradle v8.1.1
  • Dokka version: 1.8.10

Are you willing to provide a PR? Sorry, but no.

lounres avatar Jun 11 '23 22:06 lounres

By KDoc, [x] is treated as a link to element x. Meanwhile, Dokka should generate \] and \[ in HTML to display MathJax. Current workaround - to use HTML escaping, e.g. for [ ([):

/**
 * \[f[x]\]
 *
 * @usesMathJax
 */

Escaping in Kdoc should be discussed further so I left this issue.

vmishenev avatar Jun 22 '23 16:06 vmishenev

https://youtrack.jetbrains.com/issue/KT-24840/Square-bracket-escaping-in-KDoc

vmishenev avatar Mar 07 '25 13:03 vmishenev