Fix case sensitivity issues in bibtex
This commit is contained in:
parent
d71ad4d18a
commit
d7883e172f
|
@ -49,7 +49,7 @@
|
||||||
(match (read-until (λ (c) (or (char=? c #\{)
|
(match (read-until (λ (c) (or (char=? c #\{)
|
||||||
(char=? c #\()))
|
(char=? c #\()))
|
||||||
ip)
|
ip)
|
||||||
[(app string-downcase "string")
|
[(app string-foldcase "string")
|
||||||
(slurp-whitespace ip)
|
(slurp-whitespace ip)
|
||||||
(match (read-char ip)
|
(match (read-char ip)
|
||||||
[#\{
|
[#\{
|
||||||
|
@ -70,8 +70,8 @@
|
||||||
(perror ip 'read-entry "Parsing string, expected }, got ~v; tag is ~v; string is ~v" c tag string)])]
|
(perror ip 'read-entry "Parsing string, expected }, got ~v; tag is ~v; string is ~v" c tag string)])]
|
||||||
[c
|
[c
|
||||||
(perror ip 'read-entry "Parsing string, expected =, got ~v; tag is ~v" c tag)])]
|
(perror ip 'read-entry "Parsing string, expected =, got ~v; tag is ~v" c tag)])]
|
||||||
[(or (app string-downcase "comment")
|
[(or (app string-foldcase "comment")
|
||||||
(app string-downcase "preamble"))
|
(app string-foldcase "preamble"))
|
||||||
(read-char ip)
|
(read-char ip)
|
||||||
(let loop ()
|
(let loop ()
|
||||||
(read-until (λ (c) (or (char=? c #\{) (char=? c #\}))) ip)
|
(read-until (λ (c) (or (char=? c #\{) (char=? c #\}))) ip)
|
||||||
|
@ -83,7 +83,7 @@
|
||||||
[typ
|
[typ
|
||||||
(read-char ip)
|
(read-char ip)
|
||||||
(slurp-whitespace ip)
|
(slurp-whitespace ip)
|
||||||
(define label (read-until (λ (c) (char=? c #\,)) ip))
|
(define label (string-foldcase (read-until (λ (c) (char=? c #\,)) ip)))
|
||||||
(read-char ip)
|
(read-char ip)
|
||||||
(define alist
|
(define alist
|
||||||
(let loop ()
|
(let loop ()
|
||||||
|
@ -110,11 +110,11 @@
|
||||||
[c
|
[c
|
||||||
(perror ip 'read-entry "Parsing entry tag, expected =, got ~v; label is ~v; atag is ~v" c label atag)])])))
|
(perror ip 'read-entry "Parsing entry tag, expected =, got ~v; label is ~v; atag is ~v" c label atag)])])))
|
||||||
(hash-set! ENTRY-DB label
|
(hash-set! ENTRY-DB label
|
||||||
(hash-set alist 'type typ))]))
|
(hash-set alist 'type (string-foldcase typ)))]))
|
||||||
|
|
||||||
(define (read-tag ip)
|
(define (read-tag ip)
|
||||||
(slurp-whitespace ip)
|
(slurp-whitespace ip)
|
||||||
(string-downcase
|
(string-foldcase
|
||||||
(read-until
|
(read-until
|
||||||
(λ (c) (or (char-whitespace? c)
|
(λ (c) (or (char-whitespace? c)
|
||||||
(char=? c #\=)
|
(char=? c #\=)
|
||||||
|
@ -197,13 +197,7 @@
|
||||||
autobib-cite autobib-citet
|
autobib-cite autobib-citet
|
||||||
~cite-id citet-id)))
|
~cite-id citet-id)))
|
||||||
|
|
||||||
(define-syntax-rule
|
(define ((make-citer bibtex-db citer) f . r)
|
||||||
(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
|
(apply citer
|
||||||
(filter-map
|
(filter-map
|
||||||
(λ (key)
|
(λ (key)
|
||||||
|
@ -211,8 +205,15 @@
|
||||||
(generate-bib bibtex-db key)))
|
(generate-bib bibtex-db key)))
|
||||||
(append-map (curry regexp-split #px"\\s+")
|
(append-map (curry regexp-split #px"\\s+")
|
||||||
(cons f r)))))
|
(cons f r)))))
|
||||||
(define ~cite-id (make-citer autobib-cite))
|
|
||||||
(define citet-id (make-citer autobib-citet))))
|
(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 ~cite-id (make-citer bibtex-db autobib-cite))
|
||||||
|
(define citet-id (make-citer bibtex-db autobib-citet))))
|
||||||
|
|
||||||
;; Seems a little redundant to convert latex escapes into unicode only to
|
;; Seems a little redundant to convert latex escapes into unicode only to
|
||||||
;; convert them back into latex, but we need to sort authors so we can't
|
;; convert them back into latex, but we need to sort authors so we can't
|
||||||
|
@ -450,9 +451,9 @@
|
||||||
|
|
||||||
(define (generate-bib db key)
|
(define (generate-bib db key)
|
||||||
(match-define (bibdb raw bibs) db)
|
(match-define (bibdb raw bibs) db)
|
||||||
(hash-ref! bibs key
|
(hash-ref! bibs (string-foldcase key)
|
||||||
(λ ()
|
(λ ()
|
||||||
(define the-raw (hash-ref raw key (λ () (error 'bibtex "Unknown citation ~e" key))))
|
(define the-raw (hash-ref raw (string-foldcase key) (λ () (error 'bibtex "Unknown citation ~e" key))))
|
||||||
(define (raw-attr a [def #f])
|
(define (raw-attr a [def #f])
|
||||||
(hash-ref the-raw a def))
|
(hash-ref the-raw a def))
|
||||||
(define (raw-attr* a)
|
(define (raw-attr* a)
|
||||||
|
|
|
@ -6,3 +6,4 @@ Bibliography
|
||||||
Python. Massachusetts Institute of Technology, 2004.
|
Python. Massachusetts Institute of Technology, 2004.
|
||||||
[3]Sam Tobin-Hochstadt, Vincent St-Amour, Ryan Culpepper, Matthew Flatt,
|
[3]Sam Tobin-Hochstadt, Vincent St-Amour, Ryan Culpepper, Matthew Flatt,
|
||||||
and Matthias Felleisen. Languages as Libraries. In Proc. PLDI, 2011.
|
and Matthias Felleisen. Languages as Libraries. In Proc. PLDI, 2011.
|
||||||
|
[4]ZA ZAuThOr. StrIngS ArE TerriblE. 2000.
|
||||||
|
|
|
@ -74,7 +74,8 @@
|
||||||
(λ (~cite-id citet-id)
|
(λ (~cite-id citet-id)
|
||||||
(citet-id "salib:starkiller")
|
(citet-id "salib:starkiller")
|
||||||
(citet-id "cryptoeprint:2000:067")
|
(citet-id "cryptoeprint:2000:067")
|
||||||
(citet-id "Tobin-Hochstadt:2011fk")))
|
(citet-id "Tobin-Hochstadt:2011fk")
|
||||||
|
(citet-id "anannoyingkey")))
|
||||||
(test-render latex-escapes-path (#:style number-style)
|
(test-render latex-escapes-path (#:style number-style)
|
||||||
(λ (~cite-id citet-id)
|
(λ (~cite-id citet-id)
|
||||||
(citet-id "Braberman:2008:PPH:1375634.1375655"))))
|
(citet-id "Braberman:2008:PPH:1375634.1375655"))))
|
||||||
|
|
|
@ -405,3 +405,8 @@ Book{landru21,
|
||||||
month = "May",
|
month = "May",
|
||||||
year = 2004
|
year = 2004
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@MiSc{AnAnnoyingKeY,
|
||||||
|
Author = {ZA ZAuThOr},
|
||||||
|
Title = {StrIngS ArE TerriblE},
|
||||||
|
Year = {2000}}
|
Loading…
Reference in New Issue
Block a user