diff --git a/collects/scribble/html-properties.rkt b/collects/scribble/html-properties.rkt index ab5da815..a46b9785 100644 --- a/collects/scribble/html-properties.rkt +++ b/collects/scribble/html-properties.rkt @@ -14,4 +14,5 @@ [url-anchor ([name string?])] [alt-tag ([name (and/c string? #rx"^[a-zA-Z0-9]+$")])] - [attributes ([assoc (listof (cons/c symbol? string?))])]) + [attributes ([assoc (listof (cons/c symbol? string?))])] + [column-attributes ([assoc (listof (cons/c symbol? string?))])]) diff --git a/collects/scribble/html-render.rkt b/collects/scribble/html-render.rkt index a0c569b3..5598e222 100644 --- a/collects/scribble/html-render.rkt +++ b/collects/scribble/html-render.rkt @@ -1264,6 +1264,21 @@ [(centered) '([align "center"])] [else '()]) ,@(style->attribs (table-style t))) + ,@(let ([columns (ormap (lambda (p) + (and (table-columns? p) + (map (lambda (s) + (ormap (lambda (a) + (and (column-attributes? a) + a)) + (style-properties s))) + (table-columns-styles p)))) + (style-properties (table-style t)))]) + (if (and columns (ormap values columns)) + `((colgroup ,@(for/list ([col (in-list columns)]) + `(col ,(if col + (map (lambda (v) (list (car v) (cdr v))) (column-attributes-assoc col)) + null))))) + null)) ,@(if (null? (table-blockss t)) `((tr (td))) (map make-row diff --git a/collects/scribble/private/manual-proc.rkt b/collects/scribble/private/manual-proc.rkt index 9721583e..481b598d 100644 --- a/collects/scribble/private/manual-proc.rkt +++ b/collects/scribble/private/manual-proc.rkt @@ -5,6 +5,9 @@ "../search.rkt" "../basic.rkt" "../manual-struct.rkt" + (only-in "../core.rkt" + make-style make-table-columns) + "../html-properties.rkt" "qsloc.rkt" "manual-utils.rkt" "manual-vars.rkt" @@ -655,7 +658,15 @@ (list flow-spacer flow-spacer c) (list flow-spacer flow-spacer c 'cont 'cont)))]) (make-table - #f + (if one-right-column? + #f + ;; Shift all extra width to last column: + (make-style #f (list + (make-table-columns + (for/list ([i 5]) + (if (i . < . 4) + (make-style #f (list (column-attributes '((width . "0*"))))) + (make-style #f null))))))) (append (list (append @@ -676,10 +687,10 @@ (not cname-id)) (list (racketparenfont ")")) null))))) - (list (to-flow the-name) + (list (to-flow (make-element 'no-break the-name)) (to-flow (make-element #f (list spacer (racketparenfont "(")))) - (to-flow (to-element (field-view (car fields)))))))) + (to-flow (make-element 'no-break (to-element (field-view (car fields))))))))) (if (short-width . < . max-proto-width) null (let loop ([fields (if (null? fields) diff --git a/collects/scribblings/scribble/core.scrbl b/collects/scribblings/scribble/core.scrbl index 3d64b480..df085c0d 100644 --- a/collects/scribblings/scribble/core.scrbl +++ b/collects/scribblings/scribble/core.scrbl @@ -483,8 +483,9 @@ The following @tech{style properties} are currently recognized: @itemize[ @item{@racket[table-columns] structure --- Provides column-specific - styles, but only if a @racket[table-cells] structure is not - included as a @tech{style property}.} + styles, but only @racket[column-attributes] properties (if any) + are used if a @racket[table-cells] structure is included as a + @tech{style property}.} @item{@racket[table-cells] structure --- Provides cell-specific styles.} @@ -1009,9 +1010,18 @@ In addition, for HTML output, @racket[attributes] structures as @defstruct[table-columns ([styles (listof style?)])]{ -Like @racket[table-cells], but the @racket[styles] list is duplicated -for each row in the table. This @tech{style property} is used only when a -@racket[table-cells] is not present in a style's list of properties.} +Like @racket[table-cells], but with support for a +@racket[column-attributes] property in each style, and the +@racket[styles] list is otherwise duplicated for each row in the +table. The non-@racket[column-attributes] parts of a +@racket[table-columns] are used only when a @racket[table-cells] property is +not present along with the @racket[table-columns] property. + +For HTML table rendering, for each column that has a +@racket[column-attributes] property in the corresponding element of +@racket[styles], the attributes are put into an HTML @tt{col} tag +within the table.} + @deftogether[( @defstruct[box-mode ([top-name string?] @@ -1302,6 +1312,7 @@ Defined as Used as a @tech{style property} to add arbitrary attributes to an HTML tag.} + @defstruct[alt-tag ([name (and/c string? #rx"^[a-zA-Z0-9]+$")])]{ Use as a @tech{style property} for an @racket[element], @@ -1310,6 +1321,12 @@ alternate HTML tag (instead of @tt{}, @tt{

}, @tt{div}, @|etc|).} +@defstruct[column-attributes ([assoc (listof (cons/c symbol? string?))])]{ + +Used as a @tech{style property} on a style with @racket[table-columns] +to add arbitrary attributes to an HTML @tt{col} tag within the table.} + + @defstruct[url-anchor ([name string?])]{ Used as a @tech{style property} with @racket[element] to insert an