all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Rendering buffer to HTML from command line script
@ 2016-02-20 17:20 Stéphane Travostino
  2016-08-05 19:10 ` Thien-Thi Nguyen
  0 siblings, 1 reply; 3+ messages in thread
From: Stéphane Travostino @ 2016-02-20 17:20 UTC (permalink / raw)
  To: help-gnu-emacs

Hello,

I'm trying to create a command line Emacs script that, by specifying a file
and a theme, renders the file to HTML using the theme colours.
For example:

emacs --script render-theme.el some-theme.el test.c > test.c.html

I'm using htmlfontify to render the buffer to HTML, and works great when
called from X, but I get a black and white output when called from the
terminal _with most themes_.

The problem is that themes specify the minimum terminal requirements to
enable a specific face, i.e. minimum amount of colours supported by the
terminal, window-system, etc. (
http://www.gnu.org/software/emacs/manual/html_node/elisp/Defining-Faces.html
)

For example: (defface 'foo (((min-colors 88) (class color) etc.))

If I modify the theme to disable these terminal requirements options,
htmlfontify renders correctly.

That's probably a long shot, but is it possible to either force a
particular terminal configuration from command line, or force-enable all
theme faces?

For example, (display-color-cells) in X returns 16777216, while I get 0
when executed from the script; that's probably part of the problem.

Why am I doing this: I want to create an Emacs theme browser web
application which creates a preview of any theme against a few different
file formats, and I want an headless Emacs to create the HTML preview.

Thanks.
Stephane.


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

* Re: Rendering buffer to HTML from command line script
       [not found] <mailman.5246.1456006059.843.help-gnu-emacs@gnu.org>
@ 2016-02-24 20:41 ` Gene
  0 siblings, 0 replies; 3+ messages in thread
From: Gene @ 2016-02-24 20:41 UTC (permalink / raw)
  To: help-gnu-emacs

On Saturday, February 20, 2016 at 5:07:43 PM UTC-5, Stéphane Travostino wrote:

> If I modify the theme to disable these terminal requirements options,
> htmlfontify renders correctly.
> 
> That's probably a long shot, but is it possible to either force a
> particular terminal configuration from command line, or force-enable all
> theme faces?

I found the following in the docs for a package named faces+

 (eval-after-load "faces" '(require 'faces+))


> For example, (display-color-cells) in X returns 16777216, while I get 0
> when executed from the script; that's probably part of the problem.
> 
> Why am I doing this: I want to create an Emacs theme browser web
> application which creates a preview of any theme against a few different
> file formats

> I want an headless Emacs to create the HTML preview.

You might want to consider invoking emacs-nox (EG emacs with No x-windows support) as you mentioned `headless' emacs.
To speed things up you might want to consider using the --quick option.

I know this might be more general than you'd like, but it's all that comes to mind at the moment.

Cheers!
  Gene


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

* Re: Rendering buffer to HTML from command line script
  2016-02-20 17:20 Rendering buffer to HTML from command line script Stéphane Travostino
@ 2016-08-05 19:10 ` Thien-Thi Nguyen
  0 siblings, 0 replies; 3+ messages in thread
From: Thien-Thi Nguyen @ 2016-08-05 19:10 UTC (permalink / raw)
  To: Stéphane Travostino; +Cc: help-gnu-emacs

[-- Attachment #1: Type: text/plain, Size: 1806 bytes --]

() Stéphane Travostino <stephane.travostino@gmail.com>
() Sat, 20 Feb 2016 17:20:29 +0000

   For example: (defface 'foo (((min-colors 88) (class color) etc.))

   If I modify the theme to disable these terminal requirements
   options, htmlfontify renders correctly.

Did you try to set a terminal that has fulfills those
requirements?  You can use ‘toe -a’:

 $ toe -a
 dumb            80-column dumb tty
 pcansi          ibm-pc terminal programs claiming to be ansi
 ansi            ansi/pc-term compatible with color
 rxvt-unicode    rxvt-unicode terminal (X Window System)
 rxvt            rxvt terminal emulator (X Window System)
 [...]

to find a name, such as ‘foo’ and then:

 $ TERM=foo emacs -q -Q --batch \
      -eval '(message "%s" (getenv "TERM"))'
 foo

The basic technique lies in the ‘TERM=foo’ portion of the
command, prior to the executable name (in this case, "emacs").
This sets the environment variable ‘TERM’ only for that process.
Maybe Emacs will consult the env var and DTRT for your
application.

Another (better) idea, from browsing ‘emacs --help’, is to use:

--color, --color=MODE     override color mode for character terminals;
                            MODE defaults to `auto', and
                            can also be `never', `always',
                            or a mode name like `ansi8'

which, being explicitly documented as character terminal
support, should have a higher probability of success.

-- 
Thien-Thi Nguyen -----------------------------------------------
  (if you're human and you know it) read my lisp:
    (defun responsep (type via)
      (case type
        (technical (eq 'mailing-list via))
        ...))
---------------------------------------------- GPG key: 4C807502

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 197 bytes --]

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

end of thread, other threads:[~2016-08-05 19:10 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-02-20 17:20 Rendering buffer to HTML from command line script Stéphane Travostino
2016-08-05 19:10 ` Thien-Thi Nguyen
     [not found] <mailman.5246.1456006059.843.help-gnu-emacs@gnu.org>
2016-02-24 20:41 ` Gene

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.