Update of /cvsroot/ht2html/ht2html
In directory sc8-pr-cvs1:/tmp/cvs-serv14168
Added Files:
htwf.py
Log Message:
Script to check the XML well-formedness of the result of a conversion.
This doesn't check that the documnet "makes sense" as XHTML, only that
it's well-formed (tags are properly nested, empty tags use empty
element notation, attributes are properly quoted, etc.).
--- NEW FILE: htwf.py ---
#! /usr/bin/env python
"""Check the well-formedness of a .ht file used to generate XHTML.
Usage: %(program)s [options] file1 [file2 [...]]
Where options are:
--rootdir <directory>
-r <directory>
Specify the root of the Web page hierarchy. Otherwise the current
directory is used.
--style <classmod>
-s <classmod>
specifies the generator `style'. classmod is both a module name and a
class name. The module is imported (so it must be findable on your
sys.path) and the class is dug out of that module (so they must have
the same name). This class is instantiated by passing the following
arguments:
file -- the .ht file to be parsed
rootdir -- as specified above
relthis -- the directory path to get from rootdir to the current
directory. Note that rootdir must be a direct parent
of the current directory.
file should be passed to HTParser to create an instance of the file
parser. Your class should also create a LinkFixer using (the .html
version of) file, rootdir, and relthis.
--version
-v
Print the version number of this tool and exit.
--quiet
-q
Be quiet.
--help
-h
print this message and exit.
"""
from xml.parsers import expat
import ht2html
__version__ = ht2html.__version__
class HTWF(ht2html.Command):
def process_file(self, file):
if not self.quiet:
print 'Checking %s...' % file
g = self.get_generator(file)
if g is None:
return
newtext = g.makepage()
p = expat.ParserCreate()
try:
p.Parse(newtext, 1)
except expat.ExpatError, e:
print e
if __name__ == "__main__":
HTWF().main()
|