Handle empty strings in paragraph formatting.
This commit is contained in:
parent
c0a8d6d2b3
commit
624460132b
2 changed files with 8 additions and 4 deletions
4
ansi.scm
4
ansi.scm
|
@ -155,8 +155,8 @@
|
||||||
;; accordingly.
|
;; accordingly.
|
||||||
(define (ansi-paragraph-format str width)
|
(define (ansi-paragraph-format str width)
|
||||||
(let* ((strl (string->list str))
|
(let* ((strl (string->list str))
|
||||||
(first-char (car strl))
|
(first-char (if (null? strl) #f (car strl)))
|
||||||
(last-char (car (reverse strl)))
|
(last-char (if (null? strl) #f (car (reverse strl))))
|
||||||
(first-tab (eq? first-char #\tab))
|
(first-tab (eq? first-char #\tab))
|
||||||
(last-tab (eq? last-char #\tab)))
|
(last-tab (eq? last-char #\tab)))
|
||||||
(let loop ((words (string-split
|
(let loop ((words (string-split
|
||||||
|
|
|
@ -138,8 +138,12 @@
|
||||||
|
|
||||||
;; Normalizes cell line to required width and handles leading and
|
;; Normalizes cell line to required width and handles leading and
|
||||||
;; trailing tabs to allow for right and center alignment.
|
;; trailing tabs to allow for right and center alignment.
|
||||||
(define (table-normalize-cell-line cs w)
|
(define (table-normalize-cell-line line w)
|
||||||
(let ((csl (ansi-string-length cs)))
|
(let ((lst (string->list line))
|
||||||
|
(first-char (if (null? lst) #f (car lst)))
|
||||||
|
(last-char (if (null? lst) #f (car (reverse lst))))
|
||||||
|
;; Line without tabs
|
||||||
|
(len (ansi-string-length line)))
|
||||||
(if (< csl w)
|
(if (< csl w)
|
||||||
(string-append cs (string-repeat " " (- w csl)))
|
(string-append cs (string-repeat " " (- w csl)))
|
||||||
cs)))
|
cs)))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue