Permalink
Browse files

Trying to fix merge thing

zip blah doo whap
  • Loading branch information...
1 parent 7bce90c commit 1110bc1e121218e237a6e235ce573d48a1d46ed9 @admiralbumblebee admiralbumblebee committed Oct 12, 2012
View
@@ -12,3 +12,4 @@ _site/*
_source/*
deploy.sh
repl*
+_cache/*
View
@@ -1,6 +1,7 @@
source :rubygems
gem "jekyll"
-gem "rdiscount"
+# gem "rdiscount"
+gem "redcarpet"
gem "haml"
gem "RedCloth"
View
@@ -21,7 +21,7 @@ GEM
maruku (0.6.0)
syntax (>= 1.0.0)
posix-spawn (0.3.6)
- rdiscount (1.6.8)
+ redcarpet (2.2.1)
syntax (1.0.0)
PLATFORMS
@@ -31,4 +31,4 @@ DEPENDENCIES
RedCloth
haml
jekyll
- rdiscount
+ redcarpet
View
@@ -6,11 +6,12 @@ CDS reuses the [ClojureWerkz docslate](http://github.com/clojurewerkz/docslate)
## Install Tools & Dependencies
-First, install [Bundler](http://getbundler.com). Ruby 1.9.3 or JRuby are recommended:
+First, install [Bundler](http://gembundler.com). Ruby 1.9.3 or JRuby are recommended:
gem install bundler
-Then install dependencies
+Then install dependencies (Jekyll, GitHub-flavored Markdown processors, etc) with Bundler
+by running the following in the CDS repository root:
bundle install --binstubs
View
@@ -3,6 +3,9 @@ destination: ./_site
plugins: ./_plugins
auto: true
exclude: [bin, CNAME, Gemfile, Gemfile.lock, README.md]
-markdown: rdiscount
permalink: /:title
-pygments: true
+pygments: true
+# markdown: rdiscount
+markdown: redcarpet2
+redcarpet:
+ extensions: ["no_intra_emphasis", "fenced_code_blocks", "autolink", "tables", "with_toc_data"]
@@ -0,0 +1,48 @@
+require 'fileutils'
+require 'digest/md5'
+require 'redcarpet'
+require 'albino'
+
+PYGMENTS_CACHE_DIR = File.expand_path('../../_cache', __FILE__)
+FileUtils.mkdir_p(PYGMENTS_CACHE_DIR)
+
+class Redcarpet2Markdown < Redcarpet::Render::HTML
+ def block_code(code, lang)
+ lang = lang || "text"
+ path = File.join(PYGMENTS_CACHE_DIR, "#{lang}-#{Digest::MD5.hexdigest code}.html")
+ cache(path) do
+ colorized = Albino.colorize(code, lang)
+ add_code_tags(colorized, lang)
+ end
+ end
+
+ def add_code_tags(code, lang)
+ code.sub(/<pre>/, "<pre><code class=\"#{lang}\">").
+ sub(/<\/pre>/, "</code></pre>")
+ end
+
+ def cache(path)
+ if File.exist?(path)
+ File.read(path)
+ else
+ content = yield
+ File.open(path, 'w') {|f| f.print(content) }
+ content
+ end
+ end
+end
+
+class Jekyll::MarkdownConverter
+ def extensions
+ Hash[ *@config['redcarpet']['extensions'].map {|e| [e.to_sym, true] }.flatten ]
+ end
+
+ def markdown
+ @markdown ||= Redcarpet::Markdown.new(Redcarpet2Markdown.new(extensions), extensions)
+ end
+
+ def convert(content)
+ return super unless @config['markdown'] == 'redcarpet2'
+ markdown.render(content)
+ end
+end
View
@@ -12,29 +12,33 @@ its ecosystem.
CDS recognizes that different Clojure users have different level of expertise
and separates content into several groups:
- * Tutorials
- * Core language guides
- * Ecosystem (tools, libraries, community, books) guides
- * Cookbooks
+ * [Tutorials](#tutorials)
+ * [Core language guides](#clojure_language_guides)
+ * [The Ecosystem](#ecosystem) (tools, libraries, community, books) guides
+ * [Cookbooks](#cookbooks)
## Tutorials
-### [Getting Started](/articles/tutorials/getting_started.html) (Semi-complete)
+### [Getting Started](/articles/tutorials/getting_started.html) (Partially Complete)
If you're new to Clojure, this is a good place to start.
-### [Introduction](/articles/tutorials/introduction.html) (Semi-complete)
+### [Introduction](/articles/tutorials/introduction.html) (Partially Complete)
A swift introduction to the Clojure language, covering most of the
basics.
+### [Eclipse and Counterclockwise for Clojure Development](/articles/tutorials/eclipse.html) (Partially Complete)
+
+A brief introduction to Counterclockwise, a Clojure plugin for Eclipse.
+
## Clojure Language Guides
-### [Functions](/articles/language/functions.html) (Mostly Complete)
+### [Functions](/articles/language/functions.html) (Partially Complete)
Functions are at the heart of Clojure.
@@ -59,7 +63,7 @@ This guide covers:
* Key vars of `clojure.core`
-### [Interoperability with Java](/articles/language/interop.html) (In Progress)
+### [Interoperability with Java](/articles/language/interop.html) (Partially Complete)
The Clojure language implementation is symbiotic with its host
platform (the JVM), providing direct interoperability.
@@ -74,7 +78,7 @@ This guide covers:
* Other topics related to interop
-### [Namespaces](/articles/language/namespaces.html) (TBD)
+### [Namespaces](/articles/language/namespaces.html) (In Progress)
Namespaces organize Clojure functions.
@@ -86,7 +90,7 @@ This guide covers:
* How code compilation works in Clojure
-### [Polymorphism: Protocols and Multimethods](/articles/language/polymorphism.html) (In Progress)
+### [Polymorphism: Protocols and Multimethods](/articles/language/polymorphism.html) (Partially Complete)
This guide covers:
@@ -15,15 +15,15 @@ the JDK via interoperability.
Note that for the examples below, "io" is an alias for
clojure.java.io. That is, it's assumed your `ns` macro contains:
-{% highlight clojure %}
+``` clojure
(:require [clojure.java.io :as io])
-{% endhighlight %}
+```
or else in the repl you've loaded it:
-{% highlight clojure %}
+``` clojure
(require '[clojure.java.io :as io])
-{% endhighlight %}
+```
@@ -32,9 +32,9 @@ or else in the repl you've loaded it:
### Read a file into one long string
-{% highlight clojure %}
+``` clojure
(def a-long-string (slurp "foo.txt"))
-{% endhighlight %}
+```
Note, you can pass urls to `slurp` as well. See also [slurp at
Clojuredocs](http://clojuredocs.org/clojure_core/clojure.core/slurp).
@@ -45,10 +45,10 @@ Clojuredocs](http://clojuredocs.org/clojure_core/clojure.core/slurp).
Suppose you'd like to call `my-func` on every line in a file,
and return the resulting sequence:
-{% highlight clojure %}
+``` clojure
(with-open [rdr (io/reader "foo.txt")]
(doall (map my-func (line-seq rdr))))
-{% endhighlight %}
+```
The `doall` is needed because the `map` call is lazy. The lines that
`line-seq` gives you have no trailing newlines (and empty lines in the
@@ -57,43 +57,43 @@ file will yield empty strings ("")).
### Write a long string out to a new file
-{% highlight clojure %}
+``` clojure
(spit "foo.txt"
"A long
multi-line string.
Bye.")
-{% endhighlight %}
+```
Overwrites the file if it already exists. To append, use
-{% highlight clojure %}
+``` clojure
(spit "foo.txt" "file content" :append true)
-{% endhighlight %}
+```
### Write a file one line at a time
Suppose you'd like to write out every item in a vector, one item per
line:
-{% highlight clojure %}
+``` clojure
(with-open [wrtr (io/writer "foo.txt")]
(doseq [i my-vec]
(.write wrtr (str i "\n"))))
-{% endhighlight %}
+```
### Check if a file exists
-{% highlight clojure %}
+``` clojure
(.exists (io/file "filename.txt"))
-{% endhighlight %}
+```
Is it a directory? :
-{% highlight clojure %}
+``` clojure
(.isDirectory (io/file "path/to/something"))
-{% endhighlight %}
+```
An io/file is a java.io.File object (a file or a directory). You can
call a number of functions on it, including:
@@ -113,14 +113,14 @@ docs](http://docs.oracle.com/javase/7/docs/api/java/io/File.html).
As `File` objects:
-{% highlight clojure %}
+``` clojure
(.listFiles (io/file "path/to/some-dir"))
-{% endhighlight %}
+```
Same, but just the *names* (strings), not File objects:
-{% highlight clojure %}
+``` clojure
(.list (io/file "path/to/some-dir"))
-{% endhighlight %}
+```
The results of those calls are seqable.
@@ -1,5 +1,5 @@
---
-title: "Doing with Mathematics in Clojure"
+title: "Mathematics with Clojure"
layout: article
---
@@ -19,17 +19,17 @@ and
contrib libraries. It's assumed that either you have the following in
your source code's `ns` macro:
-{% highlight clojure %}
+``` clojure
(:require [clojure.math.numeric-tower :as math]
[clojure.math.combinatorics :as combo])
-{% endhighlight %}
+```
or else in the repl you've loaded them like so:
-{% highlight clojure %}
+``` clojure
(require '[clojure.math.numeric-tower :as math])
(require '[clojure.math.combinatorics :as combo])
-{% endhighlight %}
+```
Oops, something went wrong.

0 comments on commit 1110bc1

Please sign in to comment.