zprint is a library and command line tool providing a variety of pretty printing capabilities for both Clojure code and Clojure/EDN structures. It can meet almost anyone's needs. As such, it supports a number of major source code formattng approaches.
:fn-map
. If the value in
the :fn-map
is a string, then the formatting for that function is used.
This makes having one function format like another much easier to configure.-str
fns and prebuilt
binaries support {:output {:format :hiccup}}
and {:output {:format :html}}
.
EXPERIMENTAL for now -- as always, please let me know of any issues.1.11.1
, Clojurescript 1.11.4
{:output {:range? true}}
to ease integration with IDE's.{:map {:key-value-options {key-1 options-map-1 key-2 options-map-2 ...}}
lets you specify an options map to be used
for formatting the value of any specific key in any map.:ns-justify
, which will nicely format ns
macros.
:quote-wrap
which will cause a quoted list to wrap, and not format each item
running down the page, to mention a few.{:style :justified}
to try it out!are
macro is now formatted readably by default.$ zprint -w file.clj
and $ zprint -w *.clj
-c
or --check
: $ zprint -c *.clj
..zprintrc
files using any distributed binaries, using sci
..zprintrc
. You can also define one style in terms of another.$ zprint '{:color? true}' <file.clj
:style :dark-color-map
} when using dark terminalsIn addition, zprint is very handy to use at the REPL.
Maybe one of the existing "styles" will meet your needs. All you have to
do is put {:style ...}
on the command line or as the third argument
to a zprint call. For example, {:style :community}
or
{:style :respect-bl}
.
Some commonly used styles:
quote
, deref
, var
, unquote
in structuresLeiningen (via Clojars)
zprint has been tested in each of the following environments:
planck
2.26.0 (Clojurescript 1.10.914)It requires tools.reader
at least 1.0.5, which all of the environments
above contain.
The last zprint release built with Clojure 1.8 was [zprint "0.4.15"].
In addition to the zprint dependency, you also need to include the following library when using Clojure 1.8:
[clojure-future-spec "1.9.0-alpha17"]
:style
quote
, deref
, var
, unquote
in structureslet
binding vectorscond
, assoc
pairsInformation on testing and development can be found here.
A number of folks have contributed to zprint, not all of whom show up on GitHub because I have integrated the code or suggestions manually. Thanks for all of the great contributions!
rewrite-cljs
dependency to 0.4.5
@rundis/--url
and --url-only
: @coltnzUTF-8
locale to build the native image: @mynomoto:respect-bl
: @griffis:option-fn
and :fn-format
for enhanced vector formatting: @milankinenspec.cljc
: @Quezionns
macro: @pesterhazyThanks to everyone who has contributed fixes as well as everyone who has reported an issue. I really appreciate all of the help making zprint better for everybody!
At the core of zprint
is the rewrite-clj
library originally
created by Yannick Scherer, ported to Clojurescript by Magnus
Rundberget, and recently merged into a single, supported, documented,
and updated library by Lee Read. This is a great library! I would not have
attempted zprint
if rewrite-clj
didn't exist to build upon.
Additionally, allowing options maps containing functions to be read
from files safely is made possible by sci
, the Small Clojure Interpreter
by Michael Borkent (@borkdude). This is a very well designed and
implemented addition to Clojure that required almost no effort to integrate
into zprint.
Copyright © 2016-2022 Kim Kinnear
Distributed under the MIT License. See the file LICENSE for details.
Can you improve this documentation? These fine people already did:
Kim Kinnear, Quest Yarbrough, vemv, Andrea Richiardi & Brian HurlowEdit on GitHub
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close