Skip to content

Commit 0dc27a8

Browse files
dlukesyantar92
authored andcommitted
oc-basic.el: Stringify year from CSL-JSON date-parts
* lisp/oc-basic.el (org-cite-basic--parse-json): Make sure year extracted from date-parts is returned as string. Raise error if original type other than number or string. The stringifiation is motivated by errors like the following on Emacs 28 with nativecomp: Error during redisplay: (jit-lock-function 544) signaled (wrong-type-argument "Argument is not a string or a secondary string: 2007") Additionally, the type check will warn users about problems in their CSL-JSON bibliographies. Fixes https://list.orgmode.org/875ykv4k2q.fsf@localhost/T/#t TINYCHANGE
1 parent 02a22d6 commit 0dc27a8

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

lisp/oc-basic.el

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,14 @@ Return a hash table with citation references as keys and fields alist as values.
189189
(cons 'year
190190
(cond
191191
((consp date)
192-
(caar date))
192+
(let ((year (caar date)))
193+
(cond
194+
((numberp year) (number-to-string year))
195+
((stringp year) year)
196+
(t
197+
(error
198+
"First element of CSL-JSON date-parts should be a number or string, got %s: %S"
199+
(type-of year) year)))))
193200
((stringp date)
194201
(replace-regexp-in-string
195202
(rx

0 commit comments

Comments
 (0)