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.ma...@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
From 41a7fc5c1580a45610b63b0c357f0e07884ce27b Mon Sep 17 00:00:00 2001 From: thibault <thibault.ma...@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