Add horizontal rules
This commit is contained in:
parent
e4b7f7461d
commit
13566e5281
3 changed files with 22 additions and 1 deletions
|
@ -6,6 +6,7 @@ Fancy pretty-printing utilities for [[https://cons.io/][Gerbil Scheme]].
|
|||
|
||||
- [[https://en.wikipedia.org/wiki/ANSI_escape_code#CSI_(Control_Sequence_Introducer)_sequences][ANSI control codes]] for styling and cursor movement
|
||||
- Table formatting with [[https://unicode-table.com/en/blocks/box-drawing/][Unicode box drawing characters]]
|
||||
- Horizontal rules
|
||||
|
||||
** References
|
||||
|
||||
|
|
3
build.ss
3
build.ss
|
@ -4,5 +4,6 @@
|
|||
|
||||
(defbuild-script
|
||||
'("fancy/format"
|
||||
"fancy/table")
|
||||
"fancy/table"
|
||||
"fancy/rule")
|
||||
optimize: #t)
|
||||
|
|
19
fancy/rule.ss
Normal file
19
fancy/rule.ss
Normal file
|
@ -0,0 +1,19 @@
|
|||
(export rule)
|
||||
|
||||
(import :std/misc/string
|
||||
:dlozeve/fancy/format)
|
||||
|
||||
(def (rule text width: (width 80) style: (style 'simple))
|
||||
(def rule-len (- width (+ 2 (string-length (remove-markup text)))))
|
||||
(def left-len (1- (quotient rule-len 2)))
|
||||
(def right-len (1- (+ (remainder rule-len 2) (quotient rule-len 2))))
|
||||
(def c (match style
|
||||
('simple #\━)
|
||||
('double #\═)
|
||||
('dashed #\╌)))
|
||||
(str (make-string left-len c)
|
||||
" "
|
||||
(parse-markup text)
|
||||
" "
|
||||
(make-string right-len c)
|
||||
"\n"))
|
Loading…
Add table
Add a link
Reference in a new issue