Closed davidfarmer closed 2 years ago
I think the problem is that it triggers ASCIIMath in MathJax.
Now I think the problem is that MathJax should only be configured to look for AsciiMath in certain places, such as the answers to reading questions.
This problem has probably existed since we started using MathJax3. Nothing wrong with MathJax3, but when we switched, we did not set it up properly. Problems in the sample article backticks paragraph, for example:
https://pretextbook.org/examples/sample-article/html/text-in-paragraphs.html#p-380
I guess I'd forgotten about .has_am
. You must be injecting it via Javascript, since I only see it in the XSL in the MathJax configuration.
When an answer to a reading question is submitted, the has_am class is added.
Currently everything is processed as AsciiMath. Once I fix that, I have to check that it didn't break reading questions.
On Wed, 6 Oct 2021, Rob Beezer wrote:
I guess I'd forgotten about .has_am. You must be injecting it via Javascript, since I only see it in the XSL in the MathJax configuration.
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe. Triage notifications on the go with GitHub Mobile for iOS or Android.[AABTULFGB4BINL2B3WXK653UFSXDVA5CNFSM5FDOX6P2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGO G7NLNIY.gif]
Bad news: MathJax3 does not distinguish between TeX and AsciiMath. So it is impossible to turn off AsciiMath and only use it in selected places.
So we do need a warning. Not sure if we can do something like we do with slash-paren in the source, where it appears literally in the HTML and does not trigger MathJax.
Because slash-paren is two characters, we "break" it by putting a zero-width space in the middle for it's (unlikely) occurrence in regular text.
Can we configure MathJax to do asciimath based on two characters and maybe pre-process the source to this form. What about the actual HTML tags that signal math? Why are we fighting ad-hoc markup?
Certainly something here I'm not understanding correctly.
On October 8, 2021 4:08:24 PM PDT, "David W. Farmer" @.***> wrote:
Bad news: MathJax3 does not distinguish between TeX and AsciiMath. So it is impossible to turn off AsciiMath and only use it in selected places.
So we do need a warning. Not sure if we can do something like we do with slash-paren in the source, where it appears literally in the HTML and does not trigger MathJax.
Because slash-paren is two characters, we "break" it by putting a zero-width space in the middle for it's (unlikely) occurrence in regular text.
Side note: This can drive a person nuts. Copy-paste and "why won't it work?!?!?"
If a character is &#'-ed (like \
to \
) does that block MathJax? Or is it too late once the browser has turned it back into \
?
Here is something to consider: https://spot.pcc.edu/~ajordan/temp/mathjaxtest.html
If you wrap a span around each MathJax delimiter, that prevents MathJax from latching onto it.
We know exactly where the math lies. So set ignoreHtmlClass
to ignoreme
and then set processHtmlClass
to processme
.
Then we output, for example:
<body class="ignoreme">
<span class="processme">$x^2$</span>
</body>
I understand this is how these options behave together: https://docs.mathjax.org/en/latest/options/document.html#document-options
Replace the dollar signs by backticks for an ASCIImath example (which battles markdown right here!).
David's use case is readers submitting reading question answers using ASCIImath (I think!). Would it be feasible to process an answer into this scheme?
Advantage: we get rid of texjax_ignore
on elements such as those holding verbatim text, we stop breaking TeX constructs (\(
, \begin{align}
) with zero-widthspaces. We stop having to be on the lookout for poorly-designed markup!!!
Some crude experimentation with the ignoreme/processme
classes idea. We already put a div
around display math, so that was a natural place to experiment. Everything works as expected.
I even unwound the zero-width space from within textual \(
and it behaves as-desired.
Caught one caveat: have to process the element defining all the macros!
As we move ahead with MathJax 3 configuration options, I'm afraid we will be making changes that are hard to support within the Jupyter conversion. We might just have to accept that, but perhaps some investigation of Jupyter configuration will reveal a better situation than expected.
To run with this will require some nontrivial refactoring. But it may also allow us to support ASCIImath within any PreTeXt math element, or at least <m>
.
@davidfarmer: if has_am
goes away, can you wrap any use of ASCIImath in reading questions in a suitable span.processme
.
Yes, I will use better class names!
1) I added "processme" to the answer javascript, so that can be tested.
2) The WeBWorK javascript also contains the MathJax configuration, so that is another place to update once we know the new setup.
3) I am in the midst of a CSS upgrade (from 0.31 to 0.4) and am thinking we also need a JavaScript upgrade.
4) Doesn't Alex's recent work on inline math nobreak make it easy to wrap inline math in a .processme?
On Mon, 11 Oct 2021, Rob Beezer wrote:
Some crude experimentation with the ignoreme/processme classes idea. We already put a div around display math, so that was a natural place to experiment. Everything works as expected.
I even unwound the zero-width space from within textual ( and it behaves as-desired.
Caught one caveat: have to process the element defining all the macros!
As we move ahead with MathJax 3 configuration options, I'm afraid we will be making changes that are hard to support within the Jupyter conversion. We might just have to accept that, but perhaps some investigation of Jupyter configuration will reveal a better situation than expected.
To run with this will require some nontrivial refactoring. But it may also allow us to support ASCIImath within any PreTeXt math element, or at least
. @davidfarmer: if has_am goes away, can you wrap any use of ASCIImath in reading questions in a suitable span.processme.
Yes, I will use better class names!
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or unsubscribe. Triage notifications on the go with GitHub Mobile for iOS or Android.[AABTULFPKKXNIFPKG4R76ATUGORM3A5CNFSM5FDOX6P2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGO HAIKWPQ.gif]
4) Doesn't Alex's recent work on inline math nobreak make it easy to wrap inline math in a .processme?
Right, #1590 will be a big help. Just hads not looked closely at it yet. Thanks for adding the class.
Built AATA:
Set the "platform/@host" so that logins are enabled, JS included, etc.
Used the ignoreme/processme experimental MJ 3 configuration.
Logged in, answered a reading question with "$x^2$". Preview changes it to "(x^2)" so something happens. But not being rendered as math.
https://pretextbook.org/beta/2021-10-13-reading-answers/reading-questions-1.html
(reading-questions-2 is there also, but nothing else)
Some ASCIIMath errors in the console, not sure if that is related. Noob that I am, I could even see "processme" in a plce that looked reasonable. I dropped "has_am" from the PTX MJ configuration in the above example, got a similar experience before trying that.
Rob
Apparently I had never updated the reading questions code to work with MathJax3. I just did, and those seem to work for me.
I had never updated
I was suspicious. ;-) Thanks for the quick check. I think we have proof-of-concept. I'll need to do more work to check on danger downstream (Jupyter, mostly). So, more to do, but I think this will be a big improvement.
I also want to check on the rendering time for pages with substantial amounts of math. I think it should be the same, since either way the whole tree has to be traversed to identify what needs to be rendered. But better to check for sure.
On Wed, 13 Oct 2021, Rob Beezer wrote:
I had never updated
I was suspicious. ;-) Thanks for the quick check. I think we have proof-of-concept. I'll need to do more work to check on danger downstream (Jupyter, mostly). So, more to do, but I think this will be a big improvement.
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or unsubscribe. Triage notifications on the go with GitHub Mobile for iOS or Android.[AABTULDRDAWJAYHKIFZUYNDUGXTFFA5CNFSM5FDOX6P2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGO HAYFKTA.gif]
check on the rendering time
Right. I'd thought about this. I'll definitely make a beta. My prediction: faster, but imperceptible.
Once inside an ignore'd element, all of the "text" nodes can be skipped. But I think this entire phase is not the real time-sink.
Backticks outside of math contexts will not be seen by MathJax now, with d5ef68ffa5ab5262a4a4f07258596ccb9f2f9790
So no need for warnings, and authors can continue to use their keyboards to make whatever nasty strings they wish.
Backticks, or maybe just double backticks, in the HTML cause MathJax to choke.
If these are in the PreTeXt source,
``like this''
, an error or a warning should the given.Not sure if those ever have a legitimate purpose in PreTeXt source?