Prepare column normalization.
This commit is contained in:
parent
fb7701869d
commit
b919898057
1 changed files with 23 additions and 3 deletions
22
table.scm
22
table.scm
|
@ -86,11 +86,31 @@
|
||||||
(let ((ml (apply max (map length row))))
|
(let ((ml (apply max (map length row))))
|
||||||
(map (make-list-extender ml) row)))
|
(map (make-list-extender ml) row)))
|
||||||
|
|
||||||
|
;; Normalizes the number of text lines in each table row.
|
||||||
|
(define (table-normalize-rows tbl)
|
||||||
|
(map table-normalize-row tbl))
|
||||||
|
|
||||||
|
;; Returns the maximum width of each column of the table.
|
||||||
|
(define (table-column-widths tbl)
|
||||||
|
'())
|
||||||
|
|
||||||
|
(define (table-row-normalize-cells row cwidths)
|
||||||
|
row)
|
||||||
|
|
||||||
|
;; Normalizes cells in all rows to match the widths of the wides cell
|
||||||
|
;; in each column.
|
||||||
|
(define (table-normalize-columns tbl)
|
||||||
|
(let ((cwidths (table-column-widths tbl)))
|
||||||
|
(map (lambda (row)
|
||||||
|
(table-row-normalize-cells row cwidths))
|
||||||
|
tbl)))
|
||||||
|
|
||||||
;; Ensures the table is rectangular and each cell is a list of strings.
|
;; Ensures the table is rectangular and each cell is a list of strings.
|
||||||
(define (table-prepare tbl)
|
(define (table-prepare tbl)
|
||||||
|
(table-normalize-rows
|
||||||
(table-prepare-cells
|
(table-prepare-cells
|
||||||
(table-stringify
|
(table-stringify
|
||||||
(table-rectangularize tbl))))
|
(table-rectangularize tbl)))))
|
||||||
|
|
||||||
(define (table->string tbl . args)
|
(define (table->string tbl . args)
|
||||||
"")
|
"")
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue