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 18:44:48 -0500 Message-ID: <87lfrms7pr.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> <87muc2snas.fsf@dell-desktop.WORKGROUP> <87pngytusp.fsf@nicolasgoaziou.fr> 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]:56644) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ie6ET-0005bi-4O for emacs-orgmode@gnu.org; Sun, 08 Dec 2019 18:45:02 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ie6ER-0005yn-N5 for emacs-orgmode@gnu.org; Sun, 08 Dec 2019 18:44:56 -0500 Received: from mout.gmx.net ([212.227.15.18]:60133) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ie6ER-0005tz-8P for emacs-orgmode@gnu.org; Sun, 08 Dec 2019 18:44:55 -0500 In-reply-to: <87pngytusp.fsf@nicolasgoaziou.fr> 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: Nicolas Goaziou Cc: Uwe Brauer , emacs-orgmode@gnu.org --=-=-= Content-Type: text/plain Hi, thanks for the quick review. On 2019-12-08T15:40:54-0500, Nicolas Goaziou wrote: > > +(defun org-html--latex-environment-numbered-p (latex-frag) > ^^^^^^^^^^ > latex-env I changed the name and docstring to `element' (similar to `org-html--math-environment-p'. > > + "Return t if LATEX-ENV contains a numbered environment. > Non-nil if... Done. > However, I suggest to make this function operate on the element itself, > not its value, much like `org-html--math-environment-p'. Done (if I understood correctly). > I suggest merging the two regexps into a single one, and use: > (not (string-match-p REGEXP latex-env)) Done > Operating directly on the element will be a bit nicer. Why do you need > `org-remove-indentation'? I looks like I didn't. I removed it. > Could you send an updated patch and provide an ORG-NEWS entry (on top of > master)? See attached. Thanks, thibault --=-=-= 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 3cf6b644f2b7d806b15dd5e76914b1547ef77a96 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-- etc/ORG-NEWS | 8 ++++++++ lisp/ox-html.el | 32 ++++++++++++++++++++++---------- 2 files changed, 30 insertions(+), 10 deletions(-) diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS index e61b97fa5..f20e4ea98 100644 =2D-- a/etc/ORG-NEWS +++ b/etc/ORG-NEWS @@ -21,6 +21,14 @@ just as if it was at outline level 0. Inheritance for = properties will work also for this level. In other words: defining things in a property drawer before the first headline will make them "inheritable" for all headlines. + +*** Restrict the addition of a label to LaTeX equations in HTML export to= numbered environments only + +Prevent the addition of a label to LaTeX math environments in HTML +export when not in a numbered environment (numbered environment are +everything but =3Ddisplaymath=3D and environments ending with a star +character, e.g. =3Dequation*=3D). + ** New functions *** ~org-columns-toggle-or-columns-quit~ =3D=3D bound to ~org-columns-toggle-or-columns-quit~ replaces th= e diff --git a/lisp/ox-html.el b/lisp/ox-html.el index 83d0fd2e9..2f2210aa1 100644 =2D-- a/lisp/ox-html.el +++ b/lisp/ox-html.el @@ -2914,19 +2914,31 @@ For instance, change an 'equation' environment to = 'equation*'." latex-frag nil nil 1) nil nil 1)) +(defun org-html--latex-environment-numbered-p (element) + "Non-nil if ELEMENT contains a numbered LaTeX math environment. + +Environments with a star (*) character and displaymath are not numbered." + (not (string-match-p + "\\`[ \t]*\\\\begin{\\(.*\\*\\|displaymath\\)}" + (org-element-property :value element)))) + (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-environment) + (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 l)))))))) (cond ((memq processing-type '(t mathjax)) (org-html-format-latex =2D- 2.24.0 --=-=-=--