parinferish.core

(diff parsed-code)

Takes the result of `parse` and returns a vector of maps describing each insertion or removal made by parinferish.

Example

(parinferish.core/diff (parinferish.core/parse "([1\n 2\n 3]" {:mode :smart, :cursor-line 0, :cursor-column 1}))

(flatten parsed-code)

(flatten node-fn parsed-code)

Takes the result of `parse` and flattens it into a string. Optionally takes a `node-fn` which will receive each token and return whatever it wants, so you can have more control of what format it outputs to.

Examples

Run indent mode
(parinferish.core/flatten (parinferish.core/parse "(foo a" {:mode :indent}))
Run paren mode
(parinferish.core/flatten (parinferish.core/parse "(foo\na)" {:mode :paren}))
Run smart mode
(parinferish.core/flatten (parinferish.core/parse "([1\n 2\n 3]" {:mode :smart, :cursor-line 0, :cursor-column 1}))

(parse input)

(parse input opts)

Returns a hierarcichal (I can never spell that goddamn word) vector of tuples representing each distinct Clojure token from the input string. Takes an options map that allows you to apply parinferish via the :mode option (:indent, :paren, :smart). Note that if you use parinfer, the return value will include both the inserted and removed tokens. The tokens parinfer wants to remove will be removed by the `flatten` function.

Example

(parse "(+ 1 2)")