From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Augusto Stoffel Newsgroups: gmane.emacs.bugs Subject: bug#73641: 30.0.90; Math in EWW/shr Date: Sat, 05 Oct 2024 16:01:36 +0200 Message-ID: <87ttdqmywv.fsf@gmail.com> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="18421"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) To: 73641@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sat Oct 05 16:02:25 2024 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1sx5MX-0004g5-8C for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 05 Oct 2024 16:02:25 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sx5M8-0006eM-0Y; Sat, 05 Oct 2024 10:02:00 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sx5M5-0006eC-Vv for bug-gnu-emacs@gnu.org; Sat, 05 Oct 2024 10:01:58 -0400 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sx5M5-0002ES-Nm for bug-gnu-emacs@gnu.org; Sat, 05 Oct 2024 10:01:57 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=MIME-Version:Date:From:To:Subject; bh=gEKAi+vjM8EXSpPQ+m+XqV+FbWKw9ujhCqU8FVqC3KY=; b=YB3poKCvX1wftNgKoWAbjYLvksIR9NcgO2xkEmdGU35cHm4HvChF4+z4a2S6xwwB1WtwozV0PupZcqM1TcU4tW66De/QhtSi2NItHUscZP90S32wq+2N3txcVrBtkcajd/uAR2jgrmNW06+URN5qQMFVGiqVGiviCvgHl4HMWFmbusSezjEt33l0zBSv3M5BaBcWnzu5UorNjxS/vfAVMvtwoRS+sXGhTG2+H/t0wdz4EUnW/CrWWFsqqkairCAfCygdE1VDqd2n5dV+A4e8o5S4t6io916tC+1p4lbXMNyafoPNnvG91nvQNr8WXH1HLM2CtPnn+QyBWnXpvf/itQ==; Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1sx5MA-0001Fa-8c for bug-gnu-emacs@gnu.org; Sat, 05 Oct 2024 10:02:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Augusto Stoffel Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 05 Oct 2024 14:02:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 73641 X-GNU-PR-Package: emacs X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.17281369134785 (code B ref -1); Sat, 05 Oct 2024 14:02:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 5 Oct 2024 14:01:53 +0000 Original-Received: from localhost ([127.0.0.1]:39331 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sx5M0-0001F6-W3 for submit@debbugs.gnu.org; Sat, 05 Oct 2024 10:01:53 -0400 Original-Received: from lists.gnu.org ([209.51.188.17]:45652) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1sx5Lz-0001Ez-Jo for submit@debbugs.gnu.org; Sat, 05 Oct 2024 10:01:52 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sx5Lu-0006dh-G2 for bug-gnu-emacs@gnu.org; Sat, 05 Oct 2024 10:01:46 -0400 Original-Received: from mail-ed1-x534.google.com ([2a00:1450:4864:20::534]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sx5Ls-0002EH-Tx for bug-gnu-emacs@gnu.org; Sat, 05 Oct 2024 10:01:46 -0400 Original-Received: by mail-ed1-x534.google.com with SMTP id 4fb4d7f45d1cf-5c718bb04a3so3913355a12.3 for ; Sat, 05 Oct 2024 07:01:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1728136900; x=1728741700; darn=gnu.org; h=mime-version:user-agent:message-id:date:subject:to:from:from:to:cc :subject:date:message-id:reply-to; bh=gEKAi+vjM8EXSpPQ+m+XqV+FbWKw9ujhCqU8FVqC3KY=; b=RrFcd46JZFxi+4+Sl+FXQWdFtT0S+N9mU6ps5wO2sN8r2BFfDbPDVHaOwTp+l21WP/ gnJjeOAdN/epddH/dBgWfdsGU2ofNktIY0QJSlxjeQRdXQFzI23Z6zSXrIDnUteEVz/V 3yb3kevGAMp8PqHQk45Lx2wKCkhSGyFt7X4pT9myyj0eBkuk/TiBUF+oHmyg4LbPmnv6 sRkmMnGkSH+JhC/eBv6mQueFrATStRAq2QJm3nsiFiSk3MeEvEfm2PZSTCvUXs0WCEUw 6LPMZv8qfxCfXaqWGMgpreJoRU7ta3ZlGg03qMfOOhJ2sNHWIfl6cRAMlXcPeuO6pGzU /Ifg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728136900; x=1728741700; h=mime-version:user-agent:message-id:date:subject:to:from :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=gEKAi+vjM8EXSpPQ+m+XqV+FbWKw9ujhCqU8FVqC3KY=; b=OT5ONEYI7qKMCfSrtVIlO8IkcOgXJIRlRkstzYtlLUV/WDi6pKmCLfL7W+HbxAO+3M f6zRI2JTZPOt3Wdq5UzK/A6JH/70t+E2nDeq/j+Z07Ql9Hml11MDVn7ndALW2VhKQ3kT bIUNB7zR4fAdzfEeFDH1/6WNSUuNc7p43F9nKNccuBXJKnHE559bfar36m/x25iv+3sS M6FVEQDEEZWUANoswG5Ut7We888BFEE3Vp2JmPmmh+L9aEeYdkxQYEv/gUAA3f6D8baC VOp6qoqianPwsyJdiY6UMUkLFxv5/eDiaT8XSN7BSegaccOAxeuGbch7H1QIVs0M5TnU mClw== X-Gm-Message-State: AOJu0YwYzrS7wE4JJTr591oZGeg0RBLIdu7M1Bg5FktbAEmy8rlbML2N 9J4ipcvmO5Ygp3vTj1Xl8N5Q2+10vTjE+6JBeJYXEPapesRdDvvGxMg9sA== X-Google-Smtp-Source: AGHT+IG8h8fnzZe2cgCqbcqAkzMcHrgL0XYRUKHiTXI/WJq3Tt8JIndNsCb2sdkwMMOjUHGCwU2azw== X-Received: by 2002:a17:906:ee87:b0:a8b:ddf4:46f1 with SMTP id a640c23a62f3a-a991c077d4amr717486966b.63.1728136900301; Sat, 05 Oct 2024 07:01:40 -0700 (PDT) Original-Received: from ars3 ([2a02:8109:8a87:ff00::d6f6]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a99309aa6afsm129266466b.112.2024.10.05.07.01.39 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 05 Oct 2024 07:01:39 -0700 (PDT) Received-SPF: pass client-ip=2a00:1450:4864:20::534; envelope-from=arstoffel@gmail.com; helo=mail-ed1-x534.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:293038 Archived-At: 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 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 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.)