Implement col0 separators for lines.
This commit is contained in:
parent
4d7330a086
commit
71c9e7a5fe
1 changed files with 21 additions and 10 deletions
31
table.scm
31
table.scm
|
@ -208,7 +208,7 @@
|
|||
|
||||
;; Accepts a table row - list of list of strings - and returns a list
|
||||
;; of lines (list of strings).
|
||||
(define (table-row->lines row left-border cell-separator right-border ansi?)
|
||||
(define (table-row->lines row left-border cell0-separator cell-separator right-border ansi?)
|
||||
(if (null? row)
|
||||
'()
|
||||
(let yloop ((row row)
|
||||
|
@ -217,14 +217,23 @@
|
|||
(reverse res)
|
||||
(yloop (map cdr row)
|
||||
(cons
|
||||
(string-append left-border
|
||||
(string-intersperse
|
||||
(let ((srow (map car row)))
|
||||
(if ansi?
|
||||
(map (lambda (c) (string-append c (ansi #:default))) srow)
|
||||
srow))
|
||||
cell-separator)
|
||||
right-border)
|
||||
(string-append
|
||||
left-border
|
||||
(let cloop ((srow (map car row))
|
||||
(res "")
|
||||
(idx 0))
|
||||
(if (null? srow)
|
||||
res
|
||||
(cloop (cdr srow)
|
||||
(string-append res
|
||||
(case idx
|
||||
((0) "")
|
||||
((1) cell0-separator)
|
||||
(else cell-separator))
|
||||
(car srow)
|
||||
(if ansi? (ansi #:default) ""))
|
||||
(add1 idx))))
|
||||
right-border)
|
||||
res))))))
|
||||
|
||||
;; Creates table row delimiter based on column widths.
|
||||
|
@ -269,6 +278,8 @@
|
|||
(cdr stylepair)
|
||||
(cdar table-borders-lookup)))
|
||||
(cell-borders (list (if table-border (vector-ref stylevec 4) "")
|
||||
(if (or column-border col0-border)
|
||||
(vector-ref stylevec 6) "")
|
||||
(if column-border (vector-ref stylevec 6) "")
|
||||
(if table-border (vector-ref stylevec 7) "")
|
||||
ansi?))
|
||||
|
@ -360,7 +371,7 @@
|
|||
'((("a") ("bb") ("ccc") (" "))
|
||||
((" ") ("b ") ("z ") ("x"))))
|
||||
(test-equal? table-row->lines
|
||||
(table-row->lines '(("a ") ("bb") ("ccc") (" ")) "]" "|" "[" #f)
|
||||
(table-row->lines '(("a ") ("bb") ("ccc") (" ")) "]" "|" "|" "[" #f)
|
||||
'("]a |bb|ccc| ["))
|
||||
(test-equal? table-row-delimiter
|
||||
(table-row-delimiter '(1 2 3 1) "/" "-" "+" "\\")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue