Generalizing define-bibtex-cite
original commit: 875c20119d962c79ef3760a491bb24a57a2e51b5
This commit is contained in:
parent
cb442ffa94
commit
3437fda407
|
@ -191,8 +191,17 @@
|
|||
(define-bibtex-cite bib-pth
|
||||
~cite-id citet-id generate-bibliography-id . options)
|
||||
(begin
|
||||
(define bibtex-db (path->bibdb bib-pth))
|
||||
(define-cite autobib-cite autobib-citet generate-bibliography-id . options)
|
||||
(define-bibtex-cite* bib-pth
|
||||
autobib-cite autobib-citet
|
||||
~cite-id citet-id)))
|
||||
|
||||
(define-syntax-rule
|
||||
(define-bibtex-cite* bib-pth
|
||||
autobib-cite autobib-citet
|
||||
~cite-id citet-id)
|
||||
(begin
|
||||
(define bibtex-db (path->bibdb bib-pth))
|
||||
(define ((make-citer citer) f . r)
|
||||
(apply citer
|
||||
(filter-map
|
||||
|
@ -286,4 +295,5 @@
|
|||
(provide (struct-out bibdb)
|
||||
path->bibdb
|
||||
bibtex-parse
|
||||
define-bibtex-cite)
|
||||
define-bibtex-cite
|
||||
define-bibtex-cite*)
|
||||
|
|
|
@ -11,9 +11,20 @@
|
|||
|
||||
@defform[(define-bibtex-cite bib-pth ~cite-id citet-id generate-bibliography-id . options)]{
|
||||
|
||||
This expands into:
|
||||
@racketblock[
|
||||
(begin
|
||||
(define-cite autobib-cite autobib-citet generate-bibliography-id . options)
|
||||
(define-bibtex-cite* bib-pth
|
||||
autobib-cite autobib-citet
|
||||
~cite-id citet-id))]
|
||||
}
|
||||
|
||||
@defform[(define-bibtex-cite* bib-pth autobib-cite autobib-citet ~cite-id citet-id)]{
|
||||
|
||||
Parses @racket[bib-pth] as a BibTeX database.
|
||||
|
||||
Uses @racket[define-cite] from @racketmodname[scriblib/autobib], but augments the @racket[~cite-id] and @racket[citet-id] functions so that rather than accepting @racket[bib?] structures, they accept citation key strings. Any @racket[options] are given to @racket[define-cite] without interpretation.
|
||||
Augments @racket[autobib-cite] and @racket[autobib-citet] into @racket[~cite-id] and @racket[citet-id] functions so that rather than accepting @racket[bib?] structures, they accept citation key strings.
|
||||
|
||||
Each string is broken along spaces into citations keys that are looked up in the BibTeX database and turned into @racket[bib?] structures.
|
||||
|
||||
|
|
|
@ -11,12 +11,11 @@
|
|||
(define-runtime-path normal-expected-path "bibtex.normal.txt")
|
||||
(define-runtime-path number-expected-path "bibtex.number.txt")
|
||||
|
||||
(define-syntax-rule (test-render expected-path options body)
|
||||
(define-syntax-rule (test-render* definer expected-path body generate-bibliography-id)
|
||||
(let ()
|
||||
(define-bibtex-cite example.bib
|
||||
~cite-id citet-id generate-bibliography-id . options)
|
||||
definer
|
||||
|
||||
(body ~cite-id citet-id)
|
||||
body
|
||||
|
||||
(define actual-path
|
||||
(make-temporary-file "~a-bibtex.txt"))
|
||||
|
@ -29,6 +28,23 @@
|
|||
(test
|
||||
(file->string actual-path) => (file->string expected-path))))
|
||||
|
||||
(define-syntax-rule (test-render expected-path options body)
|
||||
(begin
|
||||
(test-render* (define-bibtex-cite example.bib
|
||||
~cite-id citet-id generate-bibliography-id . options)
|
||||
expected-path
|
||||
(body ~cite-id citet-id)
|
||||
generate-bibliography-id)
|
||||
(test-render* (begin
|
||||
(define-cite autobib-cite autobib-citet
|
||||
generate-bibliography-id . options)
|
||||
(define-bibtex-cite* example.bib
|
||||
autobib-cite autobib-citet
|
||||
~cite-id citet-id))
|
||||
expected-path
|
||||
(body ~cite-id citet-id)
|
||||
generate-bibliography-id)))
|
||||
|
||||
(test
|
||||
(let ()
|
||||
(define example (path->bibdb example.bib))
|
||||
|
|
Loading…
Reference in New Issue
Block a user