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
View this message in rfc822 format
[Message part 1 (text/plain, inline)]
Your bug report
#73641: 30.0.90; Math in EWW/shr
which was filed against the emacs package, has been closed.
The explanation is attached below, along with your original report.
If you require more details, please reply to 73641 <at> debbugs.gnu.org.
--
73641: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=73641
GNU Bug Tracking System
Contact help-debbugs <at> gnu.org with problems
[Message part 2 (message/rfc822, inline)]
> From: Augusto Stoffel <arstoffel <at> gmail.com>
> Cc: jb <at> jeremybryant.net, 73641 <at> debbugs.gnu.org, sacha <at> sachachua.com
> Date: Tue, 29 Oct 2024 07:44:42 +0100
>
> On Sun, 27 Oct 2024 at 12:25, Eli Zaretskii wrote:
>
> >> From: Augusto Stoffel <arstoffel <at> gmail.com>
> >> Cc: jb <at> jeremybryant.net, 73641 <at> debbugs.gnu.org, sacha <at> sachachua.com
> >> Date: Sat, 12 Oct 2024 19:13:48 +0200
> >>
> >> On Sat, 12 Oct 2024 at 18:07, Eli Zaretskii wrote:
> >>
> >> > Thanks, but can we please have a comment here explaining why we do
> >> > that?
> >>
> >> How about this?
> >
> > As I said, this LGTM, but I'm unsure how you'd like to proceed.
> > Should I install this, and you will follow up with some code which
> > uses this new function?
>
> >From my perspective it can be installed, and no follow up code is
> needed. At some point shr calls (intern (format "shr-tag-%s" ...)), so
> the code that uses the new function is already there.
Thanks, installed on master, and closing the bug.
[Message part 3 (message/rfc822, inline)]
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.