string - Easy way to work with text without having to escape quotation marks in Clojure? -
i'm playing around text parsing in repl, , want dump in bunch of data string, whether it's bibtex entry or ebnf notation etc. typically there might quotation marks in string, , it's tedious , error-prone have manually escape them..
is there alternative way of doing this, such ruby's %q|i
can use "quotation marks"|
or heredocs
etc? or possible write macro or modification of reader enable this?
there has been some discussion more robust quoting syntax, no changes support seem imminent.
in meantime, handle repl interaction mention, might find useful. note doesn't work every repl out there -- don't support read-line
terribly well:
(defn read-lines [] (->> (repeatedly read-line) (take-while #(not= % ".")) (mapcat #(list % "\n")) (apply str)))
use running (read-lines)
@ repl, pasting content, , adding line .
itself:
user=> (read-lines) #_=> "works" #_=> sometimes... #_=> . "this \"works\"\nsometimes...\n" user=> (print *1) "works" sometimes... nil
Comments
Post a Comment