diff --git a/scribble-doc/scriblib/scribblings/autobib.scrbl b/scribble-doc/scriblib/scribblings/autobib.scrbl index 50baa4cd..aadbd33b 100644 --- a/scribble-doc/scriblib/scribblings/autobib.scrbl +++ b/scribble-doc/scriblib/scribblings/autobib.scrbl @@ -144,10 +144,16 @@ optionally given @racket[render-date-expr] functions. @deftogether[( @defthing[author+date-style any/c] +@defthing[author+date-square-bracket-style any/c] @defthing[number-style any/c] )]{ -Styles for use with @racket[define-cite].} +Styles for use with @racket[define-cite]. + +The @racket[author+date-square-bracket-style] definition is the same +as @racket[author+date-style], except that references to citations +are enclosed in @litchar["[]"] instead of @litchar["()"]. +} @defproc[(bib? [v any/c]) boolean?]{ diff --git a/scribble-lib/scriblib/autobib.rkt b/scribble-lib/scriblib/autobib.rkt index d77f6102..bc83bf5f 100644 --- a/scribble-lib/scriblib/autobib.rkt +++ b/scribble-lib/scriblib/autobib.rkt @@ -14,7 +14,7 @@ racket/contract) (provide define-cite - author+date-style number-style + author+date-style author+date-square-bracket-style number-style make-bib in-bib (rename-out [auto-bib? bib?]) author-name org-author-name (contract-out @@ -195,20 +195,28 @@ (error 'default-disambiguation "Citations too ambiguous for default disambiguation scheme.")) (make-element #f (list (format "~a" (integer->char (+ 97 n)))))) -(define author+date-style +(define author+date-style% + (class object% + (define/public (bibliography-table-style) bib-single-style) + (define/public (entry-style) bibentry-style) + (define/public (disambiguate-date?) #t) + (define/public (collapse-for-date?) #t) + (define/public (get-cite-open) "(") + (define/public (get-cite-close) ")") + (define/public (get-group-sep) "; ") + (define/public (get-item-sep) ", ") + (define/public (render-citation date-cite i) date-cite) + (define/public (render-author+dates author dates) (list* author " " dates)) + (define/public (bibliography-line i e) (list e)) + (super-new))) + +(define author+date-style (new author+date-style%)) + +(define author+date-square-bracket-style (new - (class object% - (define/public (bibliography-table-style) bib-single-style) - (define/public (entry-style) bibentry-style) - (define/public (disambiguate-date?) #t) - (define/public (collapse-for-date?) #t) - (define/public (get-cite-open) "(") - (define/public (get-cite-close) ")") - (define/public (get-group-sep) "; ") - (define/public (get-item-sep) ", ") - (define/public (render-citation date-cite i) date-cite) - (define/public (render-author+dates author dates) (list* author " " dates)) - (define/public (bibliography-line i e) (list e)) + (class author+date-style% + (define/override (get-cite-open) "[") + (define/override (get-cite-close) "]") (super-new)))) (define number-style