Changed " +" to "\\s+" in parse-author. Added more test for Last,First format for names in bibtex.
This commit is contained in:
parent
aee15712e5
commit
d34569cebe
|
@ -209,7 +209,7 @@
|
||||||
(λ (key)
|
(λ (key)
|
||||||
(and (not (string=? "\n" key))
|
(and (not (string=? "\n" key))
|
||||||
(generate-bib bibtex-db key)))
|
(generate-bib bibtex-db key)))
|
||||||
(append-map (curry regexp-split #rx" +")
|
(append-map (curry regexp-split #px"\\s+")
|
||||||
(cons f r)))))
|
(cons f r)))))
|
||||||
(define ~cite-id (make-citer autobib-cite))
|
(define ~cite-id (make-citer autobib-cite))
|
||||||
(define citet-id (make-citer autobib-citet))))
|
(define citet-id (make-citer autobib-citet))))
|
||||||
|
@ -217,9 +217,9 @@
|
||||||
(define (parse-author as)
|
(define (parse-author as)
|
||||||
(and as
|
(and as
|
||||||
(apply authors
|
(apply authors
|
||||||
(for/list ([a (in-list (regexp-split #rx" +and *" as))])
|
(for/list ([a (in-list (regexp-split #px"\\s+and\\s+" as))])
|
||||||
(define (trim s)
|
(define (trim s)
|
||||||
(string-trim (regexp-replace #rx" +" s " ")))
|
(string-trim (regexp-replace #px"\\s+" s " ")))
|
||||||
(match a
|
(match a
|
||||||
[(pregexp #px"^(.*),(.*),(.*)$" (list _ two suffix one))
|
[(pregexp #px"^(.*),(.*),(.*)$" (list _ two suffix one))
|
||||||
(author-name (trim one) (trim two) #:suffix (trim suffix))]
|
(author-name (trim one) (trim two) #:suffix (trim suffix))]
|
||||||
|
@ -228,7 +228,7 @@
|
||||||
[(pregexp #px"^(.*) (von|de la|van der) (.*)$" (list _ one von-like two))
|
[(pregexp #px"^(.*) (von|de la|van der) (.*)$" (list _ one von-like two))
|
||||||
(author-name (string-trim one) (string-append von-like " " (string-trim two)))]
|
(author-name (string-trim one) (string-append von-like " " (string-trim two)))]
|
||||||
[space-separated
|
[space-separated
|
||||||
(match (regexp-split #rx" +" space-separated)
|
(match (regexp-split #px"\\s+" space-separated)
|
||||||
[(list one) (org-author-name one)]
|
[(list one) (org-author-name one)]
|
||||||
[(list one two) (author-name one two)]
|
[(list one two) (author-name one two)]
|
||||||
[(list-rest first rest)
|
[(list-rest first rest)
|
||||||
|
@ -272,36 +272,96 @@
|
||||||
(authors
|
(authors
|
||||||
(author-name "Fst" "Lst")))
|
(author-name "Fst" "Lst")))
|
||||||
|
|
||||||
|
(check
|
||||||
|
print-as-equal-string?
|
||||||
|
(parse-author "Lst,Fst")
|
||||||
|
(authors
|
||||||
|
(author-name "Fst" "Lst")))
|
||||||
|
|
||||||
(check
|
(check
|
||||||
print-as-equal-string?
|
print-as-equal-string?
|
||||||
(parse-author "James, Earl Jones")
|
(parse-author "James, Earl Jones")
|
||||||
(authors
|
(authors
|
||||||
(author-name "Earl Jones" "James")))
|
(author-name "Earl Jones" "James")))
|
||||||
|
|
||||||
|
(check
|
||||||
|
print-as-equal-string?
|
||||||
|
(parse-author "James,Earl Jones")
|
||||||
|
(authors
|
||||||
|
(author-name "Earl Jones" "James")))
|
||||||
|
|
||||||
(check
|
(check
|
||||||
print-as-equal-string?
|
print-as-equal-string?
|
||||||
(parse-author "LstA LstB, Fst")
|
(parse-author "LstA LstB, Fst")
|
||||||
(authors
|
(authors
|
||||||
(author-name "Fst" "LstA LstB")))
|
(author-name "Fst" "LstA LstB")))
|
||||||
|
|
||||||
|
(check
|
||||||
|
print-as-equal-string?
|
||||||
|
(parse-author "LstA LstB,Fst")
|
||||||
|
(authors
|
||||||
|
(author-name "Fst" "LstA LstB")))
|
||||||
|
|
||||||
(check
|
(check
|
||||||
print-as-equal-string?
|
print-as-equal-string?
|
||||||
(parse-author "LstA LstB, FstA FstB")
|
(parse-author "LstA LstB, FstA FstB")
|
||||||
(authors
|
(authors
|
||||||
(author-name "FstA FstB" "LstA LstB")))
|
(author-name "FstA FstB" "LstA LstB")))
|
||||||
|
|
||||||
|
(check
|
||||||
|
print-as-equal-string?
|
||||||
|
(parse-author "LstA LstB,FstA FstB")
|
||||||
|
(authors
|
||||||
|
(author-name "FstA FstB" "LstA LstB")))
|
||||||
|
|
||||||
(check
|
(check
|
||||||
print-as-equal-string?
|
print-as-equal-string?
|
||||||
(parse-author "James, Jr, Earl Jones")
|
(parse-author "James, Jr, Earl Jones")
|
||||||
(authors
|
(authors
|
||||||
(author-name "Earl Jones" "James" #:suffix "Jr")))
|
(author-name "Earl Jones" "James" #:suffix "Jr")))
|
||||||
|
|
||||||
|
(check
|
||||||
|
print-as-equal-string?
|
||||||
|
(parse-author "James,Jr, Earl Jones")
|
||||||
|
(authors
|
||||||
|
(author-name "Earl Jones" "James" #:suffix "Jr")))
|
||||||
|
|
||||||
|
(check
|
||||||
|
print-as-equal-string?
|
||||||
|
(parse-author "James, Jr,Earl Jones")
|
||||||
|
(authors
|
||||||
|
(author-name "Earl Jones" "James" #:suffix "Jr")))
|
||||||
|
|
||||||
|
(check
|
||||||
|
print-as-equal-string?
|
||||||
|
(parse-author "James,Jr,Earl Jones")
|
||||||
|
(authors
|
||||||
|
(author-name "Earl Jones" "James" #:suffix "Jr")))
|
||||||
|
|
||||||
(check
|
(check
|
||||||
print-as-equal-string?
|
print-as-equal-string?
|
||||||
(parse-author "James, III, Earl Jones")
|
(parse-author "James, III, Earl Jones")
|
||||||
(authors
|
(authors
|
||||||
(author-name "Earl Jones" "James" #:suffix "III")))
|
(author-name "Earl Jones" "James" #:suffix "III")))
|
||||||
|
|
||||||
|
(check
|
||||||
|
print-as-equal-string?
|
||||||
|
(parse-author "James,III, Earl Jones")
|
||||||
|
(authors
|
||||||
|
(author-name "Earl Jones" "James" #:suffix "III")))
|
||||||
|
|
||||||
|
(check
|
||||||
|
print-as-equal-string?
|
||||||
|
(parse-author "James, III,Earl Jones")
|
||||||
|
(authors
|
||||||
|
(author-name "Earl Jones" "James" #:suffix "III")))
|
||||||
|
|
||||||
|
(check
|
||||||
|
print-as-equal-string?
|
||||||
|
(parse-author "James,III,Earl Jones")
|
||||||
|
(authors
|
||||||
|
(author-name "Earl Jones" "James" #:suffix "III")))
|
||||||
|
|
||||||
(check
|
(check
|
||||||
print-as-equal-string?
|
print-as-equal-string?
|
||||||
(parse-author "James Jack von Earl Jones")
|
(parse-author "James Jack von Earl Jones")
|
||||||
|
@ -326,7 +386,13 @@
|
||||||
(authors (author-name "Edward L." "Deci")
|
(authors (author-name "Edward L." "Deci")
|
||||||
(author-name "Robert J." "Vallerand")
|
(author-name "Robert J." "Vallerand")
|
||||||
(author-name "Luc G." "Pelletier")
|
(author-name "Luc G." "Pelletier")
|
||||||
(author-name "Richard M." "Ryan" #:suffix "Jr"))))
|
(author-name "Richard M." "Ryan" #:suffix "Jr")))
|
||||||
|
|
||||||
|
(check
|
||||||
|
print-as-equal-string?
|
||||||
|
(parse-author "Foo anderson") ;; Should not be parsed as the two authors "Foo" & "erson"
|
||||||
|
(authors
|
||||||
|
(author-name "Foo" "anderson"))))
|
||||||
|
|
||||||
(define (parse-pages ps)
|
(define (parse-pages ps)
|
||||||
(match ps
|
(match ps
|
||||||
|
|
Loading…
Reference in New Issue
Block a user