openlab-at-city-tech / webworkqa

WeBWorK integration for WordPress and BuddyPress
GNU General Public License v2.0
4 stars 2 forks source link

[math] not rendering #1

Closed boonebgorges closed 8 years ago

boonebgorges commented 8 years ago

https://openlab.citytech.cuny.edu/groups/openlab-webwork-integration-project/forum/topic/setting-up-webwork-test-integration-with-openlabdev-org/#post-35041

boonebgorges commented 8 years ago

Andrew - Can you please share the URL of the problem where you initiated your question? TeX should, generally speaking, be parsed; but there may be something about the [math] markup in particular that's causing problems.

drdrew42 commented 8 years ago

Set 3, problem 3 in WW-Dev

From the debug dump: [math]

and

Solutions (separate by commas): [math]

neither of these are rendering under "Show Problem" - all I see is [math] in their place.

drdrew42 commented 8 years ago

LOL, trying to copy-paste HTML code. Let's try this again:

<span class="MathJax_Preview">[math]</span><script type="math/tex; mode=display">\frac{7}{3x+4}+\frac{32}{6x^{2}+5x-4} = \frac{x}{2x-1}.</script>

and

Solutions (separate by commas): <span class="MathJax_Preview">[math]</span><script type="math/tex">x =</script>

drdrew42 commented 8 years ago

Actually, I'm not getting the [math] to render anywhere... Is it just me? I'm on Chrome Version 48.0.2564.109 (64-bit)

boonebgorges commented 8 years ago

It looks like [math] and <script type="math/tex"> means that MathJax has already converted the content. I'll have to find a way to back-convert it, or to force MathJax to display it.

In my original development, TeX was being properly rendered, but it's possible it had originally been generated in a different way - using $ or \( delimiters or something. Can you let me know how the TeX was originally written, when seeding the problem?

drdrew42 commented 8 years ago

In WeBWorK, TeX is delimited by \( ... \) or \[ ... \], but when it's appearing in the dump, there's no delimiters beyond the <script> tags. What appears between the <script> tags is legit TeX code for the original problem, just without any delimiters.

In the usual TeX files, math expressions are delimited with $ ... $ or $$ ... $$

drdrew42 commented 8 years ago

http://docs.mathjax.org/en/v1.1-latest/model.html

This document describes exactly what we're seeing. It looks like the submission of MathJax data is designed for use in an older version of MathJax (1.1), well behind the current v2.6

boonebgorges commented 8 years ago

Ah, interesting. What version of WeBWorK are you running?

On 02/10/16 13:31, drdrew42 wrote:

http://docs.mathjax.org/en/v1.1-latest/model.html

This document describes exactly what we're seeing. It looks like the submission of MathJax data is designed for use in an older version of MathJax (1.1), well behind the current v2.6

— Reply to this email directly or view it on GitHub https://github.com/livinglab/webwork-for-wordpress/issues/1#issuecomment-182541073.

drdrew42 commented 8 years ago

2.11, I updated over the winter break.

drdrew42 commented 8 years ago

I think I found the problem. I see call to load the MathJax script in the header: <script type="text/javascript" src="/webwork2_files/mathjax/MathJax.js?config=TeX-MML-AM_HTMLorMML-full"></script> but I'm seeing an error from the JS Console in Chrome: http://openlabdev.org/webwork2_files/mathjax/MathJax.js?config=TeX-MML-AM_HTMLorMML-full Failed to load resource: the server responded with a status of 404 (Not Found)

Also, I was wrong earlier: Reading through MathJax documentation, it looks like everything is correct for the current version. <script type="math/tex">TEX_STUFF</script> is the proper manner of calling MathJax to process TEX_STUFF, with the script tags as delimiters. And according to the documentation, the "MathJax_Preview" is placed in front of the script tags because of issues with IE handling the HTML codes in some weird way. http://mathjax.readthedocs.org/en/latest/advanced/model.html#how-mathematics-is-stored-in-the-page

drdrew42 commented 8 years ago

We don't necessarily need a local instance of MathJax (for now?)

Just replace the previous call to load MathJax.js with the following: <script type="text/javascript" async src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config= TeX-AMS-MML_HTMLorMML"> </script>

boonebgorges commented 8 years ago

Yes, I'm already loading the script from the mathjax.org CDN, but there are other conflicts on the page, perhaps as a result of the fact that I'm dumping the contents of the original POST request onto the page. I will look into it.

On 02/15/2016 11:02 AM, drdrew42 wrote:

We don't necessarily need a local instance of MathJax (for now?)

Just replace the previous call to load MathJax.js with the following: |<script type="text/javascript" async src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config= TeX-AMS-MML_HTMLorMML"> |

— Reply to this email directly or view it on GitHub https://github.com/livinglab/webwork-for-wordpress/issues/1#issuecomment-184302301.

boonebgorges commented 8 years ago

The underlying problem was the finickiness of how MathJax needs to be loaded. I was stripping the JS sent from WeBWorK, for security reasons, and attempting to load MathJax in the footer of the page. But it turns out that MathJax doesn't work if it's loaded outside of the document head. I'm now reproducing something close to what WW was sending over, and TeX is now being parsed as expected.