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
|
;; Accepts a table row - list of list of strings - and returns a list
|
||||||
;; of lines (list of strings).
|
;; 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)
|
(if (null? row)
|
||||||
'()
|
'()
|
||||||
(let yloop ((row row)
|
(let yloop ((row row)
|
||||||
|
@ -217,14 +217,23 @@
|
||||||
(reverse res)
|
(reverse res)
|
||||||
(yloop (map cdr row)
|
(yloop (map cdr row)
|
||||||
(cons
|
(cons
|
||||||
(string-append left-border
|
(string-append
|
||||||
(string-intersperse
|
left-border
|
||||||
(let ((srow (map car row)))
|
(let cloop ((srow (map car row))
|
||||||
(if ansi?
|
(res "")
|
||||||
(map (lambda (c) (string-append c (ansi #:default))) srow)
|
(idx 0))
|
||||||
srow))
|
(if (null? srow)
|
||||||
cell-separator)
|
res
|
||||||
right-border)
|
(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))))))
|
res))))))
|
||||||
|
|
||||||
;; Creates table row delimiter based on column widths.
|
;; Creates table row delimiter based on column widths.
|
||||||
|
@ -269,6 +278,8 @@
|
||||||
(cdr stylepair)
|
(cdr stylepair)
|
||||||
(cdar table-borders-lookup)))
|
(cdar table-borders-lookup)))
|
||||||
(cell-borders (list (if table-border (vector-ref stylevec 4) "")
|
(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 column-border (vector-ref stylevec 6) "")
|
||||||
(if table-border (vector-ref stylevec 7) "")
|
(if table-border (vector-ref stylevec 7) "")
|
||||||
ansi?))
|
ansi?))
|
||||||
|
@ -360,7 +371,7 @@
|
||||||
'((("a") ("bb") ("ccc") (" "))
|
'((("a") ("bb") ("ccc") (" "))
|
||||||
((" ") ("b ") ("z ") ("x"))))
|
((" ") ("b ") ("z ") ("x"))))
|
||||||
(test-equal? table-row->lines
|
(test-equal? table-row->lines
|
||||||
(table-row->lines '(("a ") ("bb") ("ccc") (" ")) "]" "|" "[" #f)
|
(table-row->lines '(("a ") ("bb") ("ccc") (" ")) "]" "|" "|" "[" #f)
|
||||||
'("]a |bb|ccc| ["))
|
'("]a |bb|ccc| ["))
|
||||||
(test-equal? table-row-delimiter
|
(test-equal? table-row-delimiter
|
||||||
(table-row-delimiter '(1 2 3 1) "/" "-" "+" "\\")
|
(table-row-delimiter '(1 2 3 1) "/" "-" "+" "\\")
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue