commit 8f72339a18d3770ab71a0212525aa32760f7471f
parent abbbc0201607c6189d54070f11a433cf9e7d808a
Author: Jay McCarthy <jay@racket-lang.org>
Date: Mon, 25 Mar 2013 08:13:18 -0600
Support mastersthesis, clarify docs, and add test of rendering
original commit: b3b10a39f5543729a4b2a427eb550f15c575227a
Diffstat:
5 files changed, 45 insertions(+), 3 deletions(-)
diff --git a/collects/scriblib/bibtex.rkt b/collects/scriblib/bibtex.rkt
@@ -69,7 +69,8 @@
(perror ip 'read-entry "Parsing string, expected }, got ~v; tag is ~v; string is ~v" c tag string)])]
[c
(perror ip 'read-entry "Parsing string, expected =, got ~v; tag is ~v" c tag)])]
- [(app string-downcase "comment")
+ [(or (app string-downcase "comment")
+ (app string-downcase "preamble"))
(read-char ip)
(let loop ()
(read-until (λ (c) (or (char=? c #\{) (char=? c #\}))) ip)
@@ -261,6 +262,12 @@
(make-bib #:title (raw-attr "title")
#:author (parse-author (raw-attr "author"))
#:date (raw-attr "year")
+ #:url (raw-attr "url"))]
+ ["mastersthesis"
+ (make-bib #:title (raw-attr "title")
+ #:author (parse-author (raw-attr "author"))
+ #:date (raw-attr "year")
+ #:location (raw-attr "school")
#:url (raw-attr "url"))]
["techreport"
(make-bib #:title (raw-attr "title")
diff --git a/collects/scriblib/scribblings/bibtex.scrbl b/collects/scriblib/scribblings/bibtex.scrbl
@@ -17,6 +17,10 @@ Uses @racket[define-cite] from @racketmodname[scriblib/autobib], but augments th
Each string is broken along spaces into citations keys that are looked up in the BibTeX database and turned into @racket[bib?] structures.
+The only BibTeX entries that are supported are: @litchar{misc},
+@litchar{book}, @litchar{article}, @litchar{inproceedings},
+@litchar{webpage}, @litchar{mastersthesis}, and @litchar{techreport}.
+
}
@defstruct*[bibdb ([raw (hash/c string? (hash/c string? string?))]
diff --git a/collects/tests/scriblib/bibtex.rkt b/collects/tests/scriblib/bibtex.rkt
@@ -1,10 +1,14 @@
#lang racket
(require racket/runtime-path
tests/eli-tester
- scriblib/bibtex)
+ scriblib/bibtex
+ scribble/render
+ (prefix-in text: scribble/text-render))
(define-runtime-path example.bib "example.bib")
+(define-runtime-path expected-path "bibtex.txt")
+
(test
(let ()
(define example (path->bibdb example.bib))
@@ -19,15 +23,26 @@
(define-bibtex-cite example.bib
~cite-id citet-id generate-bibliography-id)
+ (~cite-id "salib:starkiller")
(~cite-id "cryptoeprint:2000:067")
(~cite-id "Tobin-Hochstadt:2011fk")
(~cite-id "cryptoeprint:2000:067" "Tobin-Hochstadt:2011fk")
(~cite-id "cryptoeprint:2000:067 Tobin-Hochstadt:2011fk")
+ (citet-id "salib:starkiller")
(citet-id "cryptoeprint:2000:067")
(citet-id "Tobin-Hochstadt:2011fk")
(citet-id "Tobin-Hochstadt:2011fk" "Tobin-Hochstadt:2011fk")
(citet-id "Tobin-Hochstadt:2011fk Tobin-Hochstadt:2011fk")
+
+ (define actual-path
+ (make-temporary-file "~a-bibtex.txt"))
- (generate-bibliography-id)))
+ (render (list (generate-bibliography-id))
+ (list actual-path)
+ #:dest-dir (path-only actual-path)
+ #:render-mixin text:render-mixin)
+
+ (test
+ (file->string actual-path) => (file->string expected-path))))
diff --git a/collects/tests/scriblib/bibtex.txt b/collects/tests/scriblib/bibtex.txt
@@ -0,0 +1,8 @@
+Bibliography
+
+Ran Canetti. Universally Composable Security: A New Paradigm for
+Cryptographic Protocols. 2000.
+Michael Salib. Starkiller: A Static Type Inferencer and Compiler for
+Python. Massachusetts Institute of Technology, 2004.
+Sam Tobin-Hochstadt, Vincent St-Amour, Ryan Culpepper, Matthew Flatt,
+and Matthias Felleisen. Languages as Libraries. In Proc. PLDI, 2011.
diff --git a/collects/tests/scriblib/example.bib b/collects/tests/scriblib/example.bib
@@ -397,3 +397,11 @@ Book{landru21,
}
@preamble{"This bibliography was generated on \today"}
+
+@mastersthesis{salib:starkiller,
+ author = "Michael Salib",
+ title = "Starkiller: A Static Type Inferencer and Compiler for Python",
+ school = "Massachusetts Institute of Technology",
+ month = "May",
+ year = 2004
+}