diff --git a/citeproc-cite.el b/citeproc-cite.el index 731a2be..c501e52 100644 --- a/citeproc-cite.el +++ b/citeproc-cite.el @@ -40,6 +40,8 @@ (require 'citeproc-formatters) (require 'citeproc-sort) (require 'citeproc-subbibs) +(require 'citeproc-biblatex) +(require 'citeproc-date) (declare-function citeproc-style-category "citeproc-style" (style)) @@ -79,6 +81,20 @@ Each function takes a single argument, a rich-text, and returns a post-processed rich-text value. The functions are applied in the order they appear in the list.") +(defun citeproc-cite--internalize-locator (cite) + "Internalize a CITE locator by parsing it into several fields.' +If the \"|\" separator is present in the locator then parse it +into `locator', `locator-extra' and `locator-date' and update +CITE with these fields accordingly. Returns the possibly modified +CITE." + (when-let ((locator (alist-get 'locator cite)) + (separator-pos (cl-position ?| locator))) + (setf (alist-get 'locator cite) (substring locator 0 separator-pos)) + (push (cons 'locator-date (citeproc-date-parse (citeproc-blt--to-csl-date "1971-01-12"))) + cite) + (push (cons 'locator-extra (substring locator (1+ separator-pos))) cite)) + cite) + (defun citeproc-cite--varlist (cite) "Return the varlist belonging to CITE." (let* ((itd (alist-get 'itd cite)) @@ -89,7 +105,8 @@ order they appear in the list.") '(label locator suppress-author suppress-date stop-rendering-at position near-note first-reference-note-number ignore-et-al - bib-entry locator-only use-short-title)) + bib-entry locator-only use-short-title + locator-extra locator-date)) cite))) (nconc cite-vv item-vv))) diff --git a/citeproc-lib.el b/citeproc-lib.el index 1d626c2..aa0400b 100644 --- a/citeproc-lib.el +++ b/citeproc-lib.el @@ -38,7 +38,7 @@ ) (defconst citeproc--date-vars - '(accessed available-date event-date issued original-date submitted) + '(accessed available-date event-date issued original-date submitted locator-date) "CSL date variables.") (defconst citeproc--name-vars diff --git a/citeproc.el b/citeproc.el index 192b044..ad731fb 100644 --- a/citeproc.el +++ b/citeproc.el @@ -87,10 +87,12 @@ CITATIONS is a list of `citeproc-citation' structures." (new-ids (--remove (gethash it itemdata) uniq-ids))) ;; Add all new items in one pass (citeproc-proc-put-items-by-id proc new-ids) - ;; Add itemdata to the cite structs and add them to the cite queue. + ;; Internalize the cites dealing with locator-extra if present, add itemdata to + ;; the cite structs and add them to the cite queue. (dolist (citation citations) (setf (citeproc-citation-cites citation) - (--map (cons (cons 'itd (gethash (alist-get 'id it) itemdata)) it) + (--map (cons (cons 'itd (gethash (alist-get 'id it) itemdata)) + (citeproc-cite--internalize-locator it)) (citeproc-citation-cites citation))) (queue-append (citeproc-proc-citations proc) citation)) (setf (citeproc-proc-finalized proc) nil))))