PreTeXtBook / pretext

PreTeXt: an authoring and publishing system for scholarly documents
https://pretextbook.org
Other
254 stars 203 forks source link

First attempt at updating to MJ3. #1469

Closed zorkow closed 3 years ago

zorkow commented 3 years ago

As announced in my email last night: Here is a first attempt at integrating MJ3. The main issues are:

  1. In some proofs contain elements that are rendered but there is no context menu/a11y available.
  2. Math in knowles used as cross-references is not rendered.

If you could give us a hint how to fix problem 1, that would already be sufficient for the experiments we have in mind.

zorkow commented 3 years ago

Not sure why I can't pick reviewers, so I ping you directly: @davidfarmer @Alex-Jordan @rbeezer

davidfarmer commented 3 years ago

If someone can post an html version with these changes, I can look into the knowls issues.

zorkow commented 3 years ago

Here's the version of Tom's abstract algebra book: https://zorkow.github.io/mathbook/mj3-samples/aata/aata.html

zorkow commented 3 years ago

@Alex-Jordan and I looked at section 2 last night. Three types of elements:

  1. Rendered and accessible (i.e. with context menu)
  2. Rendered and inaccessible (all inside the hidden proofs)
  3. Not rendered, inside knowles (e.g., the crossreferenced knowle like Theorem 2.10 at the start of the Euclidean Algorithm section).

(3) is not a surprise as those live in separated html docs which do not contain a MathJax instance. (2) are the ones that I am not sure what to do about.

zorkow commented 3 years ago

PS: Yesterday I came across a couple of proof environments (usually at the top of the page) that contained accessible elements. But I can't find those anymore now.

rbeezer commented 3 years ago

Thanks, @zorkow. We'll find this very useful for #1039 very soon. So once we get the knowl issue sorted, this could become the basis for that issue.

A. Some content is born hidden in knowls always, like hints to exercises and footnotes. Others are elective, like examples. Others are elective but "on" be default, like a proof. This content is in a div on the page, so MJ must be more readily available.

B. Cross-references access duplicates of content stored in files in the knowl directory. As you mention, MJ would be less readily available. I think David hits these with MJ when they open, but he'll need to provide correct guidance. A cross-reference to a theorem will open the theorem in a knowl, and likely it will have a proof that is a knowl. That proof would be "on the page" in (A), but here it is a component of a duplicate of the proof and so there is another file just for this proof duplicate.

So your three scenarios are (1) "regular" math content, (2) my (A), born hidden, (3) my (B), cross-reference knowls?

I don't believe your PS. ;-) ;-) ;-)

Rob

davidfarmer commented 3 years ago

For most of the proofs in AATA, the content is hidden in the page and then shown when the proof knowl is clicked.

MathJax should not process that content until it is shown. So, I changed a line in the configuration to

ignoreHtmlClass: "tex2jax_ignore",

(Previously in the quotes was ".*").

However, that made no difference. I also tried, to no effect,

ignoreHtmlClass: "hidden-content",

Is there a different way to stop MathJax processing content, so it can be done later?

davidfarmer commented 3 years ago

I think MathJax is not ignoring material it was asked to ignore. I posted to MathJax support.

davidfarmer commented 3 years ago

As Davide explained on MathJax support, there are errors in the HTML. These can be fixed by:

In xsl/pretext-html.xsl, lines 10982-10984 should be deleted: that script tag should not have any attributes.

Line 11024 or 11017 (depending on which version you look at), which implements "close of MathJax.Hub.Config", should be deleted. That line contains: "});"

This one I figured out before asking Davide: line 10998 should replace ".*" by "tex2jax_ignore".

Making the above changes has things basically working, at which point we find that the "align*" environment is not recognized. In line 10995, add 'ams' to the list.

Now the "notsubset" command is broken. That is odd, because it is defined on the page. Sort-of: On line 10995 also add 'newcommand' to the list.

With those changes, things I checked in AATA were all working.

I have not checked sage cells in knowls, and surely knowls in display math are not working, but I don't think there are examples in AATA. I also did not check remote knowls (because I just hand-edited one HTML file). I'll look when a new version is posted.

Whoever made those markup errors in the new configuration can thank me for accepting the blame on the MathJax support group.

rbeezer commented 3 years ago

The newcommand package was a bit more work than suggested. Enough details here:

http://docs.mathjax.org/en/latest/input/tex/extensions/newcommand.html

I'm getting pretty good behavior with this now, with fixes from @davidfarmer. \sfrac is broken, and of course, \knowl.

Putting in mathjaxknowl3.js breaks everything, so you'll need to create a minimalist version, or edit it out of copies to get things working initially. URL looks right in "not found" error message in the console, so I think the configuration is correct.

Full beta, Section 7 is a good place to start. I've not yet tested any known problems we hope v3 would fix, this is just to get knowls code working.

https://pretextbook.org/beta/2021-05-07-mj3/section-7.html

pkra commented 3 years ago

@rbeezer https://pretextbook.org/js/lib/mathjaxknowl3.js is wrong. To kick things off, I used the "inline configuration" approach, not an extension. I've updated https://codepen.io/pkra/pen/JjWoZVp and added comments "START HERE // END HERE" - if you place just that code into the js file, it should work.

How about I create a repo for the new knowl extension? Since client-side extensions require extra build steps, it's better as a separate repository. (And for server-side rendering, you said you might want a different behavior so it's good to have both.)

davidfarmer commented 3 years ago

I replaced the contents of mathjaxknowl3.js , but that did not fix it.

The configuration for slanted fractions is wrong for MathJax3 (There is no MathJax.Hub in MJ3), but that is not the problem because I commented that out in a local version.

With that commented out, I do not see any error messages in the console.

On Sat, 8 May 2021, Peter Krautzberger wrote:

@rbeezer https://pretextbook.org/js/lib/mathjaxknowl3.js is wrong. To kick things off, I used the "inline configuration" approach, not an extension. I've updated https://codepen.io/pkra/pen/JjWoZVp and added comments "START HERE // END HERE" - if you place just that code into the js file, it should work.

How about I create a repo for the new knowl extension? Since client-side extensions require extra build steps, it's better as a separate repository. (And for server-side rendering, you said you might want a different behavior so it's good to have both.)

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, orunsubscribe.[AABTULAKJXKPJOMJJ6E25VDTMV4R7A5CNFSM43QDBAQ2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXH JKTDN5WW2ZLOORPWSZGOGHF76TI.gif]

pkra commented 3 years ago

I replaced the contents of mathjaxknowl3.js , but that did not fix it.

Next try: add "knowl" to the array in

packages: {'[+]': ['base', 'extpfeil', 'ams', 'amscd', 'newcommand']}
davidfarmer commented 3 years ago

Success!

Not complete success, because the knowl content looks terrible, probably because I am putting the knowl in the wrong location (because I have not yet updated the knowl code to handle that case). But I am on reasonably solid ground to take care of that myself. I'll do that soon (unlikely today, though) and will report how it goes.

On Sat, 8 May 2021, Peter Krautzberger wrote:

  I replaced the contents of mathjaxknowl3.js , but that did not
  fix it.

Next try: add "knowl" to the array in

packages: {'[+]': ['base', 'extpfeil', 'ams', 'amscd', 'newcommand']}

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, orunsubscribe.[AABTULCTDWS2REABZQ4D36LTMWF3LA5CNFSM43QDBAQ2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXH JKTDN5WW2ZLOORPWSZGOGHGHBKI.gif]

pkra commented 3 years ago

Thanks for the update, David!

rbeezer commented 3 years ago

Thanks, @pkra and @davidfarmer! I'll get a fix in perhaps late tonight and update the beta.

rbeezer commented 3 years ago

I added 'knowl' to the package list. Beta is being refreshed right now, give it 10 minutes to upload. Same location as above.

Knowls are functional! (Needs work, but they are are functional.) \sfrac is the only obvious thing that is wrong.

@pkra - I'll let @davidfarmer advise on repositories, etc. He's got a plan for where resources like this live.

Once this settles, I'd like to pursue #1471.

davidfarmer commented 3 years ago

Knowls code adjusted so that knowl content from math looks as expected.

Appears after teh display, as before.

I don't think it is possible (certainly not easy), and maybe not even desirable, for the knowl to appear split apart a multiline display.

For the repository, is there a reason to handle "mathjaxknowl3.js" differently than "mathjaxknowl.js"? That is, add it as a file in https://github.com/PreTeXtBook/JS_lib ?

On Sat, 8 May 2021, Rob Beezer wrote:

I added 'knowl' to the package list. Beta is being refreshed right now, give it 10 minutes to upload. Same location as above.

Knowls are functional! (Needs work, but they are are functional.) \sfrac is the only obvious thing that is wrong.

@pkra - I'll let @davidfarmer advise on repositories, etc. He's got a plan for where resources like this live.

Once this settles, I'd like to pursue #1471.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, orunsubscribe.[AABTULFJK533YHJT3P75MUTTMX5RPA5CNFSM43QDBAQ2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXH JKTDN5WW2ZLOORPWSZGOGHHQY7I.gif]

pkra commented 3 years ago

For the repository, is there a reason to handle "mathjaxknowl3.js" differently than "mathjaxknowl.js"? That is, add it as a file in https://github.com/PreTeXtBook/JS_lib ?

That depends largely on how you want to handle server-side rendering. I'm not actually sure but I'm guessing mathjaxknowl3 will work with MathJax's "components" example for server-side use (e.g. https://github.com/mathjax/MathJax-demos-node/tree/master/component) but it won't work with the "direct" example (e.g. https://github.com/mathjax/MathJax-demos-node/tree/master/direct) which I personally prefer.

rbeezer commented 3 years ago

Original code from PR is at pushed 9c91af4e107ea75c8f255624aba2d4742ab6b3fb - thanks for starting this @zorkow!

Changes discussed here are on other commits.