 ; be determined by the largest comment or code chunk and not the total size of
 ; the source file.
 
-(defn render-file [tag path]
-  (with-open [r (io/reader path)]
-    (println (str "<" tag ">"))
-    (each html<- (gather-lines (line-seq r)))
-    (println (str "</" tag ">"))))
+(defn render-file [tag path & [token lang]]
+  (let [lang (or lang (re-find #"(?<=\.)[^.]+$" path))
+        token (or token (first (languages lang)))]
+    (when-let [b (and lang (second (languages lang)))]
+      (message path " auto-associated with brush " b)
+      (swap! brushes conj b))
+    (with-open [r (io/reader path)]
+      (binding [*single-comment* (or token *single-comment*)
+                *language* (or lang *language*)]
+        (println (str "<" tag ">"))
+        (each html<- (gather-lines (line-seq r)))
+        (println (str "</" tag ">"))))))
 
 ; Code chunks are wrapped in a `pre` with the correct incantation for
 ; SyntaxHighlighter in its `class` attribute; comments are run through the

(defn look-and-feel []
  (inline-js (slurp-resource "XRegExp.js"))
  (inline-js (slurp-resource "shCore.js"))
  (inline-brush)
  (inline-theme)
  (inline-js (slurp-resource "outliner.0.5.0.62.js"))
  (inline-css (slurp-resource "page.css"))

; file's rendering is wrapped in its own `article` tags.

  (each (partial render-file "article") paths)
  (inline-brushes)
  (javascript-setup))

; The output stream can be a file or standard output or anything
