So we can still embed code in the prose, and it will be syntax-highlighted. Super! So let's test sytax highlighting in other languages. Like maybe clojure(script)?
; this is a snippet of the strokes quadtree gist (4409139)
; Check it out clojurists - here we generate a lazy-seq of maps
(defn gen-data []
(for [x (range 2500)]
{:x (rand width), :y (rand height)}))
; then we later call this function, and pass the result off directly
; to both d3.geom.quadtree and d3.selection.data (native js functions)!
(let [svg (gen-svg)
data (gen-data)]
(reset! quadtree
(-> d3 .-geom
(.quadtree data -1 -1 (+ width 1) (+ height 1))))
(reset! point (-> svg (.selectAll ".point")
(.data data)
(.enter) (.append "circle")
(.attr "class" "point")
(.attr "cx" :x)
(.attr "cy" :y)
(.attr "r" 4)))
Or maybe coffeescript?
# this is a snippet of bclinkinbeard's gist (2698389)
circles.attr("cx", (d) -> xScale d[0])
circles.attr("cy", (d) -> yScale d[1])
circles.attr("r", (d) -> rScale d[1])
svg.append("g")
.attr("class", "axis")
.attr("transform", "translate(0, #{h - padding})")
.call(xAxis)
svg.append("g")
.attr("class", "axis")
.attr("transform", "translate(#{padding}, 0)")
.call(yAxis)
OK, so not currently working on bl.ocks.org. But this pull request will fix it.
Incidentally, I miss the fact that bl.ocks.org was filtering gists based on index.html - now a bunch of non-d3 gists are cluttering my user page. Maybe I should experiment with a more selective heuristic like:
if (fileExists("thumbnail.png") || fileExists(".blocks.org"))
// show this gist
else
// hide this gist