       (do (println usage banner)
         (System/exit 1))
       (binding [*single-comment* (:comment amap)
-                *brush* (:brush amap)
                 *theme* (:theme amap)
                 *language* (or (:language amap) *language*)
                 *stylesheet* (:stylesheet amap)]
+        (swap! brushes #(or (set (:brush amap)) %))
 
 ; When no output file is given, the program renders to standard-out.
 


(defn- gather-lines- [lines]
  (lazy-seq
    (let [classfn (first (first lines))
          [same tail] (if (#{:comment :code} classfn)
                        (split-with #(= classfn (first %)) lines)
                        (split-at 1 lines))
          text (string/join "\n" (map second same))]
      (when classfn (cons [classfn text] (gather-lines- tail))))))

(defn- gather-lines [lines]
  (gather-lines- (map classify-line lines)))

; The result of gathering is a list of pairs of the form
; `[<classification> <string>]`.

; ## Rendering
;


(defn slurp-resource
  "Get the complete contents of a Java resource."
  [resource-name & continue-on-failure?]
  (try
    (-> (.getContextClassLoader (Thread/currentThread))
      (.getResourceAsStream resource-name)
      (java.io.InputStreamReader.)
      (slurp))
    (catch Exception e
      (message "failed to read resource " resource-name)
      (if continue-on-failure?
        (message "    continuing anyway...")
        (do (message "    aborting...")
          (throw e))))))

(defn slurp-file|resource
  "Get the contents of the file at path, or failing that, the contents of a
  Java resource."
  [path & continue-on-failure?]
  (try (slurp path)
    (catch java.io.FileNotFoundException _
      (message path " not found; reading as a resource instead")
      (slurp-resource path continue-on-failure?))))

(defn encode-anchor [s]
  (java.net.URLEncoder/encode (.replace s " " "-") "UTF-8"))
