Htmlfontify

This manual documents Htmlfontify, a source code -> crosslinked + formatted + syntax colorized html transformer.

Copyright © 2002–2024 Free Software Foundation, Inc.

Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.3 or any later version published by the Free Software Foundation; with no Invariant Sections, with the Front-Cover Texts being “A GNU Manual,” and with the Back-Cover Texts as in (a) below. A copy of the license is included in the section entitled “GNU Free Documentation License”.

(a) The FSF’s Back-Cover Text is: “You have the freedom to copy and modify this GNU manual.”

Table of Contents


1 Introduction

Htmlfontify provides a means of converting individual Emacs buffers, source files, or entire source trees to html, preserving formatting and Emacs colorization / syntax highlighting as much as possible through careful application of CSS stylesheets and html tags.

It can also turn instances of functions, methods and (for some languages) variables and other constructs and items into links to their definitions, and create an index file (or files) of all such symbols, also linked to their points of definition.

Htmlfontify also provides several customization items, which should allow it to mesh more-or-less seamlessly with various templating or publishing systems (in the event, for instance, that you don’t want to produce the html pages directly).


2 Usage & Examples

Htmlfontify can be used both interactively and as part of another elisp function. If you’re running it in a modern Emacs, it will also run when attached to a terminal (i.e., without X) or even when in batch mode.


2.1 Interactive

Htmlfontify provides the following interactive functions:

htmlfontify-buffer

(htmlfontify-buffer &optional srcdir file)

Create a new buffer, named for the current buffer + a .html extension, containing an inline CSS-stylesheet and formatted CSS-markup html that reproduces the look of the current Emacs buffer as closely as possible.

“Dangerous” characters in the existing buffer are turned into html entities, so you should even be able to do html-within-html fontified display.

You should, however, note that random control or non-ASCII characters such as ^L (U+000C FORM FEED (FF)) or ยค (U+00A4 CURRENCY SIGN) won’t get mapped yet.

If the srcdir and file arguments are set, lookup etags derived entries in the hfy-tags-cache and add html anchors and hyperlinks as appropriate.

htmlfontify-run-etags

(htmlfontify-run-etags srcdir)

Load the etags cache for srcdir. See hfy-load-tags-cache.


(htmlfontify-copy-and-link-dir srcdir dstdir &optional f-ext l-ext)

Trawl srcdir and write fontified-and-hyperlinked output in dstdir. f-ext and l-ext specify values for hfy-extn and hfy-link-extn.

You may also want to set hfy-page-header and hfy-page-footer.

htmlfontify-load-rgb-file

(htmlfontify-load-rgb-file &optional file)

Load an X11 style rgb.txt file (search hfy-rgb-load-path if file is not specified).

Note that this is not necessary if all you want is the standard X11 (XFree86 4.1.0) color name -> rgb triplet mapping. Htmlfontify has a copy built in, for use when it cannot contact an X server.

Loads the variable hfy-rgb-txt-color-map, which is used by hfy-fallback-color-values.

htmlfontify-unload-rgb-file

(htmlfontify-unload-rgb-file)

Unload the currently loaded X11 style rgb.txt file (if any).


2.2 Non-interactive

In addition to the aforementioned interactive methods, Htmlfontify provides the following non-interactive ones:

hfy-face-to-style

(hfy-face-to-style fn)

Take fn, a font or defface style font specification, (as returned by face-attr-construct or hfy-face-attr-for-class) and return a hfy-style-assoc.

See also: hfy-face-to-style-i, hfy-flatten-style.

hfy-fallback-color-values

(hfy-fallback-color-values color-string)

Use a fallback method for obtaining the rgb values for a color. If htmlfontify-load-rgb-file has been called, it uses the color map specified, otherwise it uses Htmlfontify’s built in map.

hfy-combined-face-spec

(hfy-combined-face-spec face)

Return a defface style alist of possible specifications for face, with any entries resulting from user customization (custom-set-faces) taking precedence.

See also: hfy-default-face-def

hfy-word-regex

(hfy-word-regex string)

Return a regex that matches string as the first match-string, with non word characters on either side (vaguely emulating the perl \b regex atom).

hfy-force-fontification

(hfy-force-fontification)

Emacs’s fontification is designed for interactive use. As such, it sometimes does things like deferring fontification until a section of the buffer is exposed and rendered, or until Emacs is idle for a while. Sometimes, in non-interactive circumstances, or if it can’t see X, it doesn’t bother with some of the harder stuff. While this is all great from the perspective of a user waiting for Emacs to load a 20000 line file and colorize it, it’s a pain from the point of view from non-interactive code. This function lies, cheats, steals and generally bullies Emacs into fontifying a buffer from start to finish, with all the extra frills, whether it thinks it needs to or not. Oh yes: it operates on the current buffer.


(hfy-link-style-string style-string)

Replace the end of a CSS style declaration style-string with the contents of the variable hfy-src-doc-link-style, removing text matching the regex hfy-src-doc-link-unstyle first, if necessary.

hfy-prepare-index-i

(hfy-prepare-index-i srcdir dstdir filename &optional stub map)

Prepare a tags index buffer for srcdir. hfy-tags-cache must already have an entry for srcdir for this to work. hfy-page-header, hfy-page-footer, hfy-link-extn and hfy-extn all play a part here.

If stub is set, prepare an (appropriately named) index buffer specifically for entries beginning with stub.

If map is set, use that instead of hfy-tags-cache.

hfy-compile-stylesheet

(hfy-compile-stylesheet)

Trawl the current buffer, construct and return a hfy-sheet-assoc.

hfy-css-name

(hfy-css-name fn)

Strip some of the boring bits from a font-name and return a CSS style name. If fn is a defface attribute list, either construct a name for it, store it in the cache, and return it, or just fetch it from the cache if it’s already there.

hfy-make-directory

(hfy-make-directory dir)

Approximate equivalent of mkdir -p dir.

hfy-triplet

(hfy-triplet color)

Takes a color name (string) and return a CSS rgb(R, G, B) triplet string. Uses the definition of “white” to map the numbers to the 0-255 range, so if you’ve redefined white, (especially if you’ve redefined it to have a triplet member lower than that of the color you are processing, strange things may happen).

hfy-default-footer

(hfy-default-footer file)

Default value for hfy-page-footer

hfy-list-files

(hfy-list-files directory)

Return a list of files under directory. Strips any leading ‘./’ from each filename.

hfy-color-vals

(hfy-color-vals color)

Where color is a color name or #XXXXXX style triplet, return a list of 3 (16 bit) rgb values for said color. If a window system is unavailable, calls hfy-fallback-color-values.

hfy-href-stub

(hfy-href-stub this-file def-files tag)

Return an href stub for a tag href: if def-files (list of files containing definitions for the tag in question) contains only one entry, the href should link straight to that file. Otherwise, the link should be to the index file.

We are not yet concerned with the file extensions/tag line number and so on at this point.

If hfy-split-index is set, and the href will be to an index file rather than a source file, append a ‘.X’ to hfy-index-file, where ‘X’ is the uppercased first character of tag.

See also: hfy-relstub, hfy-index-file.

hfy-line-number

(hfy-line-number)

Returns the line number of the point in the current buffer.

hfy-merge-adjacent-spans

(hfy-merge-adjacent-spans face-map)

Where face-map is a hfy-facemap-assoc for the current buffer, this function merges adjacent style blocks which are of the same value and are separated by nothing more interesting than whitespace.

<span class="foo">narf</span> <span class="foo">brain</span>

(as interpreted from face-map) would become:

<span class="foo">narf brain</span>

Returns a modified copy of face-map (also a hfy-facemap-assoc).

hfy-mark-tag-names

(hfy-mark-tag-names srcdir file)

Mark tags in file (lookup srcdir in hfy-tags-cache) with the hfy-anchor property, with a value of ‘tag.line-number’.

hfy-weight

(hfy-weight weight)

Derive a font-weight CSS specifier from an Emacs weight specification symbol.

hfy-size

(hfy-size height)

Derive a CSS font-size specifier from an Emacs font :height attribute. Does not cope with the case where height is a function to be applied to the height of the underlying font.

hfy-default-header

(hfy-default-header file style)

Default value for hfy-page-header

hfy-family

(hfy-family family)

Derives a CSS font-family specifier from an Emacs :family attribute.

hfy-mark-tag-hrefs

(hfy-mark-tag-hrefs srcdir file)

Mark href start points with the hfy-link property (value: href string).

Mark href end points with the hfy-endl property (value t).

Avoid overlapping links, and mark links in descending length of tag name in order to prevent subtags from usurping supertags; e.g., “term” for “terminal”).

hfy-box

(hfy-box box)

Derive CSS border-* attributes from the Emacs :box attribute.

hfy-box-to-style

(hfy-box-to-style spec)

Convert a complex :box Emacs font attribute set to a list of CSS border-* attributes. Don’t call this directly—it is called by hfy-box when necessary.

hfy-html-enkludge-buffer

(hfy-html-enkludge-buffer)

Mark dangerous ‘["<>]’ characters with the hfy-quoteme property.

See also hfy-html-dekludge-buffer.

hfy-buffer

(hfy-buffer)

Generate and return an Htmlfontify html output buffer for the current buffer. May trample an existing buffer.

hfy-fontified-p

(hfy-fontified-p)

font-lock doesn’t like to say a buffer’s been fontified when in batch mode, but we want to know if we should fontify or raw copy, so in batch mode we check for non-default face properties. Otherwise we test font-lock-mode and font-lock-fontified for truth.

hfy-lookup

(hfy-lookup face style)

Where style is a hfy-sheet-assoc and face is an Emacs face, return the relevant css style name.

hfy-fontify-buffer

(hfy-fontify-buffer &optional srcdir file)

Implement the guts of htmlfontify-buffer.

hfy-color

(hfy-color color)

Convert an Emacs :foreground property to a CSS color property.

hfy-flatten-style

(hfy-flatten-style style)

Take style (see hfy-face-to-style-i, see hfy-face-to-style) and merge any multiple attributes appropriately. Currently only font-size is merged down to a single occurrence—others may need special handling, but I haven’t encountered them yet. Returns a hfy-style-assoc.

hfy-size-to-int

(hfy-size-to-int spec)

Convert spec, a CSS font-size specifier, back to an Emacs :height attribute value. Used while merging multiple font-size attributes.

hfy-sprintf-stylesheet

(hfy-sprintf-stylesheet css file)

Generates a header, via hfy-page-header, for file, containing the stylesheet derived from css, which is a hfy-sheet-assoc. Returns a string containing the same.

hfy-relstub

(hfy-relstub file &optional start)

Return a ‘../’ stub of the appropriate length for the current source tree depth (as determined from file).

hfy-compile-face-map

(hfy-compile-face-map)

Compile and return a hfy-facemap-assoc for the current buffer.

hfy-prepare-index

(hfy-prepare-index srcdir dstdir)

Return as list of index buffer(s), as determined by hfy-split-index. Uses hfy-prepare-index-i to do this.

hfy-prepare-tag-map

(hfy-prepare-tag-map srcdir dstdir)

Prepare the counterpart(s) to the index buffer(s)—a list of buffers with the same structure, but listing (and linking to) instances of tags (as opposed to their definitions).

See also: hfy-prepare-index, hfy-split-index

hfy-subtract-maps

(hfy-subtract-maps srcdir)

Internal function—strips definitions of tags from the instance map. See: hfy-tags-cache and hfy-tags-rmap

hfy-face-to-style-i

(hfy-face-to-style-i fn)

The guts of hfy-face-to-style. fn should be a defface font specification, as returned by face-attr-construct or hfy-face-attr-for-class. Note that this function does not get font-sizes right if they are based on inherited modifiers (via the :inherit) attribute, and any other modifiers that are cumulative if they appear multiple times need to be merged by the user—hfy-flatten-style should do this.

hfy-face-to-css

(hfy-face-to-css fn)

Take fn, a font or defface specification (c.f. face-attr-construct) and return a CSS style specification.

See also: hfy-face-to-style

hfy-html-quote

(hfy-html-quote char-string)

Map a string (usually 1 character long) to an html safe string (entity) if need be.


(hfy-link-style style-string)

Convert the CSS style spec style-string to its equivalent hyperlink style.

See: hfy-link-style-fun.

hfy-p-to-face

(hfy-p-to-face props)

Given props, a list of text-properties, return the value of the face property, or nil.

hfy-box-to-border-assoc

(hfy-box-to-border-assoc spec)

Helper function for hfy-box-to-style.

hfy-face-attr-for-class

(hfy-face-attr-for-class face &optional class)

Return the face attributes for face. If class is set, it must be a defface alist key [see below]. Prior to version 0.18, the first face specification returned by hfy-combined-face-spec which didn’t clash with class was returned. In versions from 0.18 onwards, each font attribute list is scored, and the non-conflicting list with the highest score is returned. (A specification with a class of t is considered to match any class you specify. This matches Emacs’s behavior when deciding on which face attributes to use, to the best of my understanding ).

If class is nil, then you just get whatever face-attr-construct returns; i.e., the current specification in effect for face.

See hfy-display-class for details of valid values for class.

hfy-face-at

(hfy-face-at P)

Find face in effect at point P. If overlays are to be considered (see hfy-optimizations) then this may return a defface style list of face properties instead of a face symbol.

hfy-bgcol

(hfy-bgcol color)

As per hfy-color but for background colors.

hfy-kludge-cperl-mode

(hfy-kludge-cperl-mode)

cperl mode does its best to not do some of its fontification when not in a windowing system—we try to trick it…

hfy-href

(hfy-href this-file def-files tag tag-map)

Return a relative href to the tag in question, based on

this-file hfy-link-extn hfy-extn def-files tag and tag-map

this-file is the current source file def-files is a list of file containing possible link endpoints for tag tag is the tag in question tag-map is the entry in hfy-tags-cache.

hfy-shell

(hfy-shell)

Returns a best guess at a Bourne compatible shell to use: If the current shell doesn’t look promising, fall back to hfy-shell-file-name.

hfy-load-tags-cache

(hfy-load-tags-cache srcdir)

Run hfy-etags-cmd on srcdir: load hfy-tags-cache and hfy-tags-sortl.

hfy-parse-tags-buffer

(hfy-parse-tags-buffer srcdir buffer)

Parse a buffer containing etags formatted output, loading the hfy-tags-cache and hfy-tags-sortl entries for srcdir.

hfy-interq

(hfy-interq set-a set-b)

Return the intersection (using eq) of 2 lists.

hfy-text-p

(hfy-text-p srcdir file)

Is srcdir/file text? Uses hfy-istext-command to determine this.

hfy-opt

(hfy-opt symbol)

Is hfy-optimizations member symbol set or not?

hfy-dirname

(hfy-dirname file)

Return everything preceding the last ‘/’ from a relative filename, on the assumption that this will produce the name of a relative directory. Hardly bombproof, but good enough in the context in which it is being used.

hfy-html-dekludge-buffer

(hfy-html-dekludge-buffer)

Transform all dangerous characters marked with the hfy-quoteme property using hfy-html-quote

See also hfy-html-enkludge-buffer.

hfy-copy-and-fontify-file

(hfy-copy-and-fontify-file srcdir dstdir file)

Open file in srcdir—if fontified, write a fontified copy to dstdir adding an extension of hfy-extn. Fontification is actually done by htmlfontify-buffer. If the buffer is not fontified, just copy it.

hfy-decor

(hfy-decor tag val)

Derive CSS text-decoration specifiers from various Emacs font attributes.

hfy-slant

(hfy-slant slant)

Derive a font-style CSS specifier from the Emacs :slant attribute—CSS does not define the reverse-* styles, so just maps those to the regular specifiers.

hfy-tags-for-file

(hfy-tags-for-file srcdir file)

List of etags tags that have definitions in this file. Looks up the tags cache in hfy-tags-cache using srcdir as the key.

hfy-width

(hfy-width width)

Convert an Emacs :width attribute to a CSS font-stretch attribute.


2.3 Variables

Important variables that are not customization items:

hfy-tags-cache

This is an alist of the form:

(("/src/dir/0" . tag-hash0) ("/src/dir/1" tag-hash1) … )

Each tag hash entry then contains entries of the form:

"tag_string" => (("file/name.ext" line char) … )

i.e., an alist mapping (relative) file paths to line and character offsets.

See hfy-load-tags-cache.

hfy-tags-rmap

hfy-tags-rmap is an alist of the form:

(("/src/dir" . tag-rmap-hash))

Where tag-rmap-hash has entries of the form:

"tag_string" => ( "file/name.ext" line char )

Unlike hfy-tags-cache these are the locations of occurrences of tagged items, not the locations of their definitions.

hfy-tags-sortl

hfy-tags-sortl is an alist of the form:

(("/src/dir" . (tag0 tag1 tag2)) … )

Where the tags are stored in descending order of length.

See: hfy-load-tags-cache.


2.4 Data Structures

Some of the (informal) data structures used in Htmlfontify are detailed here:

hfy-style-assoc

An assoc representing/describing an Emacs face. Properties may be repeated, in which case later properties should be treated as if they were inherited from a “parent” font. (For some properties, only the first encountered value is of any importance, for others the values might be cumulative, and for others they might be cumulative in a complex way.)

Some examples:

(hfy-face-to-style 'default) =>

  (("background"      . "rgb(0, 0, 0)"      )
   ("color"           . "rgb(255, 255, 255)")
   ("font-style"      . "normal"            )
   ("font-weight"     . "500"               )
   ("font-stretch"    . "normal"            )
   ("font-family"     . "misc-fixed"        )
   ("font-size"       . "13pt"              )
   ("text-decoration" . "none"              ))

(hfy-face-to-style 'Info-title-3-face) =>

  (("font-weight"     . "700"        )
   ("font-family"     . "helv"       )
   ("font-size"       . "120%"       )
   ("text-decoration" . "none")      )
hfy-sheet-assoc

An assoc with elements of the form ‘(face-name style-name . style-string)’. The actual stylesheet for each page is derived from one of these.

((default       "default" . "{ background: black; color: white}")
 (font-lock-string-face "string"  . "{ color: rgb(64,224,208) }"))
hfy-facemap-assoc

An assoc of (point . face-symbol) or (point . defface attribute list) and (point . end) elements, in descending order of point value (i.e., from the file’s end to its beginning). The map is in reverse order because inserting a ‘<style>’ tag (or any other string) at point invalidates the map for all entries with a greater value of point. By traversing the map from greatest to least point, we still invalidate the map as we go, but only those points we have already dealt with (and therefore no longer care about) will be invalid at any time.

((64820 . end)
 (64744 . font-lock-comment-face)
 (64736 . end)
 (64722 . font-lock-string-face)
 (64630 . end)
 (64623 . font-lock-string-face)
 (64449 . end)
 ;; Big similar section elided.  You get the idea.
 (5459 . end)
 (5431 . (:inherit font-lock-keyword-face :background "7e7e7e"))
 (5431 . end)
 (4285 . font-lock-constant-face)
 (4285 . end)
 (4221 . font-lock-comment-face)
 (4221 . end)
 (4197 . font-lock-constant-face)
 (4197 . end)
 (1 . font-lock-comment-face))

2.5 Examples

The following is a lump of code I use to fontify source code on my site, http://rtfm.etla.org/ (which was the reason, incidentally, that Htmlfontify was written in the first place).

(defvar rtfm-section nil)

;; Constructs an appropriate header string to fit in with rtfm's
;; templating system, based on the file and the stylesheet string
(defun rtfm-build-page-header (file style)
  (format "#define  TEMPLATE red+black.html
#define  DEBUG    1
#include <build/menu-dirlist|>\n
html-css-url := /css/red+black.css
title        := rtfm.etla.org ( %s / src/%s )
bodytag      :=
head         <=STYLESHEET;\n
%s
STYLESHEET
main-title   := rtfm / %s / src/%s\n
main-content <=MAIN_CONTENT;\n" rtfm-section file style rtfm-section file))

;; the footer:
(defun rtfm-build-page-footer (file) "\nMAIN_CONTENT\n")

(defun rtfm-fontify-buffer (section)
  (interactive "s section[eg- emacs / p4-blame]: ")
  (require 'htmlfontify)
  (let ((hfy-page-header  'rtfm-build-page-header)
	(hfy-page-footer  'rtfm-build-page-footer)
	(rtfm-section                     section))
    (htmlfontify-buffer)
    )
  )

;; Here's the function I actually call---it asks me for a section label,
;; and source and destination directories, and then binds a couple of
;; customization variable in a let before calling htmlfontify:
(defun rtfm-build-source-docs (section srcdir destdir)
  (interactive
   "s section[eg- emacs / p4-blame]:\nD source-dir: \nD output-dir: ")
  (require 'htmlfontify)
  (hfy-load-tags-cache srcdir)
  (let ((hfy-page-header  'rtfm-build-page-header)
	(hfy-page-footer  'rtfm-build-page-footer)
	(rtfm-section                     section)
	(hfy-index-file                   "index")
	(auto-mode-alist (append auto-mode-alist
				 '(("dbi\\(shell\\|gtk\\)$" . cperl-mode)
				   ("\\.xpm$"               . c-mode    ))))
	)
    (htmlfontify-run-etags srcdir)
    (htmlfontify-copy-and-link-dir srcdir destdir ".src" ".html")))

3 Customization

Htmlfontify provides the following variable and customization entries:

Set this to a function, which will be called with one argument (a ‘{ foo: bar; …}’ CSS style-string)—it should return a copy of its argument, altered so as to make any changes you want made for text which is a hyperlink, in addition to being in the class to which that style would normally be applied.

hfy-html-quote-regex

Regex to match (with a single back-reference per match) strings in HTML which should be quoted with hfy-html-quote (and see hfy-html-quote-map) to make them safe.

hfy-page-footer

As hfy-page-header, but generates the output footer (and takes only 1 argument, the filename).

hfy-display-class

Display class to use to determine which display class to use when calculating a face’s attributes. This is useful when, for example, you are running Emacs on a tty or in batch mode, and want Htmlfontify to have access to the face spec you would use if you were connected to an X display.

Some valid class specification elements are:

  (class      color)
  (class      grayscale)
  (background dark)
  (background light)
  (type       x-toolkit)
  (type       tty)
  (type       motif)
  (type       lucid)

Multiple values for a tag may be combined, to indicate that any one or more of these values in the specification key constitutes a match. For example, ((class color grayscale) (type tty)) would match any of:

  ((class color))
  ((class grayscale))
  ((class color grayscale)))
  ((class color foo))
  ((type  tty))
  ((type  tty) (class color))
hfy-page-header

Function called with two arguments (the filename relative to the top level source directory being etagged and fontified), and a string containing the ‘<style>…</style>’ text to embed in the document—the string returned will be used as the header for the htmlfontified version of the source file.

See also: hfy-page-footer

String to add to the ‘<style> a’ variant of an Htmlfontify CSS class.

hfy-split-index

Whether or not to split the index hfy-index-file alphabetically on the first letter of each tag. Useful when the index would otherwise be large and take a long time to render or be difficult to navigate.

hfy-exclude-file-rules

Regular expressions to exclude files which shouldn’t be fontified.

hfy-extn

File extension used for output files.

hfy-default-face-def

Fallback defface specification for the face default, used when hfy-display-class has been set (the normal Htmlfontify way of extracting potentially non-current face information doesn’t necessarily work for default).

For example, I customize this to:

((t :background "black" :foreground "white" :family "misc-fixed"))
hfy-init-kludge-hook

List of functions to call when starting htmlfontify-buffer to do any kludging necessary to get highlighting modes to behave as you want, even when not running under a window system.

hfy-shell-file-name

Should be set to a Bourne compatible shell, which will be invoked for the more complex shell interactions needed by Htmlfontify. Currently this is only required/used when using GNU etags, see hfy-etags-cmd-alist for details.

hfy-optimizations

Optimizations to turn on. So far, the following have been implemented:

merge-adjacent-tags

If two (or more) span tags are adjacent, identical and separated by nothing more than whitespace, they will be merged into one span.

zap-comment-links

Suppress hyperlinking of tags found in comments.

zap-string-links

Suppress hyperlinking of tags found in strings.

div-wrapper

Add ‘<div class="default"> </div>’ tags around the fontified body. (Some people like this because they cut and paste the html into a page with different colors than the fontified code.)

keep-overlays

Preserve overlay highlighting (cf. ediff or goo-font-lock) as well as basic faces. Can result in extremely verbose highlighting if there are many overlays (as is the case with goo-font-lock).

And the following are planned but not yet available:

kill-context-leak

Suppress hyperlinking between files highlighted by different modes.

Note: like compiler optimizations, these optimize the output of the code, not the processing of the source itself, and are therefore likely to slow Htmlfontify down, at least a little. Except for skip-refontification, which can never slow you down, but may result in incomplete fontification.

Regex to remove from the ‘<style> a’ variant of an Htmlfontify CSS class.

File extension used for href links—useful where the Htmlfontify output files are going to be processed again, with a resulting change in file extension. If nil, then any code using this should fall back to hfy-extn.

hfy-istext-command

Command to run with the name of a file, to see whether it is a text file or not. The command should emit a string containing the word ‘text’ if the file is a text file, and a string not containing ‘text’ otherwise.

hfy-etags-cmd-alist

An alist of possible shell commands that will generate etags output that Htmlfontify can use. ‘%s’ will be replaced by hfy-etags-bin.

hfy-etags-bin

The location of the etags binary (we begin by assuming it’s in your path).

Note that if etags is not in your path, you will need to alter the shell commands in hfy-etags-cmd-alist.

[As of version 0.17, this requirement has been removed: it should all just work(tm).]

hfy-etags-cmd

An etags shell command to run in the source directory to generate a tags file for the whole source tree from there on down. The command should emit the etags output on standard output.

Two canned commands are provided—they drive Emacs’s etags and exuberant-ctags’s etags respectively.

hfy-etag-regex

Regex used to parse an etags entry: must have 3 subexps, corresponding, in order, to:

  1. The tag
  2. The line
  3. The character (point) at which the tag occurs
hfy-index-file

Name (sans extension) of the index file produced during fontification-and-hyperlinking.

hfy-instance-file

Name (sans extension) of the tag usage index file produced during fontification-and-hyperlinking.

hfy-html-quote-map

An alist of character -> entity mappings used to make the text html-safe.


4 Requirements

Htmlfontify has a couple of external requirements:


Appendix A GNU Free Documentation License

Version 1.3, 3 November 2008
Copyright © 2000, 2001, 2002, 2007, 2008 Free Software Foundation, Inc.
https://fsf.org/

Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
  1. PREAMBLE

    The purpose of this License is to make a manual, textbook, or other functional and useful document free in the sense of freedom: to assure everyone the effective freedom to copy and redistribute it, with or without modifying it, either commercially or noncommercially. Secondarily, this License preserves for the author and publisher a way to get credit for their work, while not being considered responsible for modifications made by others.

    This License is a kind of “copyleft”, which means that derivative works of the document must themselves be free in the same sense. It complements the GNU General Public License, which is a copyleft license designed for free software.

    We have designed this License in order to use it for manuals for free software, because free software needs free documentation: a free program should come with manuals providing the same freedoms that the software does. But this License is not limited to software manuals; it can be used for any textual work, regardless of subject matter or whether it is published as a printed book. We recommend this License principally for works whose purpose is instruction or reference.

  2. APPLICABILITY AND DEFINITIONS

    This License applies to any manual or other work, in any medium, that contains a notice placed by the copyright holder saying it can be distributed under the terms of this License. Such a notice grants a world-wide, royalty-free license, unlimited in duration, to use that work under the conditions stated herein. The “Document”, below, refers to any such manual or work. Any member of the public is a licensee, and is addressed as “you”. You accept the license if you copy, modify or distribute the work in a way requiring permission under copyright law.

    A “Modified Version” of the Document means any work containing the Document or a portion of it, either copied verbatim, or with modifications and/or translated into another language.

    A “Secondary Section” is a named appendix or a front-matter section of the Document that deals exclusively with the relationship of the publishers or authors of the Document to the Document’s overall subject (or to related matters) and contains nothing that could fall directly within that overall subject. (Thus, if the Document is in part a textbook of mathematics, a Secondary Section may not explain any mathematics.) The relationship could be a matter of historical connection with the subject or with related matters, or of legal, commercial, philosophical, ethical or political position regarding them.

    The “Invariant Sections” are certain Secondary Sections whose titles are designated, as being those of Invariant Sections, in the notice that says that the Document is released under this License. If a section does not fit the above definition of Secondary then it is not allowed to be designated as Invariant. The Document may contain zero Invariant Sections. If the Document does not identify any Invariant Sections then there are none.

    The “Cover Texts” are certain short passages of text that are listed, as Front-Cover Texts or Back-Cover Texts, in the notice that says that the Document is released under this License. A Front-Cover Text may be at most 5 words, and a Back-Cover Text may be at most 25 words.

    A “Transparent” copy of the Document means a machine-readable copy, represented in a format whose specification is available to the general public, that is suitable for revising the document straightforwardly with generic text editors or (for images composed of pixels) generic paint programs or (for drawings) some widely available drawing editor, and that is suitable for input to text formatters or for automatic translation to a variety of formats suitable for input to text formatters. A copy made in an otherwise Transparent file format whose markup, or absence of markup, has been arranged to thwart or discourage subsequent modification by readers is not Transparent. An image format is not Transparent if used for any substantial amount of text. A copy that is not “Transparent” is called “Opaque”.

    Examples of suitable formats for Transparent copies include plain ASCII without markup, Texinfo input format, LaTeX input format, SGML or XML using a publicly available DTD, and standard-conforming simple HTML, PostScript or PDF designed for human modification. Examples of transparent image formats include PNG, XCF and JPG. Opaque formats include proprietary formats that can be read and edited only by proprietary word processors, SGML or XML for which the DTD and/or processing tools are not generally available, and the machine-generated HTML, PostScript or PDF produced by some word processors for output purposes only.

    The “Title Page” means, for a printed book, the title page itself, plus such following pages as are needed to hold, legibly, the material this License requires to appear in the title page. For works in formats which do not have any title page as such, “Title Page” means the text near the most prominent appearance of the work’s title, preceding the beginning of the body of the text.

    The “publisher” means any person or entity that distributes copies of the Document to the public.

    A section “Entitled XYZ” means a named subunit of the Document whose title either is precisely XYZ or contains XYZ in parentheses following text that translates XYZ in another language. (Here XYZ stands for a specific section name mentioned below, such as “Acknowledgements”, “Dedications”, “Endorsements”, or “History”.) To “Preserve the Title” of such a section when you modify the Document means that it remains a section “Entitled XYZ” according to this definition.

    The Document may include Warranty Disclaimers next to the notice which states that this License applies to the Document. These Warranty Disclaimers are considered to be included by reference in this License, but only as regards disclaiming warranties: any other implication that these Warranty Disclaimers may have is void and has no effect on the meaning of this License.

  3. VERBATIM COPYING

    You may copy and distribute the Document in any medium, either commercially or noncommercially, provided that this License, the copyright notices, and the license notice saying this License applies to the Document are reproduced in all copies, and that you add no other conditions whatsoever to those of this License. You may not use technical measures to obstruct or control the reading or further copying of the copies you make or distribute. However, you may accept compensation in exchange for copies. If you distribute a large enough number of copies you must also follow the conditions in section 3.

    You may also lend copies, under the same conditions stated above, and you may publicly display copies.

  4. COPYING IN QUANTITY

    If you publish printed copies (or copies in media that commonly have printed covers) of the Document, numbering more than 100, and the Document’s license notice requires Cover Texts, you must enclose the copies in covers that carry, clearly and legibly, all these Cover Texts: Front-Cover Texts on the front cover, and Back-Cover Texts on the back cover. Both covers must also clearly and legibly identify you as the publisher of these copies. The front cover must present the full title with all words of the title equally prominent and visible. You may add other material on the covers in addition. Copying with changes limited to the covers, as long as they preserve the title of the Document and satisfy these conditions, can be treated as verbatim copying in other respects.

    If the required texts for either cover are too voluminous to fit legibly, you should put the first ones listed (as many as fit reasonably) on the actual cover, and continue the rest onto adjacent pages.

    If you publish or distribute Opaque copies of the Document numbering more than 100, you must either include a machine-readable Transparent copy along with each Opaque copy, or state in or with each Opaque copy a computer-network location from which the general network-using public has access to download using public-standard network protocols a complete Transparent copy of the Document, free of added material. If you use the latter option, you must take reasonably prudent steps, when you begin distribution of Opaque copies in quantity, to ensure that this Transparent copy will remain thus accessible at the stated location until at least one year after the last time you distribute an Opaque copy (directly or through your agents or retailers) of that edition to the public.

    It is requested, but not required, that you contact the authors of the Document well before redistributing any large number of copies, to give them a chance to provide you with an updated version of the Document.

  5. MODIFICATIONS

    You may copy and distribute a Modified Version of the Document under the conditions of sections 2 and 3 above, provided that you release the Modified Version under precisely this License, with the Modified Version filling the role of the Document, thus licensing distribution and modification of the Modified Version to whoever possesses a copy of it. In addition, you must do these things in the Modified Version:

    1. Use in the Title Page (and on the covers, if any) a title distinct from that of the Document, and from those of previous versions (which should, if there were any, be listed in the History section of the Document). You may use the same title as a previous version if the original publisher of that version gives permission.
    2. List on the Title Page, as authors, one or more persons or entities responsible for authorship of the modifications in the Modified Version, together with at least five of the principal authors of the Document (all of its principal authors, if it has fewer than five), unless they release you from this requirement.
    3. State on the Title page the name of the publisher of the Modified Version, as the publisher.
    4. Preserve all the copyright notices of the Document.
    5. Add an appropriate copyright notice for your modifications adjacent to the other copyright notices.
    6. Include, immediately after the copyright notices, a license notice giving the public permission to use the Modified Version under the terms of this License, in the form shown in the Addendum below.
    7. Preserve in that license notice the full lists of Invariant Sections and required Cover Texts given in the Document’s license notice.
    8. Include an unaltered copy of this License.
    9. Preserve the section Entitled “History”, Preserve its Title, and add to it an item stating at least the title, year, new authors, and publisher of the Modified Version as given on the Title Page. If there is no section Entitled “History” in the Document, create one stating the title, year, authors, and publisher of the Document as given on its Title Page, then add an item describing the Modified Version as stated in the previous sentence.
    10. Preserve the network location, if any, given in the Document for public access to a Transparent copy of the Document, and likewise the network locations given in the Document for previous versions it was based on. These may be placed in the “History” section. You may omit a network location for a work that was published at least four years before the Document itself, or if the original publisher of the version it refers to gives permission.
    11. For any section Entitled “Acknowledgements” or “Dedications”, Preserve the Title of the section, and preserve in the section all the substance and tone of each of the contributor acknowledgements and/or dedications given therein.
    12. Preserve all the Invariant Sections of the Document, unaltered in their text and in their titles. Section numbers or the equivalent are not considered part of the section titles.
    13. Delete any section Entitled “Endorsements”. Such a section may not be included in the Modified Version.
    14. Do not retitle any existing section to be Entitled “Endorsements” or to conflict in title with any Invariant Section.
    15. Preserve any Warranty Disclaimers.

    If the Modified Version includes new front-matter sections or appendices that qualify as Secondary Sections and contain no material copied from the Document, you may at your option designate some or all of these sections as invariant. To do this, add their titles to the list of Invariant Sections in the Modified Version’s license notice. These titles must be distinct from any other section titles.

    You may add a section Entitled “Endorsements”, provided it contains nothing but endorsements of your Modified Version by various parties—for example, statements of peer review or that the text has been approved by an organization as the authoritative definition of a standard.

    You may add a passage of up to five words as a Front-Cover Text, and a passage of up to 25 words as a Back-Cover Text, to the end of the list of Cover Texts in the Modified Version. Only one passage of Front-Cover Text and one of Back-Cover Text may be added by (or through arrangements made by) any one entity. If the Document already includes a cover text for the same cover, previously added by you or by arrangement made by the same entity you are acting on behalf of, you may not add another; but you may replace the old one, on explicit permission from the previous publisher that added the old one.

    The author(s) and publisher(s) of the Document do not by this License give permission to use their names for publicity for or to assert or imply endorsement of any Modified Version.

  6. COMBINING DOCUMENTS

    You may combine the Document with other documents released under this License, under the terms defined in section 4 above for modified versions, provided that you include in the combination all of the Invariant Sections of all of the original documents, unmodified, and list them all as Invariant Sections of your combined work in its license notice, and that you preserve all their Warranty Disclaimers.

    The combined work need only contain one copy of this License, and multiple identical Invariant Sections may be replaced with a single copy. If there are multiple Invariant Sections with the same name but different contents, make the title of each such section unique by adding at the end of it, in parentheses, the name of the original author or publisher of that section if known, or else a unique number. Make the same adjustment to the section titles in the list of Invariant Sections in the license notice of the combined work.

    In the combination, you must combine any sections Entitled “History” in the various original documents, forming one section Entitled “History”; likewise combine any sections Entitled “Acknowledgements”, and any sections Entitled “Dedications”. You must delete all sections Entitled “Endorsements.”

  7. COLLECTIONS OF DOCUMENTS

    You may make a collection consisting of the Document and other documents released under this License, and replace the individual copies of this License in the various documents with a single copy that is included in the collection, provided that you follow the rules of this License for verbatim copying of each of the documents in all other respects.

    You may extract a single document from such a collection, and distribute it individually under this License, provided you insert a copy of this License into the extracted document, and follow this License in all other respects regarding verbatim copying of that document.

  8. AGGREGATION WITH INDEPENDENT WORKS

    A compilation of the Document or its derivatives with other separate and independent documents or works, in or on a volume of a storage or distribution medium, is called an “aggregate” if the copyright resulting from the compilation is not used to limit the legal rights of the compilation’s users beyond what the individual works permit. When the Document is included in an aggregate, this License does not apply to the other works in the aggregate which are not themselves derivative works of the Document.

    If the Cover Text requirement of section 3 is applicable to these copies of the Document, then if the Document is less than one half of the entire aggregate, the Document’s Cover Texts may be placed on covers that bracket the Document within the aggregate, or the electronic equivalent of covers if the Document is in electronic form. Otherwise they must appear on printed covers that bracket the whole aggregate.

  9. TRANSLATION

    Translation is considered a kind of modification, so you may distribute translations of the Document under the terms of section 4. Replacing Invariant Sections with translations requires special permission from their copyright holders, but you may include translations of some or all Invariant Sections in addition to the original versions of these Invariant Sections. You may include a translation of this License, and all the license notices in the Document, and any Warranty Disclaimers, provided that you also include the original English version of this License and the original versions of those notices and disclaimers. In case of a disagreement between the translation and the original version of this License or a notice or disclaimer, the original version will prevail.

    If a section in the Document is Entitled “Acknowledgements”, “Dedications”, or “History”, the requirement (section 4) to Preserve its Title (section 1) will typically require changing the actual title.

  10. TERMINATION

    You may not copy, modify, sublicense, or distribute the Document except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense, or distribute it is void, and will automatically terminate your rights under this License.

    However, if you cease all violation of this License, then your license from a particular copyright holder is reinstated (a) provisionally, unless and until the copyright holder explicitly and finally terminates your license, and (b) permanently, if the copyright holder fails to notify you of the violation by some reasonable means prior to 60 days after the cessation.

    Moreover, your license from a particular copyright holder is reinstated permanently if the copyright holder notifies you of the violation by some reasonable means, this is the first time you have received notice of violation of this License (for any work) from that copyright holder, and you cure the violation prior to 30 days after your receipt of the notice.

    Termination of your rights under this section does not terminate the licenses of parties who have received copies or rights from you under this License. If your rights have been terminated and not permanently reinstated, receipt of a copy of some or all of the same material does not give you any rights to use it.

  11. FUTURE REVISIONS OF THIS LICENSE

    The Free Software Foundation may publish new, revised versions of the GNU Free Documentation License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. See https://www.gnu.org/licenses/.

    Each version of the License is given a distinguishing version number. If the Document specifies that a particular numbered version of this License “or any later version” applies to it, you have the option of following the terms and conditions either of that specified version or of any later version that has been published (not as a draft) by the Free Software Foundation. If the Document does not specify a version number of this License, you may choose any version ever published (not as a draft) by the Free Software Foundation. If the Document specifies that a proxy can decide which future versions of this License can be used, that proxy’s public statement of acceptance of a version permanently authorizes you to choose that version for the Document.

  12. RELICENSING

    “Massive Multiauthor Collaboration Site” (or “MMC Site”) means any World Wide Web server that publishes copyrightable works and also provides prominent facilities for anybody to edit those works. A public wiki that anybody can edit is an example of such a server. A “Massive Multiauthor Collaboration” (or “MMC”) contained in the site means any set of copyrightable works thus published on the MMC site.

    “CC-BY-SA” means the Creative Commons Attribution-Share Alike 3.0 license published by Creative Commons Corporation, a not-for-profit corporation with a principal place of business in San Francisco, California, as well as future copyleft versions of that license published by that same organization.

    “Incorporate” means to publish or republish a Document, in whole or in part, as part of another Document.

    An MMC is “eligible for relicensing” if it is licensed under this License, and if all works that were first published under this License somewhere other than this MMC, and subsequently incorporated in whole or in part into the MMC, (1) had no cover texts or invariant sections, and (2) were thus incorporated prior to November 1, 2008.

    The operator of an MMC Site may republish an MMC contained in the site under CC-BY-SA on the same site at any time before August 1, 2009, provided the MMC is eligible for relicensing.

ADDENDUM: How to use this License for your documents

To use this License in a document you have written, include a copy of the License in the document and put the following copyright and license notices just after the title page:

  Copyright (C)  year  your name.
  Permission is granted to copy, distribute and/or modify this document
  under the terms of the GNU Free Documentation License, Version 1.3
  or any later version published by the Free Software Foundation;
  with no Invariant Sections, no Front-Cover Texts, and no Back-Cover
  Texts.  A copy of the license is included in the section entitled ``GNU
  Free Documentation License''.

If you have Invariant Sections, Front-Cover Texts and Back-Cover Texts, replace the “with…Texts.” line with this:

    with the Invariant Sections being list their titles, with
    the Front-Cover Texts being list, and with the Back-Cover Texts
    being list.

If you have Invariant Sections without Cover Texts, or some other combination of the three, merge those two alternatives to suit the situation.

If your document contains nontrivial examples of program code, we recommend releasing these examples in parallel under your choice of free software license, such as the GNU General Public License, to permit their use in free software.


Index

Concepts
Functions
Index Entry  Section

H
hfy-bgcol: Non-interactive
hfy-box: Non-interactive
hfy-box-to-border-assoc: Non-interactive
hfy-box-to-style: Non-interactive
hfy-buffer: Non-interactive
hfy-color: Non-interactive
hfy-color-vals: Non-interactive
hfy-combined-face-spec: Non-interactive
hfy-compile-face-map: Non-interactive
hfy-compile-stylesheet: Non-interactive
hfy-copy-and-fontify-file: Non-interactive
hfy-css-name: Non-interactive
hfy-decor: Non-interactive
hfy-default-footer: Non-interactive
hfy-default-header: Non-interactive
hfy-dirname: Non-interactive
hfy-face-at: Non-interactive
hfy-face-attr-for-class: Non-interactive
hfy-face-to-css: Non-interactive
hfy-face-to-style: Non-interactive
hfy-face-to-style-i: Non-interactive
hfy-fallback-color-values: Non-interactive
hfy-family: Non-interactive
hfy-flatten-style: Non-interactive
hfy-fontified-p: Non-interactive
hfy-fontify-buffer: Non-interactive
hfy-force-fontification: Non-interactive
hfy-href: Non-interactive
hfy-href-stub: Non-interactive
hfy-html-dekludge-buffer: Non-interactive
hfy-html-enkludge-buffer: Non-interactive
hfy-html-quote: Non-interactive
hfy-interq: Non-interactive
hfy-kludge-cperl-mode: Non-interactive
hfy-line-number: Non-interactive
hfy-link-style: Non-interactive
hfy-link-style-string: Non-interactive
hfy-list-files: Non-interactive
hfy-load-tags-cache: Non-interactive
hfy-lookup: Non-interactive
hfy-make-directory: Non-interactive
hfy-mark-tag-hrefs: Non-interactive
hfy-mark-tag-names: Non-interactive
hfy-merge-adjacent-spans: Non-interactive
hfy-opt: Non-interactive
hfy-p-to-face: Non-interactive
hfy-parse-tags-buffer: Non-interactive
hfy-prepare-index: Non-interactive
hfy-prepare-index-i: Non-interactive
hfy-prepare-tag-map: Non-interactive
hfy-relstub: Non-interactive
hfy-shell: Non-interactive
hfy-size: Non-interactive
hfy-size-to-int: Non-interactive
hfy-slant: Non-interactive
hfy-sprintf-stylesheet: Non-interactive
hfy-subtract-maps: Non-interactive
hfy-tags-for-file: Non-interactive
hfy-text-p: Non-interactive
hfy-triplet: Non-interactive
hfy-weight: Non-interactive
hfy-width: Non-interactive
hfy-word-regex: Non-interactive
htmlfontify-buffer: Interactive
htmlfontify-copy-and-link-dir: Interactive
htmlfontify-load-rgb-file: Interactive
htmlfontify-run-etags: Interactive
htmlfontify-unload-rgb-file: Interactive

Variables & Customization