Enhanced printing functions for rendering Clojure values. The following options are available to control the printer:
:width
Number of characters to try to wrap pretty-printed forms at.
:print-meta
If true, metadata will be printed before values. Defaults to the value of
*print-meta*
if unset.
:sort-keys
Print maps and sets with ordered keys. If true, the pretty printer will sort all unordered collections before printing. If a number, counted collections will be sorted if they are smaller than the given size. Otherwise, collections are printed in their natural sort order. Sorted collections are always printed in their natural sort order.
:map-delimiter
The text placed between key-value pairs in a map.
:map-coll-separator
The text placed between a map key and a collection value. The keyword :line will cause line breaks if the whole map does not fit on a single line.
:namespace-maps
Extract common keyword namespaces from maps using the namespace map literal
syntax. See *print-namespace-maps*
.
:seq-limit
If set to a positive number, then lists will only render at most the first n elements. This can help prevent unintentional realization of infinite lazy sequences.
:coll-limit
If set to a positive number, then collections will only render at most the
first n elements. This can help prevent unintentional printing of large
collections. Note: :seq-limit
has higher precendence than :coll-limit
if both are set.
:print-color
When true, ouptut colored text from print functions.
:color-markup
:ansi for ANSI color text (the default), :html-inline for inline-styled html, :html-classes to use the names of the keys in the :color-scheme map as class names for spans so styling can be specified via CSS.
:color-scheme
Map of syntax element keywords to color codes.
:print-handlers
A lookup function which will return a rendering function for a given class
type. This will be tried before the built-in type logic. See the
puget.dispatch
namespace for some helpful constructors. The returned
function should accept the current printer and the value to be rendered,
returning a format document.
:print-fallback
Keyword argument specifying how to format unknown values. Puget supports a few different options:
:pretty
renders values with the default colored representation.:print
defers to the standard print method by rendering unknown values
using pr-str
.:error
will throw an exception when types with no defined handler are
encountered.Enhanced printing functions for rendering Clojure values. The following options are available to control the printer: #### General Rendering `:width` Number of characters to try to wrap pretty-printed forms at. `:print-meta` If true, metadata will be printed before values. Defaults to the value of `*print-meta*` if unset. #### Collection Options `:sort-keys` Print maps and sets with ordered keys. If true, the pretty printer will sort all unordered collections before printing. If a number, counted collections will be sorted if they are smaller than the given size. Otherwise, collections are printed in their natural sort order. Sorted collections are always printed in their natural sort order. `:map-delimiter` The text placed between key-value pairs in a map. `:map-coll-separator` The text placed between a map key and a collection value. The keyword :line will cause line breaks if the whole map does not fit on a single line. `:namespace-maps` Extract common keyword namespaces from maps using the namespace map literal syntax. See `*print-namespace-maps*`. `:seq-limit` If set to a positive number, then lists will only render at most the first n elements. This can help prevent unintentional realization of infinite lazy sequences. `:coll-limit` If set to a positive number, then collections will only render at most the first n elements. This can help prevent unintentional printing of large collections. Note: `:seq-limit` has higher precendence than `:coll-limit` if both are set. #### Color Options `:print-color` When true, ouptut colored text from print functions. `:color-markup` :ansi for ANSI color text (the default), :html-inline for inline-styled html, :html-classes to use the names of the keys in the :color-scheme map as class names for spans so styling can be specified via CSS. `:color-scheme` Map of syntax element keywords to color codes. #### Type Handling `:print-handlers` A lookup function which will return a rendering function for a given class type. This will be tried before the built-in type logic. See the `puget.dispatch` namespace for some helpful constructors. The returned function should accept the current printer and the value to be rendered, returning a format document. `:print-fallback` Keyword argument specifying how to format unknown values. Puget supports a few different options: - `:pretty` renders values with the default colored representation. - `:print` defers to the standard print method by rendering unknown values using `pr-str`. - `:error` will throw an exception when types with no defined handler are encountered. - A function value will be called with the current printer options and the unknown value and is expected to return a formatting document representing it.
Default options to use when constructing new printers.
Default options to use when constructing new printers.
(canonical-printer)
(canonical-printer handlers)
Constructs a new canonical printer with the given handler dispatch.
Constructs a new canonical printer with the given handler dispatch.
Map of print handlers for 'primary' Clojure types. These should take
precedence over the handlers in clojure-interface-handlers
.
Map of print handlers for 'primary' Clojure types. These should take precedence over the handlers in `clojure-interface-handlers`.
Fallback print handlers for other Clojure interfaces.
Fallback print handlers for other Clojure interfaces.
(color-text element text)
(color-text options element text)
Produces text colored according to the active color scheme. This is mostly
useful to clients which want to produce output which matches data printed by
Puget, but which is not directly printed by the library. Note that this
function still obeys the :print-color
option.
Produces text colored according to the active color scheme. This is mostly useful to clients which want to produce output which matches data printed by Puget, but which is not directly printed by the library. Note that this function still obeys the `:print-color` option.
Print handler dispatch combining Java and Clojure handlers with inheritance lookups. Provides a similar experience as the standard Clojure pretty-printer.
Print handler dispatch combining Java and Clojure handlers with inheritance lookups. Provides a similar experience as the standard Clojure pretty-printer.
(cprint value)
(cprint value opts)
Like pprint, but turns on colored output.
Like pprint, but turns on colored output.
(cprint-str value)
(cprint-str value opts)
Pretty-prints a value to a colored string.
Pretty-prints a value to a colored string.
(format-doc printer value)
Recursively renders a print document for the given value.
Recursively renders a print document for the given value.
(format-doc* printer value)
Formats a document without considering metadata.
Formats a document without considering metadata.
(format-unknown printer value)
(format-unknown printer value repr)
(format-unknown printer value tag repr)
Renders common syntax doc for an unknown representation of a value.
Renders common syntax doc for an unknown representation of a value.
Map of print handlers for Java types. This supports syntax for regular expressions, dates, UUIDs, and futures.
Map of print handlers for Java types. This supports syntax for regular expressions, dates, UUIDs, and futures.
(merge-options a b)
Merges maps of printer options, taking care to combine the color scheme correctly.
Merges maps of printer options, taking care to combine the color scheme correctly.
(pprint value)
(pprint value opts)
Pretty-prints a value to out. Options may be passed to override the default options map.
Pretty-prints a value to *out*. Options may be passed to override the default *options* map.
(pprint-str value)
(pprint-str value opts)
Pretty-print a value to a string.
Pretty-print a value to a string.
(pr-handler printer value)
Print handler which renders the value with pr-str
.
Print handler which renders the value with `pr-str`.
(pretty-printer opts)
Constructs a new printer from the given configuration.
Constructs a new printer from the given configuration.
(render-out printer value)
Prints a value using the given printer.
Prints a value using the given printer.
(render-str printer value)
Renders a value to a string using the given printer.
Renders a value to a string using the given printer.
(tagged-handler tag value-fn)
Generates a print handler function which renders a tagged-literal with the given tag and a value produced by calling the function.
Generates a print handler function which renders a tagged-literal with the given tag and a value produced by calling the function.
(unknown-handler printer value)
Print handler which renders the value using the printer's unknown type logic.
Print handler which renders the value using the printer's unknown type logic.
(with-color & body)
Executes the given expressions with colored output enabled.
Executes the given expressions with colored output enabled.
(with-options opts & body)
Executes the given expressions with a set of options merged into the current option map.
Executes the given expressions with a set of options merged into the current option map.
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close