help-gnu-emacs
[Top][All Lists]
Advanced

[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 <daneNO@MORE.mk.SPAMtelcordia.com> 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 orgmode.org.

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.

   (with-temp-buffer
     (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)
         (htmlize-css-name-prefix
          org-export-htmlize-css-font-prefix)
         (htmlbuf (htmlize-region beg end)))
    (unwind-protect
        (with-current-buffer htmlbuf
          (buffer-substring
           (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]