all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* bug#73641: 30.0.90; Math in EWW/shr
@ 2024-10-05 14:01 Augusto Stoffel
  2024-10-05 15:24 ` Eli Zaretskii
  0 siblings, 1 reply; 13+ messages in thread
From: Augusto Stoffel @ 2024-10-05 14:01 UTC (permalink / raw)
  To: 73641

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.)





^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2024-10-29  6:44 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-10-05 14:01 bug#73641: 30.0.90; Math in EWW/shr Augusto Stoffel
2024-10-05 15:24 ` Eli Zaretskii
2024-10-10  6:41   ` Augusto Stoffel
2024-10-10  7:43     ` Eli Zaretskii
2024-10-10 10:49       ` Augusto Stoffel
2024-10-10 11:34         ` Eli Zaretskii
2024-10-10 20:24           ` Jeremy Bryant via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-10-12 14:24             ` Augusto Stoffel
2024-10-12 15:07               ` Eli Zaretskii
2024-10-12 17:13                 ` Augusto Stoffel
2024-10-12 18:16                   ` Eli Zaretskii
2024-10-27 10:25                   ` Eli Zaretskii
2024-10-29  6:44                     ` Augusto Stoffel

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.