diff --git a/collects/scriblib/bibtex.rkt b/collects/scriblib/bibtex.rkt index 01ca4dbe..414192c8 100644 --- 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 index 6e660f76..438b527b 100644 --- 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 index f916bc27..60d53ea5 100644 --- 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") - - (generate-bibliography-id))) + + (define actual-path + (make-temporary-file "~a-bibtex.txt")) + + (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 new file mode 100644 index 00000000..c29bdb96 --- /dev/null +++ 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 index 81408e36..9d5d44b0 100644 --- 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 +}