From: Augusto Stoffel Date: Sat, 12 Oct 2024 14:20:47 +0000 (+0200) Subject: shr.el: Define rendering rule for math tag X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=15304cd57e9a972bf982818e3270593032c95b0f;p=emacs.git shr.el: Define rendering rule for math tag * lisp/net/shr.el (shr-tag-math): New function, see bug#73641. (cherry picked from commit 9c5b6e88e7f851e239721a0fd855fbcd10b5b0a3) --- diff --git a/lisp/net/shr.el b/lisp/net/shr.el index f1062acf7e4..0c37ef67bbb 100644 --- a/lisp/net/shr.el +++ b/lisp/net/shr.el @@ -2264,6 +2264,18 @@ BASE is the URL of the HTML being rendered." (shr-generic dom) (insert ?\N{POP DIRECTIONAL ISOLATE})) +(defun shr-tag-math (dom) + ;; Sometimes a math element contains a plain text annotation + ;; (typically TeX notation) in addition to MathML markup. If we pass + ;; that to `dom-generic', the formula is printed twice. So we select + ;; only the annotation if available. + (shr-generic + (thread-first + dom + (dom-child-by-tag 'semantics) + (dom-child-by-tag 'annotation) + (or dom)))) + ;;; Outline Support (defun shr-outline-search (&optional bound move backward looking-at) "A function that can be used as `outline-search-function' for rendered html.