openlab-at-city-tech / webworkqa

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

TeX not always rendered within tables #133

Closed boonebgorges closed 5 years ago

boonebgorges commented 6 years ago

See screenshot: m0xlnvo

However, when I tested later, it did render: tf1ljy0

So, I think what's happening is that the TeX is recognized and rendered, but it happens very slowly. Each of the items in backticks is a different bit of TeX, as far as the parser is concerned, and they are all processed serially rather than in parallel.

I'll test this theory and poke around to see if I can come up with improvements.

boonebgorges commented 6 years ago

Looking more closely at this, the behavior is very strange.

The root issue is that the unrendered text in this table is being sent from WeBWorK in backticks, instead of in the standard format for LaTeX-formatted math. Consider the following, which is the first row in the table above:

<TR>
<TD><span class="MathJax_Preview">[math]</span><script type="math/tex">\qquad \color{red}{x} \qquad</script></TD>
<TD><span class="MathJax_Preview">[math]</span><script type="math/tex">\qquad f(\color{red}{x}) = 3\color{red}{(x)}-4\qquad</script></TD>
<TD>`3x-4`</TD>
</TR>

The first two td elements are rendering properly, while the last is not. In the first two, WeBWorK is sending the expected <script type="math/tex">...</script>, which we use on our end to convert to standardized delimiters. In the last td, simple backticks are used, which OL-WW doesn't know anything about. I can see a parallel discrepancy between formatting in the original WeBWorK problem source, but I don't understand enough about how TeX is entered into WeBWorK (especially when building a table in PGML) to know what's going on. See screenshot and http://mathww.citytech.cuny.edu/webwork2/WW-Dev/instructor/pgProblemEditor2/Functions_-_Difference_Quotient/1/

screenshot_2018-09-25_16-05-41

Given the above, you'd think that these td elements would never be rendered by MathJax. As far as I can see, it works occasionally because the MathJax script is fairly greedy, and is trained to see content in backticks. It might be that it only does this when the rest of the TeX on the page is processed quickly enough, which is why it's intermittent? I don't really know.

In any case, perhaps @drdrew42 can shed some light on the issue with the backticks. If we can avoid the use of this technique in the source problems, the current problem might fix itself.

boonebgorges commented 5 years ago

Bump @drdrew42 - Could you read over the comment above and see whether you've got any insight on how the original problem is formatted? Is it common to use backticks as TeX delimiters in WeBWorK? Is it necessary?

drdrew42 commented 5 years ago

No, this is not a common delimiter - I'm going to revise the code for this problem, replacing backticks with ( and ).

boonebgorges commented 5 years ago

Awesome. Then I'm going to close this ticket as not being applicable moving forward. Thank you for having a look!