* [PATCH] Fix numbering of captioned images
@ 2021-04-30 2:52 Pablo Barraza Cornejo
2021-04-30 4:54 ` Kyle Meyer
0 siblings, 1 reply; 4+ messages in thread
From: Pablo Barraza Cornejo @ 2021-04-30 2:52 UTC (permalink / raw)
To: emacs-orgmode
[-- Attachment #1: Type: text/plain, Size: 510 bytes --]
When exporting to HTML, the exporter is supposed to check if there
are additional constraints over a paragraph using
`org-html-standalone-image-predicate'. A misplaced quote causes
`org-html-standalone-image-p' to not apply them.
To number captions on images the `org-html-paragraph' binds
`org-html-standalone-image-predicate' to
`org-html--has-caption-p', but since it gets ignored,
`org-export-get-ordinal' considers all standalone images, not just
captioned ones. This throws off the numbering.
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-ox-html.el-inline-image-export-Fix-caption-numbering.patch --]
[-- Type: text/x-patch, Size: 1035 bytes --]
From 85e0b2da37f914458d71bd3a5797298ca3a4e0ce Mon Sep 17 00:00:00 2001
From: Pablo Barraza Cornejo <pbarrazacornejo@gmail.com>
Date: Thu, 29 Apr 2021 20:15:08 -0600
Subject: [PATCH] ox-html.el/inline-image export: Fix caption numbering.
* lisp/ox-html.el (org-html-standalone-image-p): Remove quote which
causes `org-html-standalone-image-p' to not check if `org-html-standalone-image-predicate' is bound.
TINYCHANGE
---
lisp/ox-html.el | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lisp/ox-html.el b/lisp/ox-html.el
index 47122314c..df270b22b 100644
--- a/lisp/ox-html.el
+++ b/lisp/ox-html.el
@@ -3039,7 +3039,7 @@ images, set it to:
(`paragraph element)
(`link (org-export-get-parent element)))))
(and (eq (org-element-type paragraph) 'paragraph)
- (or (not (fboundp 'org-html-standalone-image-predicate))
+ (or (not (fboundp org-html-standalone-image-predicate))
(funcall org-html-standalone-image-predicate paragraph))
(catch 'exit
(let ((link-count 0))
--
2.31.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] Fix numbering of captioned images
2021-04-30 2:52 [PATCH] Fix numbering of captioned images Pablo Barraza Cornejo
@ 2021-04-30 4:54 ` Kyle Meyer
2021-04-30 5:44 ` Pablo Barraza Cornejo
0 siblings, 1 reply; 4+ messages in thread
From: Kyle Meyer @ 2021-04-30 4:54 UTC (permalink / raw)
To: Pablo Barraza Cornejo; +Cc: emacs-orgmode
Pablo Barraza Cornejo writes:
> When exporting to HTML, the exporter is supposed to check if there
> are additional constraints over a paragraph using
> `org-html-standalone-image-predicate'. A misplaced quote causes
> `org-html-standalone-image-p' to not apply them.
Thanks for catching the issue and for sending a patch. This looks like
a regression introduced way back in 8.2.7 by ab1ce2a75 (ox-html: Fix
spurious "figure" divs on empty paragraphs, 2014-05-15).
> Subject: [PATCH] ox-html.el/inline-image export: Fix caption numbering.
The convention in this project is to leave off the trailing period from
the subject.
> * lisp/ox-html.el (org-html-standalone-image-p): Remove quote which
> causes `org-html-standalone-image-p' to not check if `org-html-standalone-image-predicate' is bound.
Please fill this line to ~70 characters (set in the repo's
.dir-locals.el).
> (and (eq (org-element-type paragraph) 'paragraph)
> - (or (not (fboundp 'org-html-standalone-image-predicate))
> + (or (not (fboundp org-html-standalone-image-predicate))
> (funcall org-html-standalone-image-predicate paragraph))
This quote will indeed result in the fboundp call always returning nil:
(let ((org-html-standalone-image-predicate #'org-html--has-caption-p))
(fboundp 'org-html-standalone-image-predicate)) ; => nil
(let ((org-html-standalone-image-predicate #'org-html--has-caption-p))
(fboundp org-html-standalone-image-predicate)) ; => t
However, the proposed change will introduce another issue.
org-html-standalone-image-predicate is defined as
(defvar org-html-standalone-image-predicate)
That means it's left uninitialized:
(defvar my/foo) ; => my/foo
(boundp 'my/foo) ; => nil
(fboundp my/foo) ; error: (void-variable my/foo)
What about returning to the boundp/fboundp combination that was in place
before ab1ce2a75?
(and (boundp 'my/foo)
(fboundp my/foo)) ; => nil
(let ((my/foo #'ignore))
(and (boundp 'my/foo)
(fboundp my/foo))) ; => t
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] Fix numbering of captioned images
2021-04-30 4:54 ` Kyle Meyer
@ 2021-04-30 5:44 ` Pablo Barraza Cornejo
2021-05-01 4:43 ` Kyle Meyer
0 siblings, 1 reply; 4+ messages in thread
From: Pablo Barraza Cornejo @ 2021-04-30 5:44 UTC (permalink / raw)
To: Kyle Meyer; +Cc: emacs-orgmode
[-- Attachment #1: Type: text/plain, Size: 354 bytes --]
Kyle Meyer writes:
> What about returning to the boundp/fboundp combination that was
> in place
> before ab1ce2a75?
>
> (and (boundp 'my/foo)
> (fboundp my/foo)) ; => nil
>
> (let ((my/foo #'ignore))
> (and (boundp 'my/foo)
> (fboundp my/foo))) ; => t
Sounds good to me! I've modified the patch to reflect this change.
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-ox-html.el-inline-image-export-Fix-caption-numbering.patch --]
[-- Type: text/x-patch, Size: 1141 bytes --]
From a8d653efcdbe42e887aba7f8895de413ffaa53c4 Mon Sep 17 00:00:00 2001
From: Pablo Barraza Cornejo <pbarrazacornejo@gmail.com>
Date: Thu, 29 Apr 2021 20:15:08 -0600
Subject: [PATCH] ox-html.el/inline-image export: Fix caption numbering
* lisp/ox-html.el (org-html-standalone-image-p): Remove quote which
causes `org-html-standalone-image-p' to not check if
`org-html-standalone-image-predicate' is fbound and see if it's
initialized.
TINYCHANGE
---
lisp/ox-html.el | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/lisp/ox-html.el b/lisp/ox-html.el
index 47122314c..12d511c28 100644
--- a/lisp/ox-html.el
+++ b/lisp/ox-html.el
@@ -3039,7 +3039,8 @@ images, set it to:
(`paragraph element)
(`link (org-export-get-parent element)))))
(and (eq (org-element-type paragraph) 'paragraph)
- (or (not (fboundp 'org-html-standalone-image-predicate))
+ (or (not (and (boundp 'org-html-standalone-image-predicate)
+ (fboundp org-html-standalone-image-predicate)))
(funcall org-html-standalone-image-predicate paragraph))
(catch 'exit
(let ((link-count 0))
--
2.31.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
end of thread, other threads:[~2021-05-01 4:43 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-04-30 2:52 [PATCH] Fix numbering of captioned images Pablo Barraza Cornejo
2021-04-30 4:54 ` Kyle Meyer
2021-04-30 5:44 ` Pablo Barraza Cornejo
2021-05-01 4:43 ` Kyle Meyer
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).