News for hackers. Stuff that matters.
Re:MathJax – Beautiful and accessible math in all browsers by dllu on Friday October 13, 2023 @06:18PM (#37876238)
My blog (eg https://daniel.lawrence.lu/blog/y2021m09d08/ ) uses MathJax on the serverside (via mathjax-node-cli) which gets rendered into SVG images. I find that this is nice because it's faster and the page doesn't jump around all the time while the equations are rendering. Equations can be cached. I can add alt text for accessibility.

Common mistakes that other people make when using an image-based approach include:

* failing to apply the proper sizing and offset for the baseline * using a raster PNG format which is bigger and looks fuzzy

Re:MathJax – Beautiful and accessible math in all browsers by wolverine876 on Friday October 13, 2023 @06:24PM (#37876280)
How do you feel about the tradeoff of losing copy-and-paste functionality? I'm not implying it's a bad decision - there are tradeoffs in every option - but I'm wondering what you thought about it.
Re:MathJax – Beautiful and accessible math in all browsers by dllu on Friday October 13, 2023 @06:33PM (#37876346)
With the alt text, copying and pasting actually works as you expect.
Re:MathJax – Beautiful and accessible math in all browsers by wolverine876 on Friday October 13, 2023 @06:58PM (#37876521)
Ohhh I didn't know that. For others trying it:

* Right-click > copy copies the image itself

* Highlight the image, then Right-click > copy gives you the alt text

Re:MathJax – Beautiful and accessible math in all browsers by hju22_-3 on Friday October 13, 2023 @08:37PM (#37877071)
Huh, that's surprising. I've never actually checked but always considered that they'd give the same result. Somewhat cumbersome, if one considers how few people know of this functionality though.
Re:MathJax – Beautiful and accessible math in all browsers by miki123211 on Friday October 13, 2023 @07:10PM (#37876607)
> I can add alt text for accessibility

Math ML is much more than alt text. It presents mathematical expressions in a hierarchical, tree-like way, letting you explore parts of the expression in detail. Depending on the implementation, you may also be able to adjust the verbosity or render the expression in Braille using one of a few different math codes.

If you want accessible math, just alt text is not enough.

Re:MathJax – Beautiful and accessible math in all browsers by dllu on Friday October 13, 2023 @08:20PM (#37876992)
True. The alt text in my case contains the LaTeX which contains all the information to define the equation. But you're right that a standard like MathML would allow for other surfaces like Braille.
Re:MathJax – Beautiful and accessible math in all browsers by extra88 on Friday October 13, 2023 @09:22PM (#37877286)
MathJax can generate MathML from Latex and all modern browsers render MathML now.
Re:MathJax – Beautiful and accessible math in all browsers by omaranto on Saturday October 14, 2023 @12:30AM (#37878083)
Woah! Chrome finally added support for MathML! I had no idea, apparently it landed in January of this year.
Re:MathJax – Beautiful and accessible math in all browsers by gofixurcode on Saturday October 14, 2023 @12:17AM (#37878040)
The way I have it set up in my use case is that if you click on the equation it switches to a brief description of what the equation is doing. Pretty useful for quickly parsing it for someone unfamiliar.
Re:MathJax – Beautiful and accessible math in all browsers by teleforce on Sunday October 15, 2023 @02:05AM (#37887314)
Check out Pretext, it's write once, read anywhere software package that supports cross platform publication output including Braille [1],[2].

It's a very powerful authoring and publication system, for example if you're writing an interactive Math book, you could use <sage/> blocks to specify language e.g. Python, write around code blocks, providing references to equations, etc [3].

Fun facts, PreTeXt was originally called MathBook XML thus it has robust support for mathematical formulas [4],[5].

Last but not least, don't let XML being used in Pretext scared you off since XML is great for markup language and anything todo with publication online, printed, Braille, etc [6].

[1] PreTeXt Write Once, Read Anywhere:

https://pretextbook.org/

[2] PreTeXt: Write Once Read Anywhere Authoring and Publishing System:

https://news.ycombinator.com/item?id=37231025

[3] The PreTeXt Guide: 3.17 Sage:

https://pretextbook.org/doc/guide/html/overview-sage.html

[4] The PreTeXt Guide: 4.9 Mathematics:

https://pretextbook.org/doc/guide/html/topic-mathematics.htm...

[5] The PreTeXt Guide: Chapter 13 Mathematics

https://pretextbook.org/doc/guide/html/basics-ch-math.html

[6] XML is better than YAML – Hear me out:

https://news.ycombinator.com/item?id=37586580

Re:MathJax – Beautiful and accessible math in all browsers by creata on Friday October 13, 2023 @08:40PM (#37877091)
Tangent: I asked MathJax to generate (inline) SVG and assistive MathML, and it turns out that the generated assistive MathML is perfectly copiable, at least in Firefox! But bizarrely, MathJax adds CSS to make it nonselectable. You can undo it by adding another style:

    mjx-assistive-mml {
      user-select: auto;
    }
Maybe they have a good reason for not making it selectable, but I can't think of one.
Re:MathJax – Beautiful and accessible math in all browsers by mbid on Saturday October 14, 2023 @05:01AM (#37879074)
If you're going to send out math as SVGs anyway, you can also just use your normal latex to PDF renderer (e.g. pdflatex) on each formula, and then convert the output PDFs to SVGs. That way, you get the same output you'd get with latex, and you can also use latex packages that aren't supported by MathJax (e.g. tikz-cd). I've prototyped a latex to html converter [1] based on that approach, but it's probably not ready for serious use. Here's an example: https://www.mbid.me/lcc-model/

[1] https://github.com/mbid/latex-to-html