all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* htmlize from shell
@ 2004-06-22 21:08 Lowell Kirsh
  2004-06-22 23:01 ` Kevin Rodgers
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: Lowell Kirsh @ 2004-06-22 21:08 UTC (permalink / raw)


I would like to convert several files to html using the htmlize package. 
How can I do this from my shell rather than from withing emacs? (I want 
to script it)

Thanks,
Lowell

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: htmlize from shell
  2004-06-22 21:08 htmlize from shell Lowell Kirsh
@ 2004-06-22 23:01 ` Kevin Rodgers
  2004-06-22 23:53   ` Lowell Kirsh
  2004-06-22 23:38 ` Glenn Morris
  2004-06-22 23:55 ` Michael Slass
  2 siblings, 1 reply; 8+ messages in thread
From: Kevin Rodgers @ 2004-06-22 23:01 UTC (permalink / raw)


Lowell Kirsh wrote:
 > I would like to convert several files to html using the htmlize package.
 > How can I do this from my shell rather than from withing emacs? (I want
 > to script it)

I would try this:

for file in *; do
   emacs --batch --eval "(htmlize-file \"$file\")"
done

-- 
Kevin Rodgers

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: htmlize from shell
  2004-06-22 21:08 htmlize from shell Lowell Kirsh
  2004-06-22 23:01 ` Kevin Rodgers
@ 2004-06-22 23:38 ` Glenn Morris
  2004-06-22 23:55 ` Michael Slass
  2 siblings, 0 replies; 8+ messages in thread
From: Glenn Morris @ 2004-06-22 23:38 UTC (permalink / raw)


Lowell Kirsh wrote:

> I would like to convert several files to html using the htmlize
> package. How can I do this from my shell rather than from withing
> emacs? (I want to script it)

Unfortunately, I don't think you can. htmlize requires the Emacs
font-locking machinery, and this is not active in batch mode.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: htmlize from shell
  2004-06-22 23:01 ` Kevin Rodgers
@ 2004-06-22 23:53   ` Lowell Kirsh
  0 siblings, 0 replies; 8+ messages in thread
From: Lowell Kirsh @ 2004-06-22 23:53 UTC (permalink / raw)


Thanks, we're almost there... I'm still having problems. emacs doesn't 
seem to recognize htmlize. I have a line to load it in my .emacs file 
but maybe that's not getting loaded? Also, when I try :

emacs --batch --eval "(progn(load 
\"~/emacs/addons/htmlize\")(htmlize-file \"emacs.el\"))"

this doesn't work either. What am I missing?

Lowell

Kevin Rodgers wrote:
> Lowell Kirsh wrote:
>  > I would like to convert several files to html using the htmlize package.
>  > How can I do this from my shell rather than from withing emacs? (I want
>  > to script it)
> 
> I would try this:
> 
> for file in *; do
>   emacs --batch --eval "(htmlize-file \"$file\")"
> done
> 

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: htmlize from shell
  2004-06-22 21:08 htmlize from shell Lowell Kirsh
  2004-06-22 23:01 ` Kevin Rodgers
  2004-06-22 23:38 ` Glenn Morris
@ 2004-06-22 23:55 ` Michael Slass
  2004-06-23 18:53   ` nick
  2 siblings, 1 reply; 8+ messages in thread
From: Michael Slass @ 2004-06-22 23:55 UTC (permalink / raw)


Lowell Kirsh <lkirsh@cs.ubc.ca> writes:

>I would like to convert several files to html using the htmlize
>package. How can I do this from my shell rather than from withing
>emacs? (I want to script it)
>
>Thanks,
>Lowell


emacs --eval='
(progn
  (load-library "htmlize")
  (htmlize-file "/path/to/some/file"))
' --kill

This will do one file.



emacs --eval='
(progn
  (load-library "htmlize")
  (htmlize-many-files
  '("/path/to/some/file" "path/to/some/otherfile")))
' --kill

This will do more than one.


-- 
Mike Slass

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: htmlize from shell
  2004-06-22 23:55 ` Michael Slass
@ 2004-06-23 18:53   ` nick
  2004-06-23 19:23     ` Michael Slass
  2004-06-23 20:26     ` Johan Bockgård
  0 siblings, 2 replies; 8+ messages in thread
From: nick @ 2004-06-23 18:53 UTC (permalink / raw)


Michael Slass <miknrene@drizzle.com> writes:

> Lowell Kirsh <lkirsh@cs.ubc.ca> writes:
>
>>I would like to convert several files to html using the htmlize
>>package. How can I do this from my shell rather than from withing
>>emacs? (I want to script it)
>>
> ...
> emacs --eval='
> (progn
>   (load-library "htmlize")
>   (htmlize-many-files
>   '("/path/to/some/file" "path/to/some/otherfile")))
> ' --kill
>
> This will do more than one.

... except for the quotes. Either use

    (list "/path/to/some/file" "/path/to/some/otherfile" ...)

or 
    (quote ("/path/to/some/file" "/path/to/some/otherfile" ...))

in place of

   '("/path/to/some/file" "path/to/some/otherfile" ...)

A feature of the htmlize-file or htmlize-many-file function is that it
writes the html file in the same directory as the original. You might
want to use the optional third argument of htmlize-many-files to put
the results in a single directory.

You also get the annoying pop-up and pop-down of an emacs window, but,
as Glenn Morris mentioned, --batch does not seem to work (even if you
load and enable font-lock-mode). I get:

emacs -q --no-site-file --batch \
      --eval='(progn (load-library "font-lock")
                     (load-library "htmlize")
                     (htmlize-many-files  (list "/home/nick/tmp/297.txt" )))'
Loading font-lock...
Loading htmlize (source)...
Fontifying  *temp*...
Fontifying  *temp*... (syntactically...)
Wrong type argument: stringp, unspecified

Using --load instead, I tried 

      emacs -q --no-site-file --batch --load htmlit.el

with htmlit.el containing the following:

     (setq debug-on-error t)
     (load-library "font-lock")
     (load-library "htmlize")
     (font-lock-mode t)
     (htmlize-many-files  (list "/home/nick/tmp/297.txt" ))

I get the following backtrace:

Loading font-lock...
Loading htmlize (source)...
Fontifying  *temp*...
Fontifying  *temp*... (syntactically...)
...
  htmlize-face-to-fstruct(default)
  (if (symbolp face) (htmlize-face-to-fstruct face) (htmlize-attrlist-to-fstruct face))
  (let ((fstruct ...)) (setf (gethash face face-map) fstruct) (let* (... ... ...) (while ... ...) (unless ... ...) (push new-name css-names)))
  (if (gethash face face-map) nil (let (...) (setf ... fstruct) (let* ... ... ... ...)))
  (unless (gethash face face-map) (let (...) (setf ... fstruct) (let* ... ... ... ...)))
  (while --dolist-temp--98809 (setq face (car --dolist-temp--98809)) (unless (gethash face face-map) (let ... ... ...)) (setq --dolist-temp--98809 (cdr --dolist-temp--98809)))
  (let ((--dolist-temp--98809 faces) face) (while --dolist-temp--98809 (setq face ...) (unless ... ...) (setq --dolist-temp--98809 ...)) nil)
  (catch (quote --cl-block-nil--) (let (... face) (while --dolist-temp--98809 ... ... ...) nil))
  (cl-block-wrapper (catch (quote --cl-block-nil--) (let ... ... nil)))
  (block nil (let (... face) (while --dolist-temp--98809 ... ... ...) nil))
  (dolist (face faces) (unless (gethash face face-map) (let ... ... ...)))
  (let ((face-map ...) css-names) (dolist (face faces) (unless ... ...)) face-map)
  htmlize-make-face-map((default))
  (let* ((buffer-faces ...) (face-map ...) (htmlbuf ...) (title ...)) (with-current-buffer htmlbuf (buffer-disable-undo) (insert ... 10 ... "<html>\n  <head>\n" "    <title>" ... "</title>\n" ... htmlize-head-tags) (htmlize-method insert-head buffer-faces face-map) (insert "  </head>" "\n  " ... "\n    <pre>\n")) (let (... next-change text face-list fstruct-list) (goto-char ...) (while ... ... ... ... ... ... ... ...)) (with-current-buffer htmlbuf (insert "</pre>\n  </body>\n</html>\n") (when htmlize-generate-hyperlinks ...) (goto-char ...) (when htmlize-html-major-mode ...) (run-hooks ...) (buffer-enable-undo)) htmlbuf)
  (save-excursion (save-excursion (run-hooks ...)) (htmlize-ensure-fontified) (clrhash htmlize-extended-character-cache) (let* (... ... ... ...) (with-current-buffer htmlbuf ... ... ... ...) (let ... ... ...) (with-current-buffer htmlbuf ... ... ... ... ... ...) htmlbuf))
  htmlize-buffer-1()
  (set-buffer (htmlize-buffer-1))
  (save-current-buffer (set-buffer (htmlize-buffer-1)) (unwind-protect (progn ... ...) (kill-buffer ...)))
  (with-current-buffer (htmlize-buffer-1) (unwind-protect (progn ... ...) (kill-buffer ...)))
  (let ((buffer-file-name file)) (normal-mode) (font-lock-mode 1) (unless font-lock-mode (font-lock-fontify-buffer)) (with-current-buffer (htmlize-buffer-1) (unwind-protect ... ...)))
  (save-current-buffer (set-buffer temp-buffer) (insert-file-contents file) (let (...) (normal-mode) (font-lock-mode 1) (unless font-lock-mode ...) (with-current-buffer ... ...)))
  (with-current-buffer temp-buffer (insert-file-contents file) (let (...) (normal-mode) (font-lock-mode 1) (unless font-lock-mode ...) (with-current-buffer ... ...)))
  (unwind-protect (with-current-buffer temp-buffer (insert-file-contents file) (let ... ... ... ... ...)) (and (buffer-name temp-buffer) (kill-buffer temp-buffer)))
  (let ((temp-buffer ...)) (unwind-protect (with-current-buffer temp-buffer ... ...) (and ... ...)))
  (with-temp-buffer (insert-file-contents file) (let (...) (normal-mode) (font-lock-mode 1) (unless font-lock-mode ...) (with-current-buffer ... ...)))
  (let ((output-file ...) (font-lock-mode nil) (font-lock-auto-fontify nil) (global-font-lock-mode nil) (font-lock-maximum-size nil) (font-lock-support-mode nil)) (with-temp-buffer (insert-file-contents file) (let ... ... ... ... ...)))
  htmlize-file("/home/nick/tmp/297.txt" nil)
  (while --dolist-temp--98807 (setq file (car --dolist-temp--98807)) (htmlize-file file target-directory) (setq --dolist-temp--98807 (cdr --dolist-temp--98807)))
  (let ((--dolist-temp--98807 files) file) (while --dolist-temp--98807 (setq file ...) (htmlize-file file target-directory) (setq --dolist-temp--98807 ...)) nil)
  (catch (quote --cl-block-nil--) (let (... file) (while --dolist-temp--98807 ... ... ...) nil))
  (cl-block-wrapper (catch (quote --cl-block-nil--) (let ... ... nil)))
  (block nil (let (... file) (while --dolist-temp--98807 ... ... ...) nil))
  (dolist (file files) (htmlize-file file target-directory))
  htmlize-many-files(("/home/nick/tmp/297.txt"))
  eval-buffer(#<buffer  *load*> nil "/home/nick/tmp/htmlit.el" nil t)
  load-with-code-conversion("/home/nick/tmp/htmlit.el" "/home/nick/tmp/htmlit.el" nil t)
  load("/home/nick/tmp/htmlit.el" nil t)
  command-line-1(("--load" "htmlit.el"))
  command-line()
  normal-top-level()

but I have not chased it any further.

-- 
nick  (nicholas dot dokos at hp dot com)

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: htmlize from shell
  2004-06-23 18:53   ` nick
@ 2004-06-23 19:23     ` Michael Slass
  2004-06-23 20:26     ` Johan Bockgård
  1 sibling, 0 replies; 8+ messages in thread
From: Michael Slass @ 2004-06-23 19:23 UTC (permalink / raw)


nick <nobody@nowhere.non> writes:

>
>... except for the quotes. Either use

Oh, crud.  You're right.
-- 
Mike Slass

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: htmlize from shell
  2004-06-23 18:53   ` nick
  2004-06-23 19:23     ` Michael Slass
@ 2004-06-23 20:26     ` Johan Bockgård
  1 sibling, 0 replies; 8+ messages in thread
From: Johan Bockgård @ 2004-06-23 20:26 UTC (permalink / raw)


nick <nobody@nowhere.non> writes:

> Using --load instead, I tried 
>
>       emacs -q --no-site-file --batch --load htmlit.el
>
> with htmlit.el containing the following:
>
>      (setq debug-on-error t)
>      (load-library "font-lock")
>      (load-library "htmlize")
>      (font-lock-mode t)
>      (htmlize-many-files  (list "/home/nick/tmp/297.txt" ))
>
> I get the following backtrace: [...]

You can use something like this:

-------- my-htmlize.el ----------------------------------
;; USAGE:
;;     emacs -batch -l my-htmlize.el <file> 

;; Note: Writes to stdout

;; Explicitly set the faces. 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)))
---------------------------------------------------------

You could easily adapt this to htmlize several files etc.

-- 
Johan Bockgård

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2004-06-23 20:26 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-06-22 21:08 htmlize from shell Lowell Kirsh
2004-06-22 23:01 ` Kevin Rodgers
2004-06-22 23:53   ` Lowell Kirsh
2004-06-22 23:38 ` Glenn Morris
2004-06-22 23:55 ` Michael Slass
2004-06-23 18:53   ` nick
2004-06-23 19:23     ` Michael Slass
2004-06-23 20:26     ` Johan Bockgård

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.