[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: colored fonts in batch mode

From: Carsten Dominik
Subject: Re: colored fonts in batch mode
Date: Fri, 09 May 2008 15:45:15 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.50 (darwin)

Dan Espen <address@hidden> writes:

> I'm more familiar with XEmacs than emacs, but I think
> the concept applies.
> Rather using batch invocation wouldn't using the emacs
> equivalent of "gnudoit" be a solution?
> (gnudoit sends lisp commands to a running XEmacs.)

No, I don't think that would help.  This is an emacs progress on a
webserver that is updating our pages at

OK, here is what I ended up doing:

- I created a CSS file that contains many emacs face definitions.  I
  grabbed these definitions during an interactive Emacs session, by
  creating a buffer that contained one letter with each available Emacs
  face.  Then I applied htmlize-region to this buffer, and copied the
  class definitions from the css file.  Pretty long list, but ok, I can
  clean it up if I need to.

     (let ((fl (face-list))
        (htmlize-css-name-prefix "org-")
        (htmlize-output-type 'css)
        f i)
       (while (setq f (pop fl)
                 i (and f (face-attribute f :inherit)))
         (when (and (symbolp f) (or (not i) (not (listp i))))
        (insert (org-add-props (copy-sequence "1") nil 'face f))))
       (htmlize-region (point-min) (point-max))))
   (switch-to-buffer "*html*")

- The batch process now runs htmlize not with inline-css as its method,
  but the css.  I can do this in any display, and even in batch mode,
  font-lock will still assign the correct face names to keywords in the
  buffer, and htmlize will pick up those font names rather than the
  display dependent specifications.

(defun org-export-htmlize-region-for-paste (beg end)
  "Convert the region to HTML, using htmlize.el.
This is much like `htmlize-region-for-paste', only that it uses
the settings define in the org-... variables."
  (let* ((htmlize-output-type 'css)
         (htmlbuf (htmlize-region beg end)))
        (with-current-buffer htmlbuf
           (plist-get htmlize-buffer-places 'content-start)
           (plist-get htmlize-buffer-places 'content-end)))
      (kill-buffer htmlbuf))))

- Now I can publish pages with source code with classes on all keywords,
  and because of the css file I have control over how things get
  displayed.  Pretty happy with that!

Thanks to everyone who replied, I did try a couple of the ideas, but in
the end the dependence in the current display is too deeply engraved in
the emacs internals, so this system is not easy to fool in a stable way.

- Carsten

reply via email to

[Prev in Thread] Current Thread [Next in Thread]