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

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

htmlize: Command line interface to http://fly.srk.fer.hr/~hniksic/emacs/


From: Simon Josefsson
Subject: htmlize: Command line interface to http://fly.srk.fer.hr/~hniksic/emacs/htmlize.el
Date: Fri, 09 Jul 2004 14:57:44 +0200
User-agent: Gnus/5.110003 (No Gnus v0.3) Emacs/21.3.50 (gnu/linux)

Not really Lisp code, but I found htmlize.el so useful that I wanted
to make it into a standalone tool, and thought I'd share my script
with you.  If someone knows how to use htmlize (really font locking)
without starting a X11 Emacs window, please let me know.  (If I use
--batch, the output just become black because the display engine
presumably optimize away all font locking.)

#!/bin/sh

# Copyright (C) 2004 Simon Josefsson.
#
# This file is part of Autobuild.
#
# Autobuild is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
#
# Autobuild is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Autobuild; see the file COPYING.  If not, write to the
# Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
# MA 02111-1307, USA.

prog="`basename \"$0\"`"
rcs_revision='$Revision: 1.7 $'
rcs_version=`set - $rcs_revision; echo $2`
program=`echo $0 | sed -e 's!.*/!!'`
version="htmlize (autobuild) $rcs_version

Copyright (C) 2004 Simon Josefsson
There is NO warranty.  You may redistribute this software
under the terms of the GNU General Public License.
For more information about these matters, see the files named COPYING."

usage="Usage: $prog [OPTION]... INFILE [OUTFILE [EMACS-MODE]]

Launch GNU Emacs, loading INFILE into a buffer, then invoke EMACS-MODE
followed by htmlize.el on the buffer, saving the output into OUTFILE.

If OUTFILE is not specified, it will use INFILE appended with .html.

If EMACS-MODE is not specified, compilation-mode will be used.

Options:
  --help      display this help and exit successfully.
  --version   display version information and exit successfully.

Simple example: $prog mybuildlog.txt mybuildlog.html

Report bugs to <address@hidden>."

while test $# -gt 0; do
  case $1 in
    --help) echo "$usage"; exit 0;;
    --version) echo "$version"; exit 0;;
    -*)
      echo "$0: Unknown or ambiguous option \`$1'." >&2
      echo "$0: Try \`--help' for more information." >&2
      exit 1;;
    *)
      if test -z "$INFILE"; then
        INFILE=$1
      elif test -z "$OUTFILE"; then
        OUTFILE=$1
      elif test -z "$EMACSMODE"; then
        EMACSMODE=$1
      else
        echo "$0: extra non-option argument \`$1'." >&2
        exit 1
      fi;;
  esac
  shift
done

if test -z "$INFILE"; then
    echo "$usage"
    exit 0
fi

OUTFILE=${OUTFILE:-$INFILE.html}
EMACSMODE=${EMACSMODE:-compilation-mode}

emacs --geometry 0x0+1600+1200 --eval "(let ((coding-system-for-write 'binary) 
(htmlize-before-hook (lambda () ($EMACSMODE) (font-lock-fontify-buffer)))) 
(htmlize-file \"$INFILE\" \"$OUTFILE\") (kill-emacs))"


reply via email to

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