Support multiple arguments to `citet', provided that all authors are equal?
- Also refactors indexing to separately index date and author
This commit is contained in:
parent
7c32898cb2
commit
c945927776
|
@ -1,4 +1,4 @@
|
||||||
#lang at-exp scheme/base
|
#lang at-exp racket/base
|
||||||
(require scribble/manual
|
(require scribble/manual
|
||||||
scribble/core
|
scribble/core
|
||||||
scribble/decode
|
scribble/decode
|
||||||
|
@ -41,6 +41,25 @@
|
||||||
(lambda () "(???)")
|
(lambda () "(???)")
|
||||||
(lambda () "(???)")))
|
(lambda () "(???)")))
|
||||||
|
|
||||||
|
(define (add-inline-cite group bib-entries)
|
||||||
|
(for ([i bib-entries]) (hash-set! (bib-group-ht group) i #t))
|
||||||
|
(when (and (pair? (cdr bib-entries)) (not (apply equal? (map auto-bib-author bib-entries))))
|
||||||
|
(error 'citet "citet must be used with identical authors, given ~a" (map auto-bib-author bib-entries)))
|
||||||
|
(make-element
|
||||||
|
#f
|
||||||
|
(list (add-cite group (car bib-entries) 'autobib-author)
|
||||||
|
'nbsp
|
||||||
|
"("
|
||||||
|
(let loop ([keys bib-entries])
|
||||||
|
(if (null? (cdr keys))
|
||||||
|
(add-cite group (car keys) 'autobib-date)
|
||||||
|
(make-element
|
||||||
|
#f
|
||||||
|
(list (loop (list (car keys)))
|
||||||
|
"; "
|
||||||
|
(loop (cdr keys))))))
|
||||||
|
")")))
|
||||||
|
|
||||||
(define (add-cites group bib-entries)
|
(define (add-cites group bib-entries)
|
||||||
(make-element
|
(make-element
|
||||||
#f
|
#f
|
||||||
|
@ -48,7 +67,12 @@
|
||||||
"("
|
"("
|
||||||
(let loop ([keys bib-entries])
|
(let loop ([keys bib-entries])
|
||||||
(if (null? (cdr keys))
|
(if (null? (cdr keys))
|
||||||
(add-cite group (car keys) 'autobib-cite)
|
(make-element
|
||||||
|
#f
|
||||||
|
(list
|
||||||
|
(add-cite group (car keys) 'autobib-author)
|
||||||
|
" "
|
||||||
|
(add-cite group (car keys) 'autobib-date)))
|
||||||
(make-element
|
(make-element
|
||||||
#f
|
#f
|
||||||
(list (loop (list (car keys)))
|
(list (loop (list (car keys)))
|
||||||
|
@ -87,23 +111,17 @@
|
||||||
`(autobib ,(auto-bib-key k))))
|
`(autobib ,(auto-bib-key k))))
|
||||||
(lambda (ci)
|
(lambda (ci)
|
||||||
(collect-put! ci
|
(collect-put! ci
|
||||||
`(autobib-cite ,(auto-bib-key k))
|
`(autobib-author ,(auto-bib-key k))
|
||||||
(make-element
|
(make-element
|
||||||
#f
|
#f
|
||||||
(list
|
(list
|
||||||
(author-element-cite (auto-bib-author k))
|
(author-element-cite (auto-bib-author k)))))
|
||||||
" "
|
|
||||||
(auto-bib-date k))))
|
|
||||||
(collect-put! ci
|
(collect-put! ci
|
||||||
`(autobib-inline ,(auto-bib-key k))
|
`(autobib-date ,(auto-bib-key k))
|
||||||
(make-element
|
(make-element
|
||||||
#f
|
#f
|
||||||
(list
|
(list
|
||||||
(author-element-cite (auto-bib-author k))
|
(auto-bib-date k))))))))))
|
||||||
'nbsp
|
|
||||||
"("
|
|
||||||
(auto-bib-date k)
|
|
||||||
")")))))))))
|
|
||||||
bibs)))
|
bibs)))
|
||||||
null)))
|
null)))
|
||||||
|
|
||||||
|
@ -112,8 +130,8 @@
|
||||||
(define group (make-bib-group (make-hasheq)))
|
(define group (make-bib-group (make-hasheq)))
|
||||||
(define (~cite bib-entry . bib-entries)
|
(define (~cite bib-entry . bib-entries)
|
||||||
(add-cites group (cons bib-entry bib-entries)))
|
(add-cites group (cons bib-entry bib-entries)))
|
||||||
(define (citet bib-entry)
|
(define (citet bib-entry . bib-entries)
|
||||||
(add-cite group bib-entry 'autobib-inline))
|
(add-inline-cite group (cons bib-entry bib-entries)))
|
||||||
(define (generate-bibliography #:tag [tag "doc-bibliography"])
|
(define (generate-bibliography #:tag [tag "doc-bibliography"])
|
||||||
(gen-bib tag group))))
|
(gen-bib tag group))))
|
||||||
|
|
||||||
|
|
|
@ -31,11 +31,11 @@ space. It has the contract
|
||||||
]
|
]
|
||||||
|
|
||||||
The function bound to @scheme[citet-id] generates an element suitable
|
The function bound to @scheme[citet-id] generates an element suitable
|
||||||
for use as a noun---referring to a document or its author---for a
|
for use as a noun---referring to a document or its author---for one
|
||||||
single bibliography entry. It has the contract
|
or more bibliography entries which share an author. It has the contract
|
||||||
|
|
||||||
@schemeblock[
|
@schemeblock[
|
||||||
(bib? . -> . element?)
|
((bib?) () (listof bib?) . ->* . element?)
|
||||||
]
|
]
|
||||||
|
|
||||||
The function bound to @scheme[generate-bibliography-id] generates the
|
The function bound to @scheme[generate-bibliography-id] generates the
|
||||||
|
|
Loading…
Reference in New Issue
Block a user