* [PATCH] oc-csl: Remove spaces before citations in superscript
@ 2024-05-05 9:46 András Simonyi
2024-05-05 12:14 ` Ihor Radchenko
0 siblings, 1 reply; 4+ messages in thread
From: András Simonyi @ 2024-05-05 9:46 UTC (permalink / raw)
To: emacs-orgmode list
[-- Attachment #1: Type: text/plain, Size: 452 bytes --]
Dear All,
there is a rather peculiar set of numeric citation styles (perhaps
most famously, that of Nature's) which sets citation numbers in
superscript -- similarly to footnote numbers, these citations should
not have any space between them and the previous word. The attached
patch checks during export whether a citation is produced by a CSL
style belonging to this category and removes any leading space
present.
Best wishes,
András
[-- Attachment #2: 0001-oc-csl-Remove-spaces-before-citations-in-superscript.patch --]
[-- Type: text/x-patch, Size: 2210 bytes --]
From fe331b9486d4bac31a559067c565b30474246cea Mon Sep 17 00:00:00 2001
From: Andras Simonyi <andras.simonyi@gmail.com>
Date: Sun, 5 May 2024 11:07:45 +0200
Subject: [PATCH] oc-csl: Remove spaces before citations in superscript
* lisp/oc-csl.el (org-cite-csl--create-structure): Remove spaces before citation
if it is in superscript.
(org-cite-csl--style-cite-superscript-p): New function to check whether the used
CSL style produces citations in superscript.
---
lisp/oc-csl.el | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/lisp/oc-csl.el b/lisp/oc-csl.el
index becdaed81..9bbe5e29d 100644
--- a/lisp/oc-csl.el
+++ b/lisp/oc-csl.el
@@ -134,6 +134,7 @@
(declare-function citeproc-render-bib "ext:citeproc")
(declare-function citeproc-hash-itemgetter-from-any "ext:citeproc")
(declare-function citeproc-add-subbib-filters "ext:citeproc")
+(declare-function citeproc-style-cite-superscript-p "ext:citeproc")
(declare-function org-element-interpret-data "org-element" (data))
(declare-function org-element-map "org-element" (data types fun &optional info first-match no-recursion with-affiliated))
@@ -435,6 +436,13 @@ INFO is the export state, as a property list."
(citeproc-proc-style
(org-cite-csl--processor info))))
+(defun org-cite-csl--style-cite-superscript-p (info)
+ "Non-nil when bibliography style produces citations in superscript.
+INFO is the export state, as a property list."
+ (citeproc-style-cite-superscript-p
+ (citeproc-proc-style
+ (org-cite-csl--processor info))))
+
(defun org-cite-csl--nocite-p (citation info)
"Non-nil when CITATION object's style is nocite.
INFO is the export state, as a property list."
@@ -681,6 +689,9 @@ INFO is the export state, as a property list."
(when (and (not footnote) (org-cite-csl--note-style-p info))
(org-cite-adjust-note citation info)
(setq footnote (org-cite-wrap-citation citation info)))
+ ;; Remove white space before CITATION when it is in superscript.
+ (when (org-cite-csl--style-cite-superscript-p info)
+ (org-cite--set-previous-post-blank citation 0 info))
;; Return structure.
(apply #'citeproc-citation-create
`(:note-index
--
2.34.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] oc-csl: Remove spaces before citations in superscript
2024-05-05 9:46 [PATCH] oc-csl: Remove spaces before citations in superscript András Simonyi
@ 2024-05-05 12:14 ` Ihor Radchenko
2024-05-05 14:07 ` András Simonyi
0 siblings, 1 reply; 4+ messages in thread
From: Ihor Radchenko @ 2024-05-05 12:14 UTC (permalink / raw)
To: András Simonyi; +Cc: emacs-orgmode list
András Simonyi <andras.simonyi@gmail.com> writes:
> there is a rather peculiar set of numeric citation styles (perhaps
> most famously, that of Nature's) which sets citation numbers in
> superscript -- similarly to footnote numbers, these citations should
> not have any space between them and the previous word. The attached
> patch checks during export whether a citation is produced by a CSL
> style belonging to this category and removes any leading space
> present.
LGTM.
Feel free to push.
--
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] oc-csl: Remove spaces before citations in superscript
2024-05-05 12:14 ` Ihor Radchenko
@ 2024-05-05 14:07 ` András Simonyi
2024-05-06 11:13 ` Ihor Radchenko
0 siblings, 1 reply; 4+ messages in thread
From: András Simonyi @ 2024-05-05 14:07 UTC (permalink / raw)
To: Ihor Radchenko; +Cc: emacs-orgmode list
Thanks Ihor, I have pushed it to main.
best wishes,
András
On Sun, 5 May 2024 at 14:13, Ihor Radchenko <yantar92@posteo.net> wrote:
>
> András Simonyi <andras.simonyi@gmail.com> writes:
>
> > there is a rather peculiar set of numeric citation styles (perhaps
> > most famously, that of Nature's) which sets citation numbers in
> > superscript -- similarly to footnote numbers, these citations should
> > not have any space between them and the previous word. The attached
> > patch checks during export whether a citation is produced by a CSL
> > style belonging to this category and removes any leading space
> > present.
>
> LGTM.
> Feel free to push.
>
> --
> Ihor Radchenko // yantar92,
> Org mode contributor,
> Learn more about Org mode at <https://orgmode.org/>.
> Support Org development at <https://liberapay.com/org-mode>,
> or support my work at <https://liberapay.com/yantar92>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] oc-csl: Remove spaces before citations in superscript
2024-05-05 14:07 ` András Simonyi
@ 2024-05-06 11:13 ` Ihor Radchenko
0 siblings, 0 replies; 4+ messages in thread
From: Ihor Radchenko @ 2024-05-06 11:13 UTC (permalink / raw)
To: András Simonyi; +Cc: emacs-orgmode list
András Simonyi <andras.simonyi@gmail.com> writes:
> Thanks Ihor, I have pushed it to main.
Thanks!
Applied. <- a control message for Woof!
https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=288e0a11c
^ reference to make life easier when digging mailing list archives for
future maintainers.
--
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2024-05-06 11:12 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-05-05 9:46 [PATCH] oc-csl: Remove spaces before citations in superscript András Simonyi
2024-05-05 12:14 ` Ihor Radchenko
2024-05-05 14:07 ` András Simonyi
2024-05-06 11:13 ` Ihor Radchenko
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.