In addition to the aforementioned interactive methods, Htmlfontify provides the following non-interactive ones:
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.
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.
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
Return a regex that matches string as the first
with non word characters on either side (vaguely emulating the perl
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.
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 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.
Trawl the current buffer, construct and return a hfy-sheet-assoc.
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.
Approximate equivalent of
mkdir -p dir.
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).
Default value for hfy-page-footer
Return a list of files under directory.
Strips any leading ‘./’ from each filename.
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,
(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.
Returns the line number of the point in the current buffer.
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 srcdir file)
Mark tags in file (lookup srcdir in hfy-tags-cache) with the
hfy-anchor property, with a value of ‘tag.line-number’.
Derive a font-weight CSS specifier from an Emacs weight specification symbol.
Derive a CSS font-size specifier from an Emacs font
Does not cope with the case where height is a function to be applied to
the height of the underlying font.
(hfy-default-header file style)
Default value for hfy-page-header
Derives a CSS font-family specifier from an Emacs
(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
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”).
Derive CSS border-* attributes from the Emacs
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.
Mark dangerous ‘["<>]’ characters with the
See also hfy-html-dekludge-buffer.
Generate and return an Htmlfontify html output buffer for the current
buffer. May trample an existing buffer.
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-fontified for truth.
(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 &optional srcdir file)
Implement the guts of htmlfontify-buffer.
Convert an Emacs :foreground property to a CSS color property.
Take style (see hfy-face-to-style-i, 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.
Convert spec, a CSS font-size specifier, back to an Emacs
:height attribute value. Used while merging multiple font-size
(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 file &optional start)
Return a ‘../’ stub of the appropriate length for the current source
tree depth (as determined from file).
Compile and return a hfy-facemap-assoc for the current buffer.
(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 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
Internal function—strips definitions of tags from the instance map.
See: hfy-tags-cache and hfy-tags-rmap
The guts of hfy-face-to-style. fn should be a
font specification, as returned by
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.
Take fn, a font or
defface specification (c.f.
face-attr-construct) and return a CSS style specification.
See also: hfy-face-to-style
Map a string (usually 1 character long) to an html safe string
(entity) if need be.
Convert the CSS style spec style-string to its equivalent hyperlink style.
Given props, a list of text-properties, return the value of the
face property, or nil.
Helper function for hfy-box-to-style.
(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 behaviour when deciding on which face attributes to
use, to the best of my understanding ).
If class is nil, then you just get 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.
Find face in effect at point P. If overlays are to be considered
(see hfy-optimisations) then this may return a
list of face properties instead of a face symbol.
As per hfy-color but for background colors.
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 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.
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.
Run hfy-etags-cmd on srcdir: load hfy-tags-cache and hfy-tags-sortl.
(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 set-a set-b)
Return the intersection (using
eq) of 2 lists.
(hfy-text-p srcdir file)
Is srcdir/file text? Uses hfy-istext-command to determine this.
Is hfy-optimisations member symbol set or not?
Return everything preceding the last ‘/’ from a relative filename,
on the assumption that this will produce a relative directory name. Hardly
bombproof, but good enough in the context in which it is being used.
Transform all dangerous characters marked with the
See also hfy-html-enkludge-buffer.
(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 tag val)
Derive CSS text-decoration specifiers from various Emacs font attributes.
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 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.
Convert an Emacs
:width attribute to a CSS font-stretch attribute.