Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a :print-fallback key to *options* to fall back on pr-str #18

Merged
merged 3 commits into from
Feb 27, 2015
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
uknown documents. The keyword :print will fall back to using `pr-str`
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo: 'uknown' should be 'unknown'. Also, put backticks around :print.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Heh, whoops.

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
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doh, nice catch.

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