Merge branch 'bugfix'

This commit is contained in:
Nicolas Goaziou 2022-02-26 10:25:06 +01:00
commit bb6830409d
1 changed files with 14 additions and 6 deletions

View File

@ -178,21 +178,29 @@ Return a hash table with citation references as keys and fields alist as values.
" and ")))
('issued
;; Date are expressed as an array
;; (`date-parts') or a "string (`raw').
;; In both cases, extract the year and
;; associate it to `year' field, for
;; compatibility with BibTeX format.
;; (`date-parts') or a "string (`raw'
;; or `literal'). In both cases,
;; extract the year and associate it
;; to `year' field, for compatibility
;; with BibTeX format.
(let ((date (or (alist-get 'date-parts value)
(alist-get 'literal value)
(alist-get 'raw value))))
(cons 'year
(cond
((consp date)
(caar date))
((stringp date)
(car (split-string date "-")))
(replace-regexp-in-string
(rx
(minimal-match (zero-or-more anything))
(group-n 1 (repeat 4 digit))
(zero-or-more anything))
(rx (backref 1))
date))
(t
(error "Unknown CSL-JSON date format: %S"
date))))))
value))))))
(_
(cons field value))))
item)