From a2439508ba5c94546db98593cfa676de9b59babe Mon Sep 17 00:00:00 2001 From: Paul McGuire Date: Sat, 6 Apr 2019 23:44:02 -0500 Subject: Fixed dict structure in makeHTMLTags expressions, and added tag_body attribute to the generated start expression giving easy access to a SkipTo(closeTag) that will parse the tag's body text; some code cleanup and removed duplication among examples --- pyparsing.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'pyparsing.py') diff --git a/pyparsing.py b/pyparsing.py index ebea155..97f3374 100644 --- a/pyparsing.py +++ b/pyparsing.py @@ -94,7 +94,7 @@ classes inherit from. Use the docstrings for examples of how to: """ __version__ = "2.4.0" -__versionTime__ = "02 Apr 2019 02:07 UTC" +__versionTime__ = "07 Apr 2019 04:08 UTC" __author__ = "Paul McGuire " import string @@ -5415,10 +5415,13 @@ def _makeTags(tagStr, xml, + suppress_GT) closeTag = Combine(_L("", adjacent=False) - openTag = openTag("start"+"".join(resname.replace(":"," ").title().split())).setName("<%s>" % resname) + openTag.setName("<%s>" % resname) + # add start results name in parse action now that ungrouped names are not reported at two levels + openTag.addParseAction(lambda t: t.__setitem__("start"+"".join(resname.replace(":"," ").title().split()), t.copy())) closeTag = closeTag("end"+"".join(resname.replace(":"," ").title().split())).setName("" % resname) openTag.tag = resname closeTag.tag = resname + openTag.tag_body = SkipTo(closeTag()) return openTag, closeTag def makeHTMLTags(tagStr): -- cgit v1.2.1