addContentTable
is a Python tool which adds a hierarchical content
table to HTML documents.
The content table is derived from the documents
element structure. Usually the headers H2
, H3
and
H4
are used to generate content table entries at hiearchical
level 0
, 1
and 2
, respectively.
Content table entries are links to the respective elements.
The elements are hierarchically numbered, e.g. 1.2.1
.
The generated content table usually is placed in the first div class=toc
element found in the document (its content is removed). If no such
element is found, the content table is placed after the first element
specified by place.
addContentTable.tgz
.
It contains the Python package dmutil
and the script
addContentTable
. Install the Python package as
a subdirectory of site-packages
. Place
the script addContentTable
somewhere on your path.
addContentTable [options] file...
H2,H3,H4
addContentTable
puts the rewritten HTML files into
destdir.
file~
).
-n
has also been specified.
In these cases, the content table is placed after the
first occurrence of element place.
Otherwise, the new content table replaces the old one.
H1
div class=TOC
element but place it after the first element place (see
-p
option).
xml-0.5
.
Python can be downloaded from the Python homepage, the XML package from the XML-SIG repository.
addContentTable
requires two minor patches to the
XML package.
The first patch removes a problem with the methods
firstChild
and lastChild
of
xml.dom.core.Document
objects. They fail to initialize
the document owner of the children. This leads to
Document Exceptions
.
The second patch retains
empty lines on output. This is essential e.g. for pre
elements.
You find these patches in the
XML-SIG archive
attached to the announcement of addContentTable
.
Open Source
license at your
own risk. Please see the copyright notice at the beginning of
dmutil/ContentTable.py
or addContentTable
,
for details.
addContentTable
works by parsing the document into
a DOM tree, modifying the tree and then generating a new HTML document.
Thereby, the source documents formatting is lost.
You may consider to always use the -d
option such that
your source files are retained.
visitor
module fixed.