Skip to content

Commit

Permalink
Merge pull request #18 from venantius/develop
Browse files Browse the repository at this point in the history
Add a :print-fallback key to *options* to fall back on pr-str
  • Loading branch information
greglook committed Feb 27, 2015
2 parents 7e523ae + 71457e5 commit 65c0ff5
Showing 1 changed file with 17 additions and 9 deletions.
26 changes: 17 additions & 9 deletions src/puget/printer.clj
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@
The text placed between a map key and a collection value. The keyword :line
will cause line breaks if the whole map does not fit on a single line.
`:print-fallback`
Takes a keyword argument specifying the desired string representation of
unknown documents. The keyword `:print` will fall back to using `pr-str`
rather than puget's default unknown-document representation.
`:print-meta`
If true, metadata will be printed before values. If nil, defaults to the
value of *print-meta*.
Expand All @@ -55,6 +60,7 @@
:strict false
:map-delimiter ","
:map-coll-separator " "
:print-fallback nil
:print-meta nil
:print-color false
:color-markup :ansi
Expand Down Expand Up @@ -121,7 +127,7 @@


(defn- illegal-when-strict!
"Throws an exception if strict mode is enabled. The error indincates that the
"Throws an exception if strict mode is enabled. The error indicates that the
given value has no EDN representation."
[value]
(when (:strict *options*)
Expand Down Expand Up @@ -202,14 +208,16 @@
(unknown-document value (.getName (class value)) repr))
([value tag repr]
(illegal-when-strict! value)
[:span
(color-doc :class-delimiter "#<")
(color-doc :class-name tag)
(color-doc :class-delimiter "@")
(system-id value)
" "
repr
(color-doc :class-delimiter ">")]))
(case (:print-fallback *options*)
:print [:span (pr-str value)]
[:span
(color-doc :class-delimiter "#<")
(color-doc :class-name tag)
(color-doc :class-delimiter "@")
(system-id value)
" "
repr
(color-doc :class-delimiter ">")])))



Expand Down

0 comments on commit 65c0ff5

Please sign in to comment.