(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}))

Source

(defn flatten "Takes the result of `parse` and flattens it into a string. Optionally takes a\n `node-fn` which will receive each token and return whatever it wants, so you can\n have more control of what format it outputs to." ([parsed-code] (->> parsed-code (flatten (fn* [p1__42585#] (-> p1__42585# rest str/join))) str/join)) ([node-fn parsed-code] (let [m (meta parsed-code) disable-parinfer? (and (= :paren (:mode m)) (:error? m))] (reduce (fn [v code] (into v (node-iter node-fn [] code disable-parinfer?))) [] parsed-code))))