GNU bug report logs -
#73641
30.0.90; Math in EWW/shr
Previous Next
Reported by: Augusto Stoffel <arstoffel <at> gmail.com>
Date: Sat, 5 Oct 2024 14:02:02 UTC
Severity: normal
Found in version 30.0.90
Done: Eli Zaretskii <eliz <at> gnu.org>
Bug is archived. No further changes may be made.
Full log
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
shr has a tendency to display garbled math formulas. For example
opening https://developer.mozilla.org/en-US/docs/Web/MathML/Examples/MathML_Pythagorean_Theorem
in EWW shows this:
> if a and b are the legs and c is the hypotenuse, then a2+b2=c2a^2 +
> b^2 = c^2.
This happens because <math> HTML elements tend to contain a MathML
description of the formula and possibly some "annotations", so what we
see above is "a2+b2=c2", the naive rendering of the MathML, concatenated
with "a^2 + b^2 = c^2" which is an annotation saying what the formula is
in TeX notation.
So in as a first improvement I would like to suggest adding this
definition:
(defun shr-tag-math (dom)
(shr-generic (thread-first
dom
(dom-child-by-tag 'semantics)
(dom-child-by-tag 'annotation)
(or dom))))
The above page then gets rendered like this:
> Specifically, if a and b are the legs and c is the hypotenuse, then
> a^2 + b^2 = c^2.
In other words, only the TeX annotation is displayed, which is as good
as it gets when trying to show math as plain text, IMO.
It is possible for the <math> element to include a SVG rendition of the
formula. We could consider displaying that if available (not sure how
common it is, though). Also, we might consider including infrastructure
to render MathML, but this would require external programs (there is no
reason to reinvent MathJax). I've done that in one of my packages, see
this commit for the relevant code:
https://github.com/astoff/devdocs.el/commit/04a8793072f1fc7c23f115e2c7ee83ce669b6fa4
(Actually, I added a version of the above to two of my packages already,
so I think it's pretty clear Emacs should have some general
math-rendering infrastructure.)
This bug report was last modified 262 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.