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: Sat, 02 Nov 2019 02:22:46 -0400 Message-ID: <87pniapzk9.fsf@dell-desktop.WORKGROUP> References: <87tv7o6nki.fsf@mat.ucm.es> <87imo37lay.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]:36864) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iQmoI-0003zP-9M for emacs-orgmode@gnu.org; Sat, 02 Nov 2019 02:22:55 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iQmoG-0006QD-Vf for emacs-orgmode@gnu.org; Sat, 02 Nov 2019 02:22:54 -0400 Received: from mout.gmx.net ([212.227.15.18]:53313) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iQmoG-0006H1-GA for emacs-orgmode@gnu.org; Sat, 02 Nov 2019 02:22:52 -0400 Received: from dell-desktop ([72.74.81.32]) by mail.gmx.com (mrgmx005 [212.227.17.184]) with ESMTPSA (Nemesis) id 1MXp9i-1iRx0G2rVs-00Y89U for ; Sat, 02 Nov 2019 07:22:48 +0100 In-reply-to: <87imo37lay.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 --=-=-= Content-Type: text/plain 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. If you (and others) could test and/or review the patch, we could probably get it merged at some point. Thanks, thibault On 2019-11-01T09:55:49-0400, Uwe Brauer wrote: >>> "FE" == Fraga, Eric writes: > On Friday, 1 Nov 2019 at 08:52, Uwe Brauer wrote: >> As the attached screenshots show, the png contain unwanted equations >> numbers (displaymath adn equation* have been used which should not >> generate those numbers). > Uwe, > when I invoke org-mime-htmlize with your equations, as written, I do not get any equation numbers. Thanks, so it is my setting. I wounder how can I debug this? --=-=-= 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 d66392545762f0ed890a772e08dad3655ea7e522 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.23.0 --=-=-=--