Emacs htmlize in batch mode?

后端 未结 5 580
栀梦
栀梦 2021-02-06 08:50

I like to use htmlize-file in emacs to turn clojure source files into html.

I want to use it from the linux command line instead, or programmatically from clojure itself

5条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-02-06 09:42

    There is a example to use htmlize in --batch mode

    http://sebastien.kirche.free.fr/emacs_stuff/elisp/my-htmlize.el

    ;; Make sure the the htmlize library is in load-path.
    ;; You might want to load ~/.emacs
    
    ;; USAGE:
    ;;     emacs -batch -l my-htmlize.el INFILE > OUTFILE
    
    
    ;; Example:
    (custom-set-faces 
     '(default                      ((t (:foreground "#ffffff" :background "black"))))
     '(font-lock-builtin-face       ((t (:foreground "#ff0000"))))
     '(font-lock-comment-face       ((t (:bold t :foreground "#333300"))))
     '(font-lock-constant-face      ((t (:foreground "magenta"))))
     '(font-lock-function-name-face ((t (:bold t :foreground "Blue"))))
     '(font-lock-keyword-face       ((t (:foreground "yellow3"))))
     '(font-lock-string-face        ((t (:foreground "light blue"))))
     '(font-lock-type-face      ((t (:foreground "green"))))
     '(font-lock-variable-name-face ((t (:foreground "cyan" :bold t))))
     '(font-lock-warning-face       ((t (:foreground "red" :weight bold)))))
    
    (setq htmlize-use-rgb-map 'force)
    (require 'htmlize)
    
    (find-file (pop command-line-args-left))
    (font-lock-fontify-buffer)
    (with-current-buffer (htmlize-buffer)
      (princ (buffer-string)))
    

提交回复
热议问题