vericast / nbconflux

nbconflux converts Jupyter Notebooks to Atlassian Confluence pages
BSD 3-Clause "New" or "Revised" License
117 stars 33 forks source link

MathJax issues #33

Closed danizen closed 4 years ago

danizen commented 4 years ago

I'm exploring some issues with MathJax on our wiki. The issue is that the HTML macro currently used by nbconflux to add in the scripts are not supported on my corporate confluence. A MathJax plugin will be added to the wiki, since users who do not use Jupyter notebooks may know math as well ;)

Then, I guess I'll hack away until nbconflux can either use the MathJax plugin or embed it directly.

This is partly an FYI, and partly a query for direction - there must be ways to discover which plugins are installed, but these will not be accessible everywhere, so --exclude-mathjax perhaps becomes something like --exclude-mathjax --mathjax-plugin=True

danizen commented 4 years ago

So, after installing this plugin, the storage format for a MathJax block equation is:

<ac:structured-macro ac:name="mathjax-block-macro" ac:schema-version="1" ac:macro-id="2b193a44-073d-4148-b82c-0d006a560dbc">
  <ac:plain-text-body><![CDATA[Z_{n+1} = Z_n\times sin(Z_n)]]></ac:plain-text-body>
</ac:structured-macro>

And here is that for an inline mathjax equation:

<ac:structured-macro ac:name="mathjax-inline-macro" ac:schema-version="1" ac:macro-id="4739ddeb-fcf6-43d3-9426-6fc3c388d25b">
  <ac:parameter ac:name="equation">Z_{n+1} = Z_n\times sin(Z_n)</ac:parameter
</ac:structured-macro>
danizen commented 4 years ago

That plugin placed the MathJax scripts on that page and other pages that existed before the plugin was installed, as follows:

<script type="text/x-mathjax-config">
  MathJax.Hub.Config({ tex2jax: { inlineMath: [ ['(mathjax-inline(', ')mathjax-inline)' ] ], displayMath: [ ['(mathjax-block(', ')mathjax-block)' ] ], } });
</script>
<script type="text/javascript" async
        src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-MML-AM_CHTML">
</script>
danizen commented 4 years ago

I haven't done to much with MathJax, configuration, but when I type this in a normal Confluence page, I get what you would expect:

This will converge to (mathjax-inline(\pi)mathjax-inline).

So, I need some guidance as to how to handle this - Jupyter expects the delimiter to be quite different. No doubt, the confluence plugin is using a longer string for some reason...

danizen commented 4 years ago

The plugin does support configuring tex2jax with different prefix/suffix, but whether this is wise is not so clear. It would be better to do this in a way that only targets elements with a particular class, in a large confluence site.

danizen commented 4 years ago

Related issue to enable them to use more standard prefix/suffix configuration depends on them turning it off except in divs with appropriate classes - https://bitbucket.org/keysight/keysight-plugins-for-atlassian-products/issues/72/please-support-configuration-of-the.

So, I can make the thing work the way I want. Closing this - there is no problem here with nbconflux, it already allows me to exclude mathjax and get it in Confluence a different way.