Liking cljdoc? Tell your friends :D

jj.bettong.impl.edn-text

Editing EDN through a syntax tree that keeps everything a reader throws away.

clojure.edn/read-string gives you data, and data has no comments, no key order and no indentation - so no writer can put them back. The tree here keeps whitespace, comments and #_ discards as nodes of their own, which makes rendering it the exact original text and an edit a change to one node.

Nodes are plain maps:

{:type :whitespace :text " \n\n"} {:type :comment :text ";; why this is 3000"} {:type :token :text "8080"} {:type :map :open "{" :close "}" :children [...]} {:type :wrapper :text "#inst" :children [...]} ; #_ ^meta 'quote #tag

parse and render are inverses: (= s (render (parse s))) for any EDN.

Editing EDN through a syntax tree that keeps everything a reader throws away.

`clojure.edn/read-string` gives you data, and data has no comments, no key
order and no indentation - so no writer can put them back. The tree here
keeps whitespace, comments and `#_` discards as nodes of their own, which
makes rendering it the exact original text and an edit a change to one node.

Nodes are plain maps:

  {:type :whitespace :text " \n\n"}
  {:type :comment    :text ";; why this is 3000"}
  {:type :token      :text "8080"}
  {:type :map        :open "{" :close "}" :children [...]}
  {:type :wrapper    :text "#inst" :children [...]}   ; #_ ^meta 'quote #tag

`parse` and `render` are inverses: (= s (render (parse s))) for any EDN.
raw docstring

delete-in-strclj

(delete-in-str s path)

EDN text with path removed, leaving the formatting around it alone.

EDN text with `path` removed, leaving the formatting around it alone.
raw docstring

locateclj

(locate ast path)

The get-in keys that reach the node holding the value at path, or nil.

The `get-in` keys that reach the node holding the value at `path`, or nil.
raw docstring

parseclj

(parse s)

EDN text as a tree of nodes. Nothing is discarded, so render reproduces the input exactly.

EDN text as a tree of nodes. Nothing is discarded, so `render` reproduces the
input exactly.
raw docstring

renderclj

(render node)

The text a node stands for.

The text a node stands for.
raw docstring

set-in-strclj

(set-in-str s path value)

EDN text with path set to value, as an edit to one node of the tree. Every comment, blank line and column outside that node is the text that was already there.

EDN text with `path` set to `value`, as an edit to one node of the tree.
Every comment, blank line and column outside that node is the text that was
already there.
raw docstring

cljdoc builds & hosts documentation for Clojure/Script libraries

Keyboard shortcuts
Ctrl+kJump to recent docs
Move to previous article
Move to next article
Ctrl+/Jump to the search field
× close