Permalink
Browse files

Added PROPPER highlighting.

  • Loading branch information...
1 parent 70cf19b commit 441af377f233baa6914f0f951ab85568f5996778 @Licenser Licenser committed May 20, 2010
View
@@ -6,6 +6,7 @@
[ring/ring-jetty-adapter "0.2.0"]
[commons-lang/commons-lang "2.5"]
[clj-sandbox "0.3.7"]
+ [clj-highlight "0.1.0-SNAPSHOT"]
[hiccup "0.2.3"]
[clj-gist "1.0.0-SNAPSHOT"]]
:dev-dependencies [[swank-clojure "1.2.1"]
@@ -49,3 +49,126 @@ div.console div.jquery-console-message-success
{ color:#187718; font-family:monospace;
padding:0.1em; }
div.console span.jquery-console-prompt-label { font-weight:bold }
+
+/* Coderay alpha style */
+
+.code {
+ background-color: #f8f8f8;
+ border: 1px solid silver;
+/* font-family: 'Courier New', 'Terminal', monospace; */
+ color: #000;
+}
+.code pre { margin: 0px; }
+
+span.code { white-space: pre; border: 0px; padding: 2px; }
+
+table.code { border-collapse: collapse; width: 100%; padding: 2px; }
+table.code td { padding: 2px 4px; vertical-align: top; }
+
+.code .line_numbers, .code .no {
+ background-color: #def;
+ color: gray;
+ text-align: right;
+}
+.code .line_numbers a:target, .code .no a:target { color: blue; }
+.code .line_numbers .highlighted, .code .no .highlighted { color: red; }
+.code .no { padding: 0px 4px; }
+.code .code { width: 100%; }
+.code .code pre { overflow: auto; }
+
+.debug { color:white ! important; background:blue ! important; }
+
+.an { color:#007 }
+.at { color:#f08 }
+.av { color:#700 }
+.bi { color:#509; font-weight:bold }
+.c { color:#888; }
+.c .dl { color:#444; }
+.c .ch { color:#444; }
+
+.ch { color:#04D }
+.ch .k { color:#04D }
+.ch .dl { color:#039 }
+
+.cl { color:#B06; font-weight:bold }
+.cm { color:#A08; font-weight:bold }
+.co { color:#036; font-weight:bold }
+.cr { color:#0A0 }
+.cv { color:#369 }
+.de { color:#B0B; }
+.df { color:#099; font-weight:bold }
+.di { color:#088; font-weight:bold }
+.dl { color:black }
+.do { color:#970 }
+.dt { color:#34b }
+.ds { color:#D42; font-weight:bold }
+.e { color:#666; font-weight:bold }
+.en { color:#800; font-weight:bold }
+.er { color:#F00; background-color:#FAA }
+.ex { color:#C00; font-weight:bold }
+.fl { color:#60E; font-weight:bold }
+.fu { color:#06B; font-weight:bold }
+.gv { color:#d70; font-weight:bold }
+.hx { color:#058; font-weight:bold }
+.i { color:#00D; font-weight:bold }
+.ic { color:#B44; font-weight:bold }
+
+.il { background-color: hsla(0,0%,0%,0.1); color: black }
+.il .idl { font-weight: bold; color: #666 }
+.idl { font-weight: bold; color: #666; }
+
+.im { color:#f00; }
+.in { color:#B2B; font-weight:bold }
+.iv { color:#33B }
+.la { color:#970; font-weight:bold }
+.lv { color:#963 }
+.ns { color:#707; font-weight:bold }
+.oc { color:#40E; font-weight:bold }
+.op { }
+.pc { color:#058; font-weight:bold }
+.pd { color:#369; font-weight:bold }
+.pp { color:#579; }
+.ps { color:#00C; font-weight:bold }
+.pt { color:#074; font-weight:bold }
+.r, .kw { color:#080; font-weight:bold }
+
+.ke { color: #808; }
+.ke .dl { color: #606; }
+.ke .ch { color: #80f; }
+.vl { color: #088; }
+
+.rx { background-color:hsla(300,100%,50%,0.1); color:#808 }
+.rx .k { }
+.rx .dl { color:#404 }
+.rx .mod { color:#C2C }
+.rx .fu { color:#404; font-weight: bold }
+
+.s { background-color:hsla(0,100%,50%,0.1); color: #D20; }
+.s .k { }
+.s .ch { color: #b0b; }
+.s .dl { color: #710; }
+
+.sh { background-color:hsla(120,100%,50%,0.1); color:#2B2 }
+.sh .k { }
+.sh .dl { color:#161 }
+
+.sy { color:#A60 }
+.sy .k { color:#A60 }
+.sy .dl { color:#630 }
+
+.ta { color:#070 }
+.ts { color:#D70; font-weight:bold }
+.ty { color:#339; font-weight:bold }
+.v { color:#036 }
+.xt { color:#444 }
+
+.ins { background: #afa; }
+.del { background: #faa; }
+.chg { color: #aaf; background: #007; }
+.head { color: #f8f; background: #505 }
+.head .filename { color: white; }
+
+.ins .ins { color: #080; font-weight:bold }
+.del .del { color: #800; font-weight:bold }
+.chg .chg { color: #66f; }
+.head .head { color: #f4f; }
@@ -392,7 +392,7 @@
function message(msg,className) {
var mesg = $('<div class="jquery-console-message"></div>');
if (className) mesg.addClass(className);
- mesg.filledText(msg).hide();
+ mesg.html(msg).hide();
inner.append(mesg);
mesg.show();
};
View
@@ -15,8 +15,6 @@
(whitelist
(function-matcher 'println 'print 'pr 'prn 'var 'print-doc 'doc 'throw
'def 'def* 'dosync 'alter '.))))
-
-
(def state-tester
(new-tester (whitelist (constantly '(true)))
(blacklist (function-matcher 'def 'def*
@@ -39,7 +37,7 @@
(recur (next history)))))
(with-open [writer (java.io.StringWriter.)]
(let [r (pr-str ((sc form) {'*out* writer}))]
- [(str writer r)
+ [(str (.replace (escape-html writer) "\n" "<br/>") (highlight (str r)))
(if (has-state? form) (conj history form) history)]))
(catch TimeoutException _ ["Execution Timed Out!" history])
(catch SecurityException _ ["Disabled for security purposes." history])
@@ -1,7 +1,22 @@
(ns tryclojure.tutorial
- (:use hiccup.core))
+ (:use hiccup.core
+ clj-highlight.core))
-(defn code [s] (html [:code.code s]))
+(def clj-tokenizer
+ (mangle-tokens
+ :space
+ (fn [k t s]
+ [k (.replace t "\n" "<br/>") s])
+ (mangle-tokens
+ nil
+ (fn [k t s]
+ [k (escape-html t) s])
+ (tokenizer clj-syntax))))
+
+(defn highlight [code]
+ (html (to-html default-stype-map "code" (clj-tokenizer code))))
+
+(defn code [s] (highlight s))
(def tutorial0-text
(html

5 comments on commit 441af37

Instead of changing line 395 of the library itself in a way that doesn't really enhance it but regresses, in your code you can use the inner element:

       commandHandle:function(line){
           controller2.inner.append('<p>sausages</p>');
           return true;
      });

Easy! I'll fork and submit a merge request.

Maybe we could change the library to be able to return e.g. {html: "foo"} instead. But you get more control if you can modify the inner element directly. It's exported exactly for this reason. It's just an element that stuff's appended to.

Owner

Raynes replied Nov 5, 2010

In case anybody wonders what happened to this, chrisdone forked and tried to fix it, but failed and gave up. His idea might still work in theory with a little work, but I haven't tried.

Actually I forgot about it. Am I a bad man? IS THAT A CRIME?

Owner

Raynes replied Nov 5, 2010

Hah! I didn't make assumptions. I remember asking about it a while back and your recommendation was to just reset your commits. I assumed then that you had given up.

I've recently started a bit of a revitalization movement to try to get tryclojure to progress, so I added that comment to give context.

In any case, you are welcome to give it a go when/if you get the time. It would make it a lot easier if there weren't modifications. There is a wiki page on running tryclojure to refresh your memory: https://github.com/Raynes/tryclojure/wiki/Running-Tryclojure

I couldn't get it to run and then forgot about it. I'll try it again some time. If it's as easy to run as your guide says it is, this should be a walk in the park, like taking candy from a baby.

Please sign in to comment.