From mboxrd@z Thu Jan 1 00:00:00 1970 From: Thibault Marin Subject: Re: Bug: org-mime-htmlize generates unwanted equations numbers in mail [9.2.5 (release_9.2.5-521-gdea0c7 @ /home/oub/emacs/site-lisp/packages/org/)] Date: Sun, 08 Dec 2019 13:08:11 -0500 Message-ID: <87muc2snas.fsf@dell-desktop.WORKGROUP> References: <87tv7o6nki.fsf@mat.ucm.es> <87imo37lay.fsf@mat.ucm.es> <87pniapzk9.fsf@dell-desktop.WORKGROUP> <87ftj6r537.fsf@mat.ucm.es> Reply-To: thibault.marin@gmx.com Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Return-path: Received: from eggs.gnu.org ([2001:470:142:3::10]:51858) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ie0yh-000369-BO for emacs-orgmode@gnu.org; Sun, 08 Dec 2019 13:08:20 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ie0yf-0006yz-Sj for emacs-orgmode@gnu.org; Sun, 08 Dec 2019 13:08:19 -0500 Received: from mout.gmx.net ([212.227.17.22]:47813) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ie0yf-0006lB-AG for emacs-orgmode@gnu.org; Sun, 08 Dec 2019 13:08:17 -0500 In-reply-to: <87ftj6r537.fsf@mat.ucm.es> List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: "Emacs-orgmode" To: emacs-orgmode@gnu.org Cc: Uwe Brauer --=-=-= Content-Type: text/plain Dear maintainers, Following-up on this bug report regarding the handling of unnumbered equation environments in HTML export, I would like to propose the attached patch. The patch simply removes the caption for unnumbered environments. Could you please let me know whether this could be considered for a merge and if there any comments or suggestions to improve it? Thanks in advance. thibault On 2019-11-02T05:38:04-0400, Uwe Brauer wrote: >>> "TM" == Thibault Marin writes: > Hi, > I think I wrote some of that code, I was not trying to support > "unnumbered" environments. If I understand correctly, this is what you > are trying to get. > The attached patch attempts to solve this. Currently, `displaymath' and > `*' environments do not get numbers, I am not sure if there are other > environments that should not get numbers; please let me know if you have > others in mind. Thanks very much, I pulled the latest master, applied your patch, compiled and installed, and everything works *now* as expected. The only environments without numbers which I use regularly are. align* and sometimes eqnarray* but these are all covered > If you (and others) could test and/or review the patch, we could > probably get it merged at some point. That would be great, thanks again @Eric, I wonder why you did not get these numbers without the patch! Uwe --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0001-ox-html-Add-equation-numbers-only-for-numbered-envir.patch Content-Transfer-Encoding: quoted-printable =46rom 41a7fc5c1580a45610b63b0c357f0e07884ce27b Mon Sep 17 00:00:00 2001 From: thibault Date: Sat, 2 Nov 2019 02:12:38 -0400 Subject: [PATCH] ox-html: Add equation numbers only for numbered environme= nts * lisp/ox-html.el (org-html-latex-environment): Add caption to numbered environments only (org-html--latex-environment-numbered-p): Determine whether a latex environment should be numbered. =2D-- lisp/ox-html.el | 36 ++++++++++++++++++++++++++---------- 1 file changed, 26 insertions(+), 10 deletions(-) diff --git a/lisp/ox-html.el b/lisp/ox-html.el index 83d0fd2e9..55983ff2f 100644 =2D-- a/lisp/ox-html.el +++ b/lisp/ox-html.el @@ -2914,19 +2914,35 @@ For instance, change an 'equation' environment to = 'equation*'." latex-frag nil nil 1) nil nil 1)) +(defun org-html--latex-environment-numbered-p (latex-frag) + "Return t if LATEX-ENV contains a numbered environment. + +Environments with a star (*) character and displaymath are not numbered." + (not (some 'identity + (mapcar (lambda (el) + (string-match el latex-frag)) + '("\\`[ \t]*\\\\begin{[^*}]+?[*]}" + "\\`[ \t]*\\\\begin{displaymath}"))))) + (defun org-html-latex-environment (latex-environment _contents info) "Transcode a LATEX-ENVIRONMENT element from Org to HTML. CONTENTS is nil. INFO is a plist holding contextual information." - (let ((processing-type (plist-get info :with-latex)) - (latex-frag (org-remove-indentation - (org-element-property :value latex-environment))) - (attributes (org-export-read-attribute :attr_html latex-environme= nt)) - (label (and (org-element-property :name latex-environment) - (org-export-get-reference latex-environment info))) - (caption (number-to-string - (org-export-get-ordinal - latex-environment info nil - #'org-html--math-environment-p)))) + (let* ((processing-type (plist-get info :with-latex)) + (latex-frag (org-remove-indentation + (org-element-property :value latex-environment))) + (attributes (org-export-read-attribute :attr_html latex-environm= ent)) + (label (and (org-element-property :name latex-environment) + (org-export-get-reference latex-environment info))) + (caption (when (org-html--latex-environment-numbered-p + latex-frag) + (number-to-string + (org-export-get-ordinal + latex-environment info nil + (lambda (l info) + (and (org-html--math-environment-p l) + (org-html--latex-environment-numbered-p + (org-remove-indentation + (org-element-property :value l)))))))))) (cond ((memq processing-type '(t mathjax)) (org-html-format-latex =2D- 2.24.0 --=-=-=--