liffiton / dokuwiki-plugin-mathjax

MathJax plugin for DokuWiki
https://www.dokuwiki.org/plugin:mathjax
12 stars 11 forks source link

ASCIIMath not working #42

Closed Ragos81 closed 1 month ago

Ragos81 commented 1 month ago

I saw the last change was to put the ASCIIMath support behind a config flag to avoid conflicts, is it possible that this change broke the functionality?

No matter what I tried, $ sqrt 5 $ always becomes sqrt5 unless I change the code to $ \sqrt 5 $, then the output is rendered correct.

I had changed the configuration file to https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.9/MathJax.js?config=AM_CHTML.js and enabled the “asciimath” configuration option, but it seems it didn't make any difference.

The background to use ASCIIMath support is that I want to replace the mathpublish plugin, so I can use LaTeX in the future, but wouldn't need to replace every singe existing formula, except replacing the <m>...</m> tags with the dollar signs.

liffiton commented 1 month ago

I don't use ASCIIMath myself, so please correct me if any of this is in error.

The default delimiter for ASCIIMath in Mathjax is the backtick ` (Mathjax ASCIIMath documentation). You can change the delimiters in the Mathjax configuration (see the linked page).

Let me know if that works for you.

Ragos81 commented 1 month ago

Thanks a lot @liffiton for your quick reply!

You're absolutely right, I didn't noticed this detail! I changed the $ with ` and everything worked more or less as expected.

But it seems like I can't go the lazy way and add the original tags from mathpublish to the configuration.

At least this didn't work: MathJax.Hub.Config({ tex2jax: { inlineMath: [ ["$","$"], ["\(","\)"] ], displayMath: [ ["$$","$$"], ["\[","\]"] ], processEscapes: true }, asciimath2jax: { delimiters: [["\","\"] } });

I don't know if I made something wrong, or if using the <m>...</m> tags is just not possible.

Nevertheless, you already helped me a lot today. As it turns out that I will have to adjust the formulas by hand anyway, as the syntax between mathpublish and ASCIIMath is in some points different, I will have no benefit in using the old mathpublish tags.

liffiton commented 1 month ago

This plugin has to "protect" MathJax delimiters from Dokuwiki's parsing so that they are left unchanged in the HTML sent to the browser (where MathJax does its parsing). The plugin does not parse the MathJax config to see what custom delimiters may have been set, though, so it only protects the standard ones. <m> delimiters work if you wrap them in %% to manually prevent Dokuwiki's parsing, but of course that's not an ideal solution.

I'll close this issue but open another to document the custom-delimiter issue.