Created
October 18, 2013 18:19
-
-
Save woxtu/7045816 to your computer and use it in GitHub Desktop.
Convert image to Data URI in Rouge.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ;; Rouge 0.0.14 | |
| (require "base64") | |
| (require "mime/types") | |
| (let [filename (nth ARGV 0)] | |
| (let [data-type (-> filename MIME.Types/of first) | |
| data-str (-> filename Kernel/open .read Base64/encode64)] | |
| (.write (Kernel/open (str (File/basename filename) ".html") "wb") | |
| (str "<!DOCTYPE html>\n" "<img src=\"data:" data-type ";base64," data-str "\" />")))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment