Lookup cell borders in style.
This commit is contained in:
parent
b8eed3b877
commit
a2c78df941
1 changed files with 52 additions and 5 deletions
53
table.scm
53
table.scm
|
@ -227,14 +227,23 @@
|
||||||
|
|
||||||
;; Converts given table to a string suitable for printing.
|
;; Converts given table to a string suitable for printing.
|
||||||
(define (table->string tbl . args)
|
(define (table->string tbl . args)
|
||||||
(let ((table-border (get-keyword #:table-border args (lambda () #f)))
|
(let* ((table-border (get-keyword #:table-border args (lambda () #f)))
|
||||||
(cell-border (get-keyword #:cell-border args (lambda () #f)))
|
(cell-border (get-keyword #:cell-border args (lambda () #f)))
|
||||||
(border-style (get-keyword #:border-style args (lambda () 'ascii)))
|
(border-style (get-keyword #:border-style args (lambda () 'ascii)))
|
||||||
(table (table-prepare tbl)))
|
(table (table-prepare tbl))
|
||||||
|
(stylepair (assq border-style table-borders-lookup))
|
||||||
|
(stylevec (if stylepair
|
||||||
|
(cdr stylepair)
|
||||||
|
(cdar table-borders-lookup)))
|
||||||
|
(cell-borders (if cell-border
|
||||||
|
(map (lambda (idx)
|
||||||
|
(vector-ref stylevec idx))
|
||||||
|
'(4 6 7))
|
||||||
|
'("" "" ""))))
|
||||||
(string-intersperse
|
(string-intersperse
|
||||||
(flatten
|
(flatten
|
||||||
(map (lambda (row)
|
(map (lambda (row)
|
||||||
(table-row->lines row "]" "|" "["))
|
(apply table-row->lines row cell-borders))
|
||||||
table))
|
table))
|
||||||
"\n")))
|
"\n")))
|
||||||
|
|
||||||
|
@ -300,3 +309,41 @@
|
||||||
'(("a" "bb" "ccc" "")
|
'(("a" "bb" "ccc" "")
|
||||||
("" "b" "z" "x"))))
|
("" "b" "z" "x"))))
|
||||||
(print (table-row-delimiter/styled '(1 2 3 1) (cdr (assq 'unicode table-borders-lookup)) 3))
|
(print (table-row-delimiter/styled '(1 2 3 1) (cdr (assq 'unicode table-borders-lookup)) 3))
|
||||||
|
|
||||||
|
(print "************")
|
||||||
|
(print
|
||||||
|
(table->string
|
||||||
|
'(("a" "bb" "ccc" "")
|
||||||
|
("" "b" "z" "x"))
|
||||||
|
#:table-border #f
|
||||||
|
#:cell-border #f
|
||||||
|
))
|
||||||
|
|
||||||
|
(print "************")
|
||||||
|
(print
|
||||||
|
(table->string
|
||||||
|
'(("a" "bb" "ccc" "")
|
||||||
|
("" "b" "z" "x"))
|
||||||
|
#:table-border #f
|
||||||
|
#:cell-border #t
|
||||||
|
#:border-style 'unicode
|
||||||
|
))
|
||||||
|
|
||||||
|
(print "************")
|
||||||
|
(print
|
||||||
|
(table->string
|
||||||
|
'(("a" "bb" "ccc" "")
|
||||||
|
("" "b" "z" "x"))
|
||||||
|
#:table-border #t
|
||||||
|
#:cell-border #f
|
||||||
|
))
|
||||||
|
|
||||||
|
(print "************")
|
||||||
|
(print
|
||||||
|
(table->string
|
||||||
|
'(("a" "bb" "ccc" "")
|
||||||
|
("" "b" "z" "x"))
|
||||||
|
#:table-border #t
|
||||||
|
#:cell-border #t
|
||||||
|
#:border-style 'unicode
|
||||||
|
))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue