autobib book-location: fix capitalization of ordinal editions
This commit is contained in:
parent
1b4d15957c
commit
f707394839
|
@ -522,11 +522,17 @@
|
||||||
s)])
|
s)])
|
||||||
s))
|
s))
|
||||||
|
|
||||||
|
(define (string-capitalize str)
|
||||||
|
(if (non-empty-string? str)
|
||||||
|
(let ([chars (string->list str)])
|
||||||
|
(list->string (cons (char-upcase (car chars)) (cdr chars))))
|
||||||
|
str))
|
||||||
|
|
||||||
(define (book-location
|
(define (book-location
|
||||||
#:edition [edition #f]
|
#:edition [edition #f]
|
||||||
#:publisher [publisher #f])
|
#:publisher [publisher #f])
|
||||||
(let* ([s (if edition
|
(let* ([s (if edition
|
||||||
@elem{@(string-titlecase (to-string edition)) edition}
|
@elem{@(string-capitalize (to-string edition)) edition}
|
||||||
#f)]
|
#f)]
|
||||||
[s (if publisher
|
[s (if publisher
|
||||||
(if s
|
(if s
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#lang racket/base
|
#lang racket/base
|
||||||
|
|
||||||
(require rackunit scriblib/autobib)
|
(require rackunit scriblib/autobib scribble/base scribble/core)
|
||||||
|
|
||||||
(test-case "define-cite"
|
(test-case "define-cite"
|
||||||
;; Check that `define-cite` binds the expected identifiers
|
;; Check that `define-cite` binds the expected identifiers
|
||||||
|
@ -39,6 +39,23 @@
|
||||||
(check-exn exn:fail?
|
(check-exn exn:fail?
|
||||||
(λ () (book-location))))
|
(λ () (book-location))))
|
||||||
|
|
||||||
|
(define (mk-bookloc-elem/ed ed) (element (style #f '()) (list ed " edition")))
|
||||||
|
|
||||||
|
(test-case "book-location-edition-capitalization"
|
||||||
|
(check-equal? (book-location #:edition 'a)
|
||||||
|
(mk-bookloc-elem/ed "A"))
|
||||||
|
(check-equal? (book-location #:edition "first")
|
||||||
|
(mk-bookloc-elem/ed "First"))
|
||||||
|
(check-equal? (book-location #:edition 'Third)
|
||||||
|
(mk-bookloc-elem/ed "Third"))
|
||||||
|
(check-equal? (book-location #:edition 1)
|
||||||
|
(mk-bookloc-elem/ed "1"))
|
||||||
|
(check-equal? (book-location #:edition "1st")
|
||||||
|
(mk-bookloc-elem/ed "1st"))
|
||||||
|
(check-equal? (book-location #:edition "4th")
|
||||||
|
(mk-bookloc-elem/ed "4th")))
|
||||||
|
|
||||||
|
|
||||||
(test-case "techrpt-location"
|
(test-case "techrpt-location"
|
||||||
(check-not-exn
|
(check-not-exn
|
||||||
(λ () (techrpt-location #:institution "MIT" #:number 'AIM-353)))
|
(λ () (techrpt-location #:institution "MIT" #:number 'AIM-353)))
|
||||||
|
|
Loading…
Reference in New Issue
Block a user