Hiccup-like DSL for pretty-printed terminal output.
Pretty-term provides two sets of features under a unified DSL: layout and ANSI formatting.
The layout side is based on "The Design of a Pretty-printing Library" (Hughes 1995).
(def document
[:lines
[:bold "This is a heading"]
[:bullets
[:color :red "This is some red text"]
[:lines
[:color :green "This is some green text"]
"Some extra text"
"And some more"]
[:color :blue "This is some blue text"]]])
(require '[pretty-term.core :as pretty])
(println (pretty/render document))
The namespace pretty-term.core
exports a single function (render dsl)
which will interpret the dsl
input and generate a string.
(require '[pretty-term.core :refer [render]])
(println
(render
[:lines "Line one"
"Line two"
"Line three"]))
Empty document.
Text document.
Simply renders string
as regular text.
Vertically concatenates docs
by putting each of them on their own line.
Creates a new nested block.
Creates a new nested block.
Horizontally concatenates docs
together.
Vertically concatenates docs
as a bulleted list.
Renders doc
in a bold typeface.
Renders doc
in an italic typeface.
Renders doc
in an underlined typeface.
Renders doc
with the foreground color set to color
. (see colors)
Renders doc
with the background color set to color
. (see colors)
The following values for color are supported:
:black
:white
:red
:green
:blue
:cyan
:magenta
:yellow
:default