all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Thibault Marin <thibault.marin@gmx.com>
To: emacs-orgmode@gnu.org
Cc: Uwe Brauer <oub@mat.ucm.es>
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	[thread overview]
Message-ID: <87muc2snas.fsf@dell-desktop.WORKGROUP> (raw)
In-Reply-To: <87ftj6r537.fsf@mat.ucm.es>

[-- Attachment #1: Type: text/plain, Size: 1462 bytes --]


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 <thibault.marin@gmx.com> 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


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-ox-html-Add-equation-numbers-only-for-numbered-envir.patch --]
[-- Type: text/x-diff, Size: 2836 bytes --]

From 41a7fc5c1580a45610b63b0c357f0e07884ce27b Mon Sep 17 00:00:00 2001
From: thibault <thibault.marin@gmx.com>
Date: Sat, 2 Nov 2019 02:12:38 -0400
Subject: [PATCH] ox-html: Add equation numbers only for numbered environments

* 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.
---
 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
--- 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-environment))
-        (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-environment))
+         (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
--
2.24.0


  parent reply	other threads:[~2019-12-08 18:08 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-01  7:52 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/)] Uwe Brauer
2019-11-01  8:49 ` Fraga, Eric
2019-11-01 13:55   ` Uwe Brauer
2019-11-02  6:22     ` Thibault Marin
2019-11-02  9:38       ` Uwe Brauer
2019-11-02 10:22         ` Fraga, Eric
2019-11-02 17:13           ` Uwe Brauer
2019-12-08 18:08         ` Thibault Marin [this message]
2019-12-08 20:40           ` Nicolas Goaziou
2019-12-08 23:44             ` Thibault Marin
2019-12-09 20:34               ` Nicolas Goaziou
2019-11-01 13:01 ` John Kitchin
2019-11-01 13:59   ` Uwe Brauer
2019-11-01 15:12     ` John Kitchin
2019-11-01 15:32       ` Uwe Brauer
2019-11-01 16:07       ` Uwe Brauer
2019-11-01 16:16         ` [debugger] (was: 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/)]) Uwe Brauer
2019-11-01 18:33         ` 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/)] John Kitchin
2019-11-02  9:18           ` Uwe Brauer
2020-02-11  8:20 ` Bastien
2020-02-11  9:24   ` Uwe Brauer
2020-02-11  9:45     ` Bastien

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87muc2snas.fsf@dell-desktop.WORKGROUP \
    --to=thibault.marin@gmx.com \
    --cc=emacs-orgmode@gnu.org \
    --cc=oub@mat.ucm.es \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.