From 5d37362b0923e15a19d4892e1690b19243ff915d Mon Sep 17 00:00:00 2001 From: Dmitry Groshev Date: Sun, 19 May 2013 21:57:20 +0400 Subject: [PATCH] better pretty-printing --- resources/public/css/tryclojure.css | 48 ++++++++++++++++------------- src/tryclojure/views/eval.clj | 8 +++-- 2 files changed, 31 insertions(+), 25 deletions(-) diff --git a/resources/public/css/tryclojure.css b/resources/public/css/tryclojure.css index 58801f8..9f71ecb 100644 --- a/resources/public/css/tryclojure.css +++ b/resources/public/css/tryclojure.css @@ -48,43 +48,47 @@ body { border: 1px solid #aaa; } -#console div.jquery-console-inner { +#console .jquery-console-inner div { + white-space: pre; +} + +#console div.jquery-console-inner { width:580px; - height:200px; + height:200px; margin: 10px 10px; - overflow:auto; + overflow:auto; text-align:left; } #console div.jquery-console-message-value { - color:#0066FF; + color:#0066FF; font-family:monospace; - padding:0.1em; + padding:0.1em; } #console div.jquery-console-prompt-box { - color:#444; font-family:monospace; + color:#444; font-family:monospace; } #console div.jquery-console-focus span.jquery-console-cursor { background:#333; color:#eee; font-weight:bold; } #console div.jquery-console-message-error { color:#ef0505; font-family:sans-serif; font-weight:bold; - padding:0.1em; + padding:0.1em; } #console div.jquery-console-message-success { color:#187718; font-family:monospace; - padding:0.1em; + padding:0.1em; } -#console span.jquery-console-prompt-label { +#console span.jquery-console-prompt-label { font-weight:bold; } -.bottom { - background-color: white; color: #333; +.bottom { + background-color: white; color: #333; } -.bottom a,a:visited { - color: #111; +.bottom a,a:visited { + color: #111; } -table.bottom { +table.bottom { width: 100%; border: 1px solid black; } @@ -93,13 +97,13 @@ table.bottom { text-align: center; margin-top: 10px; } -#buttons a { +#buttons a { /* color: #4881d8;*/ color: #3D5B99; padding: .3em 1em; margin-right: .7em; font-family: Helvetica, sans-serif; - font-size: 16px; + font-size: 16px; font-weight: bold; background: #90b4fe; border-radius: 5px; @@ -110,10 +114,10 @@ table.bottom { } #buttons a:hover { color: #5881d8; - cursor: pointer; + cursor: pointer; } -#changer { +#changer { margin: 10px; padding: 0.25em 0.5em 0.25em 0.5em; background: #EAF2F5; @@ -148,11 +152,11 @@ div#tuttext { div.continue { width: 100%; text-align: center; - padding-top: 0.5em; + padding-top: 0.5em; } -div.footer { - text-align: center; +div.footer { + text-align: center; } /* Coderay alpha style */ @@ -204,7 +208,7 @@ table.code td { padding: 2px 4px; vertical-align: top; } /* operator */ #changer .code span.cl { - + } /* number */ diff --git a/src/tryclojure/views/eval.clj b/src/tryclojure/views/eval.clj index f9d0ff4..d04527a 100644 --- a/src/tryclojure/views/eval.clj +++ b/src/tryclojure/views/eval.clj @@ -1,7 +1,8 @@ (ns tryclojure.views.eval (:require [noir.core :refer [defpage]] [tryclojure.models.eval :refer [eval-request]] - [noir.response :as resp])) + [noir.response :as resp] + [clojure.pprint])) (defpage "/eval.json" {:keys [expr jsonp]} (let [{:keys [expr result error message] :as res} (eval-request expr) @@ -9,8 +10,9 @@ res (let [[out res] result] {:expr (pr-str expr) - :result (str out (pr-str res))}))] - + :result (str out (with-out-str (clojure.pprint/pprint res))) + }))] + (if jsonp (resp/jsonp jsonp data) (resp/json data)))) \ No newline at end of file