|
@@ -221,6 +221,10 @@ Return a hash table with citation references as keys and fields alist as values.
|
|
(let ((entries (make-hash-table :test #'equal))
|
|
(let ((entries (make-hash-table :test #'equal))
|
|
(bibtex-sort-ignore-string-entries t))
|
|
(bibtex-sort-ignore-string-entries t))
|
|
(bibtex-set-dialect dialect t)
|
|
(bibtex-set-dialect dialect t)
|
|
|
|
+ ;; Throw an error if bibliography is malformed.
|
|
|
|
+ (unless (bibtex-validate)
|
|
|
|
+ (user-error "Malformed bibliography at %S"
|
|
|
|
+ (or (buffer-file-name) (current-buffer))))
|
|
(bibtex-map-entries
|
|
(bibtex-map-entries
|
|
(lambda (key &rest _)
|
|
(lambda (key &rest _)
|
|
;; Normalize entries: field names are turned into symbols
|
|
;; Normalize entries: field names are turned into symbols
|
|
@@ -265,21 +269,26 @@ Optional argument INFO is the export state, as a property list."
|
|
(when (or (org-file-has-changed-p file)
|
|
(when (or (org-file-has-changed-p file)
|
|
(not (gethash file org-cite-basic--file-id-cache)))
|
|
(not (gethash file org-cite-basic--file-id-cache)))
|
|
(insert-file-contents file)
|
|
(insert-file-contents file)
|
|
|
|
+ (setf (buffer-file-name) file)
|
|
(puthash file (org-buffer-hash) org-cite-basic--file-id-cache))
|
|
(puthash file (org-buffer-hash) org-cite-basic--file-id-cache))
|
|
- (let* ((file-id (cons file (gethash file org-cite-basic--file-id-cache)))
|
|
|
|
- (entries
|
|
|
|
- (or (cdr (assoc file-id org-cite-basic--bibliography-cache))
|
|
|
|
- (let ((table
|
|
|
|
- (pcase (file-name-extension file)
|
|
|
|
- ("json" (org-cite-basic--parse-json))
|
|
|
|
- ("bib" (org-cite-basic--parse-bibtex 'biblatex))
|
|
|
|
- ("bibtex" (org-cite-basic--parse-bibtex 'BibTeX))
|
|
|
|
- (ext
|
|
|
|
- (user-error "Unknown bibliography extension: %S"
|
|
|
|
- ext)))))
|
|
|
|
- (push (cons file-id table) org-cite-basic--bibliography-cache)
|
|
|
|
- table))))
|
|
|
|
- (push (cons file entries) results)))))
|
|
|
|
|
|
+ (condition-case nil
|
|
|
|
+ (unwind-protect
|
|
|
|
+ (let* ((file-id (cons file (gethash file org-cite-basic--file-id-cache)))
|
|
|
|
+ (entries
|
|
|
|
+ (or (cdr (assoc file-id org-cite-basic--bibliography-cache))
|
|
|
|
+ (let ((table
|
|
|
|
+ (pcase (file-name-extension file)
|
|
|
|
+ ("json" (org-cite-basic--parse-json))
|
|
|
|
+ ("bib" (org-cite-basic--parse-bibtex 'biblatex))
|
|
|
|
+ ("bibtex" (org-cite-basic--parse-bibtex 'BibTeX))
|
|
|
|
+ (ext
|
|
|
|
+ (user-error "Unknown bibliography extension: %S"
|
|
|
|
+ ext)))))
|
|
|
|
+ (push (cons file-id table) org-cite-basic--bibliography-cache)
|
|
|
|
+ table))))
|
|
|
|
+ (push (cons file entries) results))
|
|
|
|
+ (setf (buffer-file-name) nil))
|
|
|
|
+ (error (setq org-cite-basic--file-id-cache nil))))))
|
|
(when info (plist-put info :cite-basic/bibliography results))
|
|
(when info (plist-put info :cite-basic/bibliography results))
|
|
results)))
|
|
results)))
|
|
|
|
|