mitya57 / python-markdown-math

Math extension for Python-Markdown
https://pypi.org/project/python-markdown-math/
BSD 3-Clause "New" or "Revised" License
120 stars 27 forks source link

render_to_span #15

Closed danniranderis closed 7 years ago

danniranderis commented 7 years ago

Hi.

I can see that the config-option "Render_to_span" making it easier to support users that has disabled js is committed 13 months ago. Would it be possible to ship a new release anytime soon, so that (large performance change) can get out into the air?

Thanks in advance! Danni

mitya57 commented 7 years ago

I can make a new release of course.

Are you satisfied with the current behavior of that option? It currently renders only inline math to spans, for standalone equations it still uses <script> tags.

danniranderis commented 7 years ago

For my usages inline is enough, but for sure - standalone should be processed the same way.

A thing I have noticed - and it might me my lack of enough understanding of configuring MathJax, is that this right now creates a "hard-fallback" where MathJax is not rendering the equations if javascript is available due to the fact that it looks for <script type="math/tex"> and not <span class="tex">. As of right now - I haven't figured out, how to solve this.

danniranderis commented 7 years ago

config-hub --> preRemoveClass: "MathJax_Preview".

I think we might use this to our advantage to achieve both no-js and js.

While not converting <script> to <span> it would rather be better to just add an extra <span class="MathJax_Preview"> before the <script>-tag.

With this approach we will get the following: 1) with no js, the <span> is not removed and therefore visible and the <script> is of course invisible. 2) with js enabled, the <span> is removed and <script> is processed.

danniranderis commented 7 years ago

I have now forked this and created a solution for the approach described above. Feel free to test it - I haven't seen any errors with it and it does not need extra config for MathJax.

mitya57 commented 7 years ago

Now I want to check with the author of the original change. @a3nm, are you OK with the proposed change?

danniranderis commented 7 years ago

Sounds good - I have also added the same function to handle_match() so that standalone equations are handled the same way when render_to_span=True.

Looking forward to hear from you

a3nm commented 7 years ago

I'm not sure I remember what all of this is about :) but I just pulled the proposed changes and they don't seem to introduce any issues for what I do, so I'm fine with the change. Thanks for letting me know.

-- Antoine Amarilli

On Fri, Feb 17, 2017 at 08:32:29AM -0800, Dmitry Shachnev wrote:

Now I want to check with the author of the original change. @a3nm, are you OK with the proposed change?

mitya57 commented 7 years ago

I have simplified the code, added tests, and renamed the option from render_to_span to add_preview (now that it outputs not only span/div, but also the script tag).

Please test it and I will roll a new release.

a3nm commented 7 years ago

This appears to work fine for me. (Actually my use case is to pass the result to MathJax-node/bin/page2html to render the MathJax server-side, so I don't need the extra Githubissues.

  • Githubissues is a development platform for aggregating issues.