From 00739632cf32a8ebf0748a7af74d1bf05719713e Mon Sep 17 00:00:00 2001 From: Matthew Flatt Date: Thu, 4 Jan 2018 11:03:36 -0700 Subject: [PATCH] tabular: add `#:sep-properties` Also, correct the documentation about the interaction of `#:sep` and property lists, and make the previous column's properties used consistently for a separator column. --- scribble-doc/scribblings/scribble/base.scrbl | 18 +++++++++++------- scribble-lib/info.rkt | 2 +- scribble-lib/scribble/base.rkt | 8 +++++--- 3 files changed, 17 insertions(+), 11 deletions(-) diff --git a/scribble-doc/scribblings/scribble/base.scrbl b/scribble-doc/scribblings/scribble/base.scrbl index be57eaa4..c9832c49 100644 --- a/scribble-doc/scribblings/scribble/base.scrbl +++ b/scribble-doc/scribblings/scribble/base.scrbl @@ -261,7 +261,8 @@ Returns @racket[#t] if @racket[v] is an item produced by [#:sep sep (or/c block? content? #f) #f] [#:column-properties column-properties (listof any/c) '()] [#:row-properties row-properties (listof any/c) '()] - [#:cell-properties cell-properties (listof (listof any/c)) '()]) + [#:cell-properties cell-properties (listof (listof any/c)) '()] + [#:sep-properties sep-properties (or/c list? #f) #f]) table?]{ Creates a @tech{table} with the given @racket[cells] content, which is @@ -276,11 +277,11 @@ cell in a row. The @racket[style] argument is handled the same as @racket[para]. See @racket[table] for a list of recognized @tech{style names} and @tech{style properties}. -If @racket[sep] is not @racket[#f], it is inserted as a new column -between every column in the table; note that any -@racket[table-columns] or @racket[table-cells] property in -@racket[style] must take the added columns into account. Otherwise, -the default style places no space between table columns. When @racket[sep] +The default style places no space between table columns. If +@racket[sep] is not @racket[#f], it is inserted as a new column +between every column in the table; the new column's properties are the +same as the preceding column's, unless @racket[sep-properties] +provides a list of @tech{style properties} to use. When @racket[sep] would be placed before a @racket['cont], a @racket['cont] is inserted, instead. @@ -343,7 +344,10 @@ properties will be used from the merger into @racket[table-cells].} @racket[#:row-properties], and @racket[#:cell-properties] arguments.} #:changed "1.12" @elem{Changed @racket[sep] insertion before a - @racket['cont].}] + @racket['cont].} + #:changed "1.28" @elem{Added @racket[sep-properties] and made + the preceding column's properties used + consistently if not specified.}] Examples: @codeblock[#:keep-lang-line? #f]|{ diff --git a/scribble-lib/info.rkt b/scribble-lib/info.rkt index c7ec9bf9..948bd3ea 100644 --- a/scribble-lib/info.rkt +++ b/scribble-lib/info.rkt @@ -23,4 +23,4 @@ (define pkg-authors '(mflatt eli)) -(define version "1.27") +(define version "1.28") diff --git a/scribble-lib/scribble/base.rkt b/scribble-lib/scribble/base.rkt index e57ef3b7..d0788640 100644 --- a/scribble-lib/scribble/base.rkt +++ b/scribble-lib/scribble/base.rkt @@ -329,7 +329,8 @@ #:sep (or/c content? block? #f) #:column-properties (listof any/c) #:row-properties (listof any/c) - #:cell-properties (listof (listof any/c))) + #:cell-properties (listof (listof any/c)) + #:sep-properties (or/c list? #f)) table?)]) (define (convert-block-style style) @@ -352,6 +353,7 @@ (define (tabular #:style [style #f] #:sep [sep #f] + #:sep-properties [sep-props #f] #:column-properties [column-properties null] #:row-properties [row-properties null] #:cell-properties [cell-properties null] @@ -426,7 +428,7 @@ [(null? column-properties) (if (or (zero? n) (not sep)) (cons prev (loop null (add1 n) prev)) - (list* prev prev (loop null (+ n 2) prev)))] + (list* (or sep-props prev) prev (loop null (+ n 2) prev)))] [else (define (to-list v) (if (list? v) v (list v))) (define props (to-list (car column-properties))) @@ -437,7 +439,7 @@ props)) (if (or (zero? n) (not sep)) (cons props rest) - (list* null props rest))]))) + (list* (or sep-props prev) props rest))]))) (define full-column-properties (make-full-column-properties column-properties)) (define (make-full-cell-properties cell-properties)