scriblib/autbib: add `#:note' support

original commit: 7645bacec1e9c9455a1c08f17b251cabdf1a3ebc
This commit is contained in:
Matthew Flatt 2013-05-21 13:43:31 -06:00
parent d8f2cc1bd9
commit ca96ca2c2e
2 changed files with 14 additions and 8 deletions

View File

@ -39,7 +39,7 @@
(define colbibnumber-style (make-style "Autocolbibnumber" autobib-style-extras)) (define colbibnumber-style (make-style "Autocolbibnumber" autobib-style-extras))
(define colbibentry-style (make-style "Autocolbibentry" autobib-style-extras)) (define colbibentry-style (make-style "Autocolbibentry" autobib-style-extras))
(define-struct auto-bib (author date title location url is-book? key specific)) (define-struct auto-bib (author date title location url note is-book? key specific))
(define-struct bib-group (ht)) (define-struct bib-group (ht))
(define-struct (author-element element) (names cite)) (define-struct (author-element element) (names cite))
@ -324,12 +324,13 @@
null)) null))
(define (bib->entry bib style disambiguation render-date-bib i) (define (bib->entry bib style disambiguation render-date-bib i)
(define-values (author date title location url is-book?) (define-values (author date title location url note is-book?)
(values (auto-bib-author bib) (values (auto-bib-author bib)
(auto-bib-date bib) (auto-bib-date bib)
(auto-bib-title bib) (auto-bib-title bib)
(auto-bib-location bib) (auto-bib-location bib)
(auto-bib-url bib) (auto-bib-url bib)
(auto-bib-note bib)
(auto-bib-is-book? bib))) (auto-bib-is-book? bib)))
(make-element (send style entry-style) (make-element (send style entry-style)
(append (append
@ -356,7 +357,8 @@
(decode-content (list (render-date-bib date)))) (decode-content (list (render-date-bib date))))
".") ".")
null) null)
(if url `(" " ,(link url (make-element 'url (list url)))) null)))) (if url `(" " ,(link url (make-element 'url (list url)))) null)
(if note `(" " ,note) null))))
(define-syntax (define-cite stx) (define-syntax (define-cite stx)
(syntax-parse stx (syntax-parse stx
@ -404,13 +406,14 @@
#:is-book? [is-book? #f] #:is-book? [is-book? #f]
#:location [location #f] #:location [location #f]
#:date [date #f] #:date [date #f]
#:url [url #f]) #:url [url #f]
#:note [note #f])
(define author* (define author*
(cond [(not author) #f] (cond [(not author) #f]
[(author-element? author) author] [(author-element? author) author]
[else (parse-author author)])) [else (parse-author author)]))
(define parsed-date (understand-date date)) (define parsed-date (understand-date date))
(make-auto-bib author* parsed-date title location url is-book? (make-auto-bib author* parsed-date title location url note is-book?
(content->string (content->string
(make-element #f (make-element #f
(append (append
@ -418,7 +421,8 @@
(list title) (list title)
(if location (decode-content (list location)) null) (if location (decode-content (list location)) null)
(if date (decode-content (list (default-render-date-bib parsed-date))) null) (if date (decode-content (list (default-render-date-bib parsed-date))) null)
(if url (list (link url (make-element 'url (list url)))) null)))) (if url (list (link url (make-element 'url (list url)))) null)
(if note (list note) null))))
"")) ""))
(define (in-bib bib where) (define (in-bib bib where)
@ -428,6 +432,7 @@
(auto-bib-title bib) (auto-bib-title bib)
(auto-bib-location bib) (auto-bib-location bib)
(auto-bib-url bib) (auto-bib-url bib)
(auto-bib-note bib)
(auto-bib-is-book? bib) (auto-bib-is-book? bib)
(auto-bib-key bib) (auto-bib-key bib)
;; "where" is the only specific part of auto-bib elements currently. ;; "where" is the only specific part of auto-bib elements currently.

View File

@ -121,12 +121,13 @@ Returns @racket[#t] if @racket[v] is a value produced by
[#:is-book? is-book? any/c #f] [#:is-book? is-book? any/c #f]
[#:location location any/c #f] [#:location location any/c #f]
[#:date date (or/c #f date? exact-nonnegative-integer? string?) #f] [#:date date (or/c #f date? exact-nonnegative-integer? string?) #f]
[#:url url string? #f]) [#:url url string? #f]
[#:note note any/c #f])
bib?]{ bib?]{
Produces a value that represents a document to cite. Except for Produces a value that represents a document to cite. Except for
@racket[is-book?] and @racket[url], the arguments are used as @racket[is-book?] and @racket[url], the arguments are used as
elements, except that @racket[#f] means that the information is not content, except that @racket[#f] means that the information is not
supplied. Functions like @racket[proceedings-location], supplied. Functions like @racket[proceedings-location],
@racket[author-name], and @racket[authors] help produce elements in a @racket[author-name], and @racket[authors] help produce elements in a
standard format. standard format.