summaryrefslogtreecommitdiffstats
path: root/Doc/tools/sgmlconv
diff options
context:
space:
mode:
authorFred Drake <fdrake@acm.org>1999-01-19 23:03:04 (GMT)
committerFred Drake <fdrake@acm.org>1999-01-19 23:03:04 (GMT)
commit36dfe58694afff02120f89e5a086593716baf1d7 (patch)
tree1633e16677053d00501eb498af4a04d1ef5bf087 /Doc/tools/sgmlconv
parent2664db9f763568dee0f53426ab9885ea3c624395 (diff)
downloadcpython-36dfe58694afff02120f89e5a086593716baf1d7.zip
cpython-36dfe58694afff02120f89e5a086593716baf1d7.tar.gz
cpython-36dfe58694afff02120f89e5a086593716baf1d7.tar.bz2
isnmtoken(), istoken(): Fix to ensure the regex has to match the
entire attribute value. Add ability to save list of "empty" elements to a file -- enabled by constant in the code.
Diffstat (limited to 'Doc/tools/sgmlconv')
-rwxr-xr-xDoc/tools/sgmlconv/esis2sgml.py19
1 files changed, 17 insertions, 2 deletions
diff --git a/Doc/tools/sgmlconv/esis2sgml.py b/Doc/tools/sgmlconv/esis2sgml.py
index 07ca571..b8050c8 100755
--- a/Doc/tools/sgmlconv/esis2sgml.py
+++ b/Doc/tools/sgmlconv/esis2sgml.py
@@ -9,12 +9,17 @@ __version__ = '$Revision$'
import errno
import esistools
+import os
import re
import string
from xml.utils import escape
+EMPTIES_FILENAME = "../sgml/empties.dat"
+LIST_EMPTIES = 0
+
+
def format_attrs(attrs, xml=0):
attrs = attrs.items()
attrs.sort()
@@ -33,11 +38,11 @@ def format_attrs(attrs, xml=0):
return s
-_nmtoken_rx = re.compile("[a-z][-._a-z0-9]*", re.IGNORECASE)
+_nmtoken_rx = re.compile("[a-z][-._a-z0-9]*$", re.IGNORECASE)
def isnmtoken(s):
return _nmtoken_rx.match(s) is not None
-_token_rx = re.compile("[a-z0-9][-._a-z0-9]*", re.IGNORECASE)
+_token_rx = re.compile("[a-z0-9][-._a-z0-9]*$", re.IGNORECASE)
def istoken(s):
return _token_rx.match(s) is not None
@@ -99,6 +104,16 @@ def do_convert(ifp, ofp, xml=0):
elif type == "e":
knownempty = 1
+ if LIST_EMPTIES:
+ knownempties.append("")
+ if os.path.isfile(EMPTIES_FILENAME):
+ mode = "a"
+ else:
+ mode = "w"
+ fp = open(EMPTIES_FILENAME, mode)
+ fp.write(string.join(knownempties, "\n"))
+ fp.close()
+
def sgml_convert(ifp, ofp):
return do_convert(ifp, ofp, xml=0)