clj-format 0.1.1 — now fully supporting CLJS
A Clojure DSL for cl-format inspired by Hiccup. No dependencies. Drop-in compatibility. The power of FORMAT made easy.
See https://github.com/danlentz/clj-format/blob/master/doc/examples.md from Practical Common Lisp, CLtL2, and the CL HyperSpec.
Key features:
- Full string passthrough for existing clojure.pprint/cl-format usage
- Hiccup-style [:keyword {opts} & body] language convention
- Semantic option names: {:group true :sign :always} instead of :colon/:at flags
- All 33 cl-format directives
- parse-format parses format strings into the DSL
- compile-format compiles the DSL back to format strings
- Round-trip fidelity
- Works on Clojure, ClojureScript, and Babashka
- Turing complete (!)
https://github.com/danlentz/clj-format
Cool, does it support named arguments?
Like ~@<~A~:name~>
i think we are at parity with format strings in the next version. Plus a new (pretty cool) :table extension to the DSL which is very useful. And an (eg) :figlet {:font "graffiti"} for figlet fonts. (my clj-figlet library). the higher level DSL for table formattiing is crazy useful
sorry i mean in 0.1.2. I haven't merged it yet but theres not a lot left
FWIW, i suck badly at format strings but its pretty amazing how rich a language it is (motivation for this)
0.1.2 supports nested tabl;es, figlet fonts in tables, word wrap in cells. and its simple/easy/convenient
i use this library everywhere now i'll never go back
surprisingly (or not? its hard to say anymore) but claude is very good at working with this DSL and generating your higher level output in it (fancy tables etc) but then its in a very clear, easy, maintainable language you can understand at a glance and work with by hand
Ya cl-format is really powerful once you learn it, it's not that complicated too if you give it a chance
The only thing I don't like is positional arguments, and the cl-format in Clojure only supports that. I feel that's the most antiquated part of it. But CL does have the named arguments syntax, not the nicest lol but it works
i'm terrible at it. its actually turing complete. i'm going to leave it as an exercise for the reader to implement DOOM in the format string DSL
there are some minor differences between common lisp format / clojure cl-format. we're just focusing here on a parser / compiler for a better language to express what cl-format supports
and one that i can remember lol
i'm sort of amazed this didn't exist before