From: Thibault Marin <thibault.marin@gmx.com>
To: Nicolas Goaziou <mail@nicolasgoaziou.fr>
Cc: Uwe Brauer <oub@mat.ucm.es>, emacs-orgmode@gnu.org
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 [thread overview]
Message-ID: <87lfrms7pr.fsf@dell-desktop.WORKGROUP> (raw)
In-Reply-To: <87pngytusp.fsf@nicolasgoaziou.fr>
[-- Attachment #1: Type: text/plain, Size: 1007 bytes --]
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
[-- 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: 3583 bytes --]
From 3cf6b644f2b7d806b15dd5e76914b1547ef77a96 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.
---
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
--- 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 =displaymath= and environments ending with a star
+character, e.g. =equation*=).
+
** New functions
*** ~org-columns-toggle-or-columns-quit~
=<C-c C-c>= bound to ~org-columns-toggle-or-columns-quit~ replaces the
diff --git a/lisp/ox-html.el b/lisp/ox-html.el
index 83d0fd2e9..2f2210aa1 100644
--- 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-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-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
--
2.24.0
next prev parent reply other threads:[~2019-12-08 23:45 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
2019-12-08 20:40 ` Nicolas Goaziou
2019-12-08 23:44 ` Thibault Marin [this message]
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=87lfrms7pr.fsf@dell-desktop.WORKGROUP \
--to=thibault.marin@gmx.com \
--cc=emacs-orgmode@gnu.org \
--cc=mail@nicolasgoaziou.fr \
--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.