Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

implemented syntaxhighlighter in the page.

  • Loading branch information...
commit ba11df4f9d0395062754fdbfaa0aeb7b95f60fe2 1 parent 05f3cc0
@doolin doolin authored
View
50 source/content/_parse_tree.html.md
@@ -33,41 +33,37 @@ of the common tasks that need to be done inside of loops.
examples stolen from: http://common-lisp.net/project/iterate/doc/Introduction.html
-~~~~
+<pre class="brush:clojure">
(iter (for i from 1 to 10)
- (collect i))
-~~~~
-{:lang="ruby"}
+ (collect i))
+</pre>
This doesn't seem so exciting. Ruby has collect too, and some nice looping facilities. The ruby equiv is:
-~~~~
+<pre class="brush:ruby">
(1..10).map{|i| i} # =>[1,2,3,4,5,6,7,8,9,10]
-~~~~
-{:lang="ruby"}
+</pre>
But ITERATE has many more capabilities than the actually fairly limited set of things that ruby's each, map, inject, find, etc can do for you
This one iterates over a list and collects the odd numbers in it:
-~~~~
+<pre class="brush:clojure">
(iter (for el in list)
(if (and (numberp el) (oddp el))
(collect el)))
-~~~~
-{:lang="lisp"}
+</pre>
That kind of thing can't be done with map in the general case without falling back to the imperative form of loop; a while or for loop.
You can't do it with #collect.
-~~~~
+<pre class="brush:clojure">
(iter (for (key . item) in alist)
(for i from 0)
(declare (fixnum i))
(collect (cons i key)))
-~~~~
-{:lang="lisp"}
+</pre>
This loop takes the keys of an alist and returns a new alist associating
the keys with their positions in the original list. The compiler declaration
@@ -76,19 +72,20 @@ for i will appear in the generated code in the appropriate place.
To find the length of the shortest element in a list:
-~~~~
- (iterate (for el in list)
- (minimize (length el)))
-~~~~
-{:lang="lisp"}
+<pre class="brush:clojure">
+(iterate (for el in list)
+ (minimize (length el)))
+</pre>
+
To return t only if every other element of a list is odd:
- (iterate (for els on list by #'cddr)
- (always (oddp (car els))))
-
+<pre class="brush:clojure">
+(iterate (for els on list by #'cddr)
+ (always (oddp (car els))))
+</pre>
-http://common-lisp.net/project/iterate/doc/index.html
+* http://common-lisp.net/project/iterate/doc/index.html
Iterate allows you to declare your loop at high level, rather than getting
@@ -98,7 +95,8 @@ compiled down to the equivalent of efficient while loops, without
iterating over data sets multiple times or a lot of extra bookkeeping.
-~~~~
+
+<pre class="brush:ruby">
with foo.bar {
baz
quux
@@ -120,8 +118,8 @@ macro with arg
node
}
end
-~~~~
-{:lang="ruby"}
-
+</pre>
A small amount of math: \\(\forall x \in X\\)
+
+
View
8 source/index.html.haml
@@ -4,8 +4,8 @@
%div.subtitle
(a work in progress)
= partial 'content/introduction'
-= partial 'content/outline'
= partial 'content/parse_tree'
-= partial 'content/string_substitution'
-= partial 'content/examples'
-= partial 'content/conclusion'
+-#= partial 'content/string_substitution'
+-#= partial 'content/examples'
+-#= partial 'content/outline'
+-#= partial 'content/conclusion'
View
25 source/javascripts/syntaxhighlighter/scripts/shBrushClojure.js
@@ -0,0 +1,25 @@
+SyntaxHighlighter.brushes.Clojure = function()
+{
+ // Contributed by Travis Whitton
+
+ var funcs = ':arglists :doc :file :line :macro :name :ns :private :tag :test new alias alter ' +
+ 'and apply assert class cond conj count def defmacro defn defstruct deref do ' +
+ 'doall dorun doseq dosync eval filter finally find first fn gen-class gensym if ' +
+ 'import inc keys let list loop map ns or print println quote rand recur reduce ' +
+ 'ref repeat require rest send seq set sort str struct sync take test throw ' +
+ 'trampoline try type use var vec when while';
+
+ this.regexList = [
+ { regex: new RegExp(';[^\]]+$', 'gm'), css: 'comments' },
+ { regex: SyntaxHighlighter.regexLib.multiLineDoubleQuotedString, css: 'string' },
+ { regex: /\[|\]/g, css: 'keyword' },
+ { regex: /'[a-z][A-Za-z0-9_]*/g, css: 'color1' }, // symbols
+ { regex: /:[a-z][A-Za-z0-9_]*/g, css: 'color2' }, // keywords
+ { regex: new RegExp(this.getKeywords(funcs), 'gmi'), css: 'functions' }
+ ];
+
+ this.forHtmlScript(SyntaxHighlighter.regexLib.aspScriptTags);
+}
+
+SyntaxHighlighter.brushes.Clojure.prototype = new SyntaxHighlighter.Highlighter();
+SyntaxHighlighter.brushes.Clojure.aliases = ['clojure', 'Clojure', 'clj'];
View
6 source/layout.haml
@@ -8,8 +8,14 @@
-#= stylesheet_link_tag "coderay.css"
= stylesheet_link_tag "rubymacros.css"
= yield_content :head
+ <link href='http://alexgorbatchev.com/pub/sh/current/styles/shCore.css' rel='stylesheet' type='text/css'/>
+ <link href='http://alexgorbatchev.com/pub/sh/current/styles/shThemeDefault.css' rel='stylesheet' type='text/css'/>
%script{:src => "http://code.jquery.com/jquery-1.7.2.min.js", :type => "text/javascript"}
%script{:src => "https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.18/jquery-ui.min.js", :type => "text/javascript"}
+ %script{:src => "/javascripts/syntaxhighlighter/scripts/shCore.js"}
+ %script{:src => "/javascripts/syntaxhighlighter/scripts/shBrushClojure.js"}
+ <script src='http://alexgorbatchev.com/pub/sh/current/scripts/shBrushRuby.js' type='text/javascript'></script>
+ <script>SyntaxHighlighter.all();</script>
%script{:src => "http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML", :type => "text/javascript"}
%script{:src => "http://use.typekit.com/xqo0qff.js", :type => "text/javascript"}
:javascript
View
4 source/stylesheets/rubymacros.css.scss
@@ -41,6 +41,8 @@ h1 {
text-align: center;
font-size: 48px;
line-height: 60px;
+ padding-bottom: 0px;
+ margin-bottom: 10px;
}
p {
@@ -52,6 +54,7 @@ p {
div.subtitle {
text-align: center;
+ margin-bottom: 25px;
}
span.line-numbers {
@@ -59,6 +62,7 @@ span.line-numbers {
padding-right: 25px;
}
+
pre {
white-space: pre;
word-wrap: break-word;
Please sign in to comment.
Something went wrong with that request. Please try again.