commit f707394839944af33bc8b94a8a03988c8840fc30 parent 1b4d15957cc0bd16ed8bee7205fcc72ff5dac3ed Author: Stephen Chang <stchang216@gmail.com> Date: Wed, 2 Aug 2017 13:17:38 -0400 autobib book-location: fix capitalization of ordinal editions Diffstat:
| M | scribble-lib/scriblib/autobib.rkt | | | 8 | +++++++- |
| M | scribble-test/tests/scriblib/autobib.rkt | | | 19 | ++++++++++++++++++- |
2 files changed, 25 insertions(+), 2 deletions(-)
diff --git a/scribble-lib/scriblib/autobib.rkt b/scribble-lib/scriblib/autobib.rkt @@ -522,11 +522,17 @@ 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 #:edition [edition #f] #:publisher [publisher #f]) (let* ([s (if edition - @elem{@(string-titlecase (to-string edition)) edition} + @elem{@(string-capitalize (to-string edition)) edition} #f)] [s (if publisher (if s diff --git a/scribble-test/tests/scriblib/autobib.rkt b/scribble-test/tests/scriblib/autobib.rkt @@ -1,6 +1,6 @@ #lang racket/base -(require rackunit scriblib/autobib) +(require rackunit scriblib/autobib scribble/base scribble/core) (test-case "define-cite" ;; Check that `define-cite` binds the expected identifiers @@ -39,6 +39,23 @@ (check-exn exn:fail? (λ () (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" (check-not-exn (λ () (techrpt-location #:institution "MIT" #:number 'AIM-353)))