Commit d6852147 authored by Fred Drake's avatar Fred Drake

Some cleanup.

Don't duplicate the information on what's empty; rely on the input
data for that.  (This means that the DOM may need more work.)
parent d914cffd
#! /usr/bin/env python
"""
"""Convert ESIS events to SGML or XML markup.
This is limited, but seems sufficient for the ESIS generated by the
latex2esis.py script when run over the Python documentation.
"""
__version__ = '$Revision$'
import errno
import re
import string
......@@ -64,6 +67,9 @@ def do_convert(ifp, ofp, knownempties, xml=0):
ofp.write("<%s%s/>" % (data, format_attrs(attrs)))
else:
ofp.write("<%s%s>" % (data, format_attrs(attrs)))
if knownempty and data not in knownempties:
# accumulate knowledge!
knownempties.append(data)
attrs = {}
lastopened = data
lastempty = knownempty
......@@ -87,11 +93,11 @@ def do_convert(ifp, ofp, knownempties, xml=0):
def sgml_convert(ifp, ofp, knownempties=()):
return do_convert(ifp, ofp, knownempties, xml=0)
return do_convert(ifp, ofp, list(knownempties), xml=0)
def xml_convert(ifp, ofp, knownempties=[]):
return do_convert(ifp, ofp, knownempties, xml=1)
def xml_convert(ifp, ofp, knownempties=()):
return do_convert(ifp, ofp, list(knownempties), xml=1)
def main():
......@@ -114,11 +120,11 @@ def main():
usage()
sys.exit(2)
# knownempties is ignored in the XML version
convert(ifp, ofp, knownempties=["rfc", "POSIX", "ASCII", "declaremodule",
"maketitle", "makeindex", "makemodindex",
"localmoduletable", "ABC", "UNIX", "Cpp",
"C", "EOF", "NULL", "manpage", "input",
"label"])
try:
convert(ifp, ofp)
except IOError, (err, msg):
if err != errno.EPIPE:
raise
if __name__ == "__main__":
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment