   "Take a list of file paths and an output stream, and render each file to the
   stream as HTML."
   [in-paths out]
+  (when-let [d (and
+                 (or (string? out)
+                     (instance? java.io.File out))
+                 (fs/dirname out))]
+    (fs/mkdirs d))
   (with-out-stream out
     (render-files in-paths)))
 

                  :default false :flag true]
                 ["-h" "--help" "Show this help" :default false :flag true])]

    ;; For the brush, theme, and stylesheet options the program first tries to
    ;; read from the filesystem and if that fails because the file is not found
    ;; then an attempt is made to read from the program's resources. The
    ;; resources contain the standard SyntaxHighlighter brushes and themes
    ;; under their normal file names including an additional
    ;; `shBrushClojure.js` and `shThemeClojure.css`.
    ;;
    ;; Multiple brushes can be used by repeating the `-b` or `--brush` options.
    ;; Additional brushes may be added by the program as a result of file
    ;; includes and file suffixes.
    ;;
    ;; If present, the `-p` or `--production` option prevents documentation
    ;; generation, and instead writes a production tree to the supplied

    (if (or (not (seq tail)) (:help amap))
      (do (println (str usage "\n" banner))
        (System/exit 1))
      (if-let [dir (:production amap)]
        (write-production-tree tail dir)

        ;; When no output file is given, the program renders to standard-out.
        (if (= 1 (count tail))
          (apply story amap *out* tail)
          (apply story amap (last tail) (butlast tail)))))))
