From b33bd7bf338de295bce0f89f9ff1c2c16ae92c98 Mon Sep 17 00:00:00 2001 From: Jay McCarthy Date: Thu, 29 Mar 2012 15:44:05 -0600 Subject: [PATCH] Autobib errors with no authors or dates on a bib entry. Test included. original commit: 13e36fbec4d50813ced3ae80db8c1a641952f719 --- collects/scriblib/autobib.rkt | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/collects/scriblib/autobib.rkt b/collects/scriblib/autobib.rkt index dc91c3ab..343d8968 100644 --- a/collects/scriblib/autobib.rkt +++ b/collects/scriblib/autobib.rkt @@ -34,6 +34,9 @@ (define-struct (author-element element) (names cite)) (define-struct (other-author-element author-element) ()) +(define (author-element-names* x) + (and x (author-element-names x))) + ;; render the use of a citation. (define (add-cite group bib-entry which with-specific? disambiguation) (let ([key (auto-bib-key bib-entry)]) @@ -95,9 +98,9 @@ (for ([i bib-entries]) (hash-set! (bib-group-ht group) (auto-bib-key i) i)) (when (and (pair? (cdr bib-entries)) - (not (apply equal? (map (compose author-element-names auto-bib-author) bib-entries)))) + (not (apply equal? (map (compose author-element-names* auto-bib-author) bib-entries)))) (error 'citet "citet must be used with identical authors, given ~a" - (map (compose author-element-names auto-bib-author) bib-entries))) + (map (compose author-element-names* auto-bib-author) bib-entries))) (make-element #f (list (add-cite group (car bib-entries) 'autobib-author #f #f) @@ -108,7 +111,7 @@ (define (add-cites group bib-entries sort? bib-datestring (date-year date))))) (define (default-date a, 1 -> b, etc. (define (default-disambiguation n) @@ -186,9 +191,10 @@ #f (list (author-element-cite (extract-bib-author bib))))) ;; store the date - (collect-put! ci - `(autobib-date ,(auto-bib-key bib)) ;; (list which key) - (make-element #f (list (render-date-cite (auto-bib-date bib))))) + (when (auto-bib-date bib) + (collect-put! ci + `(autobib-date ,(auto-bib-key bib)) ;; (list which key) + (make-element #f (list (render-date-cite (auto-bib-date bib)))))) ;; store how to disambiguate it from other like citations. (collect-put! ci `(autobib-disambiguation ,(auto-bib-key bib))