liffiton / dokuwiki-plugin-mathjax

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

Added support for plugin:latexport #30

Closed jean-michel-gonet closed 6 years ago

jean-michel-gonet commented 6 years ago

Why?

This makes Mathjax a beautiful plugin to use together with mine.

Modification

I've added a specific call that occurs only in mode latexport, and placed it besides other similar calls.

Check it in action

Use the following links:

liffiton commented 6 years ago

Would it be possible for your plugin to handle math mode expressions without the dependency on the Mathjax plugin? That is, could I have this plugin's render() function simply pass through the tex for all modes (which I think it really should be doing anyway):

$renderer->doc .= $data;
return true;

Then I imagine your plugin could locate, parse, and modify math mode expressions however it wanted whether the Mathjax plugin was installed or not. I'm just looking for the cleanest solution, but if there is some reason that would not work, that's fine. In that case, I just have a request and a question:

  1. Could you please match the indentation style of the existing code (4 spaces per level)?
  2. Shouldn't the render() function return true to indicate success for the latexport mode?

Thanks!

jean-michel-gonet commented 6 years ago

Thank you for your comments,

Sadly, I can't handle math mode expressions if they're directly injected in the $renderer->doc property because I need to transform them before inserting as latex content:

Furthermore, I need to perform other, more radical, transformations with headings, images, tables, that involve a change in the precedence of the content. I wouldn't be able to manage it when syntax plugins write directly in the document's buffer.

On the second suggestion, latexport being able of handling math expressions without your syntax plugin; I've considered it at the beginning, but I don't see much value in it:

Those were my reasons to prefer the hassle of a dependency.

About the indentation and the returning value: of course, you're right. I've fixed that.

liffiton commented 6 years ago

Okay, sounds good to me! I'll merge that, maybe tweak the render() function a bit (like I said, I'm not sure why I'm not just always passing the tex through for other modes) and make an updated release. Thanks.

liffiton commented 6 years ago

Oops, I didn't test this before merging, because it looked fine, but FYI the commit indented the if statements with non-breaking spaces (0xc2a0), which really confused the PHP intepreter. :smile:

jean-michel-gonet commented 6 years ago

Thanks for your support. I guess unbreakable space is my fault. I just swapped to a new editor, and I'm not familiar with it.