Commit 36dfe586 authored by Fred Drake's avatar Fred Drake

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.
parent 2664db9f
...@@ -9,12 +9,17 @@ __version__ = '$Revision$' ...@@ -9,12 +9,17 @@ __version__ = '$Revision$'
import errno import errno
import esistools import esistools
import os
import re import re
import string import string
from xml.utils import escape from xml.utils import escape
EMPTIES_FILENAME = "../sgml/empties.dat"
LIST_EMPTIES = 0
def format_attrs(attrs, xml=0): def format_attrs(attrs, xml=0):
attrs = attrs.items() attrs = attrs.items()
attrs.sort() attrs.sort()
...@@ -33,11 +38,11 @@ def format_attrs(attrs, xml=0): ...@@ -33,11 +38,11 @@ def format_attrs(attrs, xml=0):
return s 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): def isnmtoken(s):
return _nmtoken_rx.match(s) is not None 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): def istoken(s):
return _token_rx.match(s) is not None return _token_rx.match(s) is not None
...@@ -99,6 +104,16 @@ def do_convert(ifp, ofp, xml=0): ...@@ -99,6 +104,16 @@ def do_convert(ifp, ofp, xml=0):
elif type == "e": elif type == "e":
knownempty = 1 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): def sgml_convert(ifp, ofp):
return do_convert(ifp, ofp, xml=0) return do_convert(ifp, ofp, xml=0)
......
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