std.pretty

+defaults+

canonical-printer

added in 3.0

(canonical-printer)(canonical-printer handlers)

constructs a canonical printer

(canonical-printer {}) => std.pretty.CanonicalPrinter

clojure-handlers

Map of print handlers for ‘primary’ Clojure types. These should take precedence over the handlers in clojure-interface-handlers.

clojure-interface-handlers

Fallback print handlers for other Clojure interfaces.

common-handlers

Print handler dispatch combining Java and Clojure handlers with inheritance lookups. Provides a similar experience as the standard Clojure pretty-printer.

format-doc

added in 3.0

(format-doc printer value)

provides a format given a printer and value

(format-doc (canonical-printer) :hello) => “:hello”

(format-doc (pretty-printer {}) :hello) => [:span [:pass "34m" “:hello” [:pass "0m"]

format-doc-edn

added in 3.0

(format-doc-edn printer value)

provides a meta-less print formatter

(format-doc-edn (pretty-printer {}) :hello) => [:span [:pass "34m" “:hello” [:pass "0m"]

format-unknown

added in 3.0

(format-unknown printer value)(format-unknown printer value repr)(format-unknown printer value tag repr)

custom printer for an unknown type

(format-unknown (canonical-printer) :hello) => (contains-in :span “#<” “clojure.lang.Keyword” “@” string? ’(" " “:hello”) “>”)

java-handlers

Map of print handlers for Java types. This supports syntax for regular expressions, dates, UUIDs, and futures.

pprint

added in 3.0

(pprint value)(pprint value opts)

pretty prints with options

(pprint {:a 1 :b 2 :c (range 5)} {:width 10})

pprint-cc

added in 4.0

(pprint-cc & items)

pprint with the std.concurrent.print framework

(std.concurrent.print/with-out-str (pprint-cc {:a 1 :b 2 :c (range 5)})) => string?

pprint-str

added in 3.0

(pprint-str value)(pprint-str value opts)

returns the string that is printed

(pprint-str {:a 1 :b 2 :c (range 5)} {:width 10}) => string?

pr-handler

added in 3.0

(pr-handler printer value)

creates a print handler for printing strings

(pr-handler (canonical-printer) 1 2 3 4) => “1 2 3 4

pretty-printer

added in 3.0

(pretty-printer opts)

constructs a pretty printer

(pretty-printer {}) => std.pretty.PrettyPrinter

render-out

added in 3.0

(render-out printer value)

helper to pprint and pprint-str

(with-out-str (render-out (canonical-printer) {:a 1 :b 2 :c (range 5)})) => “{:a 1 :b 2 :c (0 1 2 3 4)}”

tagged-handler

added in 3.0

(tagged-handler tag value-fn)

creates a custom handler for a tagged literal

((tagged-handler ’object (fn x(map inc x))) (canonical-printer {}) 1 2 3 4) => [:span “#object” " " [:group “(” :align ’(“2” " " “3” " " “4” " " “5”) “)”]]

unknown-handler

added in 3.0

(unknown-handler printer value)

creates a custom handler for an unknown object

(unknown-handler (canonical-printer) (Thread/currentThread)) => (throws)