Added the ability to disambiguate between citations using autobib.

original commit: 2c63ce2286da4113baa9c32d5d75bf8189bcbb35
This commit is contained in:
James Ian Johnson 2012-03-07 12:31:55 -05:00 committed by Sam Tobin-Hochstadt
parent ce2dc58b4c
commit ca961ce44b

View File

@ -37,6 +37,9 @@
;; render the use of a citation. ;; render the use of a citation.
(define (add-cite group bib-entry which with-specific? disambiguation) (define (add-cite group bib-entry which with-specific? disambiguation)
(let ([key (auto-bib-key bib-entry)]) (let ([key (auto-bib-key bib-entry)])
(when disambiguation
(for ([bib disambiguation])
(hash-set! (bib-group-ht group) (auto-bib-key bib) bib)))
(hash-set! (bib-group-ht group) key bib-entry) (hash-set! (bib-group-ht group) key bib-entry)
(make-delayed-element (make-delayed-element
(lambda (renderer part ri) (lambda (renderer part ri)
@ -54,15 +57,15 @@
))) ;; should be a list of bib-entries with same author/date ))) ;; should be a list of bib-entries with same author/date
(define disambiguation* (define disambiguation*
(add-between (for/list ([bib (in-list disambiguation)]) (add-between (for/list ([bib (in-list disambiguation)])
(define key (auto-bib-key bib))
(define maybe-disambiguation (define maybe-disambiguation
(resolve-get part ri `(autobib-disambiguation ,(auto-bib-key bib)))) (resolve-get part ri `(autobib-disambiguation key)))
(case maybe-disambiguation (case maybe-disambiguation
[(unambiguous) #f] [(unambiguous) #f]
[else maybe-disambiguation])) [else (make-link-element #f (list maybe-disambiguation) `(autobib ,key))]))
",")) ","))
(cond [(not (car disambiguation*)) '()] ;; the bib was unambiguous (cond [(not (car disambiguation*)) '()] ;; the bib was unambiguous
[else [else disambiguation*])]
(list (make-link-element #f (list disambiguation*) `(autobib ,(auto-bib-key bib-entry))))])]
[else '()]))) [else '()])))
(lambda () "(???)") (lambda () "(???)")
(lambda () "(???)")))) (lambda () "(???)"))))