bootstrapworld / curriculum

6 stars 6 forks source link

Replace mathjax with unicode, where appropriate #1504

Closed schanzer closed 11 months ago

schanzer commented 1 year ago

(add more as we go -- possibly extend @math processing to use this, so that we lean on mathjax IFF we can't translate 100% of the symbols with unicode)

ds26gte commented 1 year ago

I just pushed a fix for #1502 whereby mathjax via @math in the ruby part of @fitbruby now works.

I'm just a little bit worried that replacing mathjax with Unicode, while OK for the HTML pages, may not render in the PDF (print version), because print fonts' support for arbitrary Unicode chars is not so good.

ds26gte commented 1 year ago

It may be easier to devise heuristics for when a math expression cannot be Unicoded. E.g., it can't if it

Everything else to be Unicoded. I'm basing this pretty simple 5-part heuristic based on looking at all the @math calls currently in the lessons. If I'm being too simplistic, let me know.

Actually, I'm not sure about the \mbox{...}. They may be convertible to straight HTML (preferably in sans-serif font, so they remain distinguishable from surrounding non-math text. Remainder: we typically use (or should use) \mbox{...} when we have multi-character identifiers that should be treated as kerned units, and not as algebraic juxtapositions).

This issue requires quite a bit of aesthetic consensus. Things should be readable easily, and authors should weigh in based on their own experience with reading mathematical prose and opinions developed.

schanzer commented 1 year ago

@ds26gte I think the heuristic is great!! I think we can encode mbox's as straight html as well.

flannery-denny commented 11 months ago

Noting that the issues I've cited impact more pages than the examples I selected.

schanzer commented 11 months ago

@ds26gte Unsurprisingly, Early Math has fewer errors because it doesn't stretch our math generation code as far as the other classes. Still, a few glitches popped up:

ds26gte commented 11 months ago

The fractions not using unicode super/sub could be because you changed the number font? I'm using the suggested U+2044 character for the fraction solidus.

schanzer commented 11 months ago

@flannery-denny Dorai has pushed an update that fixes a lot of the issues you and I were seeing with fractions and radicals. I've inspected all of the errors and checked off the ones that are fixed. If you have bandwidth to review the OK workbook after rebuilding today, that would be terrific.

I was not able to replicate the "arrows without lines" issue you saw. What is the issue with match-contracts-examples? That doesn't have any math in it, and it looks right to me.

flannery-denny commented 11 months ago

@schanzer Just rebuilt and the arrow issue persists in my new workbook.

ds26gte commented 11 months ago

-> becoming > does seem like it could be a font issue? Still, surprised that the other macOS user (@schanzer) is not seeing it. You two should zoom it out.

schanzer commented 11 months ago

@flannery-denny even in the exact page you wrote about, I'm just not seeing the broken arrows:

image

Let me know if you're free to zoom after 10:30am?

flannery-denny commented 11 months ago

If the arrow issue isn’t an issue on your computer, and you’re the one deploying, does that mean it will look right on the web?

schanzer commented 11 months ago

@ds26gte Flannery and I zoomed, and I had a chance to better-understand the issue. It turns out that this IS happening for me too! The arrow is drawn correctly on the web page, and any attempt to manually print the page to a PDF works great. But when puppeteer prints it, the dash disappears!

Are you able to replicate this on your machine? (Again, check the PDF - not the html)

schanzer commented 11 months ago

@ds26gte any way to use a different dash to distinguish negation from subtraction? image

We also generate extra spaces that aren't needed (though I get why the implementation does it). Unfortunately, these spaces leak into the HTML and make the output look weird. These screenshots are from "Translate Arithmetic to Circles of Evaluation & Code (Intro)" in order-of-operations. image image

ds26gte commented 11 months ago
schanzer commented 11 months ago

Thanks for rocking the spaces, @ds26gte

Huh - I didn't realize that the typographical precedent for math is that they use the same symbol! I was sort of thinking this would use emdashes (subtract) and endashes (negate). I guess we should go with convention here.

@flannery-denny , I just went through the OK workbook after some sleep and it's looking pretty good. Given that the stuff on the web is pretty broken (contract arrows missing dashes, mathjax failures, etc) think I'm going to just deploy this morning. It would still REALLY help to get the final go-ahead from you before closing this issue, however.

If you see things that need fixing unrelated to math, either make a new issue or dive in and fix them on your own.

flannery-denny commented 11 months ago

@schanzer I’m glad unicode doesn’t distinguish between negation and subtraction! I avoid materials that do because I think it’s critical that students learn to think more fluidly and distinguish based on context!

Consider -5(3 - 8)

You’d probably read it as β€œNegative five times the quantity three minus eight”

But, when distributing, I end up multiplying β€œnegative 5 times negative 8”

flannery-denny commented 11 months ago

Great work!