diff options
author | Paul McGuire <ptmcg@austin.rr.com> | 2019-04-06 23:44:02 -0500 |
---|---|---|
committer | Paul McGuire <ptmcg@austin.rr.com> | 2019-04-06 23:44:02 -0500 |
commit | a2439508ba5c94546db98593cfa676de9b59babe (patch) | |
tree | 80b02178820811c09b4befc9a9b5efb092813466 /pyparsing.py | |
parent | 832986ffccac943b363da43795c335eafc31b5da (diff) | |
download | pyparsing-git-a2439508ba5c94546db98593cfa676de9b59babe.tar.gz |
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
Diffstat (limited to 'pyparsing.py')
-rw-r--r-- | pyparsing.py | 7 |
1 files changed, 5 insertions, 2 deletions
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 <ptmcg@users.sourceforge.net>" import string @@ -5415,10 +5415,13 @@ def _makeTags(tagStr, xml, + suppress_GT) closeTag = Combine(_L("</") + tagStr + ">", adjacent=False) - openTag = openTag("start"+"".join(resname.replace(":"," ").title().split())).setName("<%s>" % resname) + openTag.setName("<%s>" % resname) + # add start<tagname> 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("</%s>" % resname) openTag.tag = resname closeTag.tag = resname + openTag.tag_body = SkipTo(closeTag()) return openTag, closeTag def makeHTMLTags(tagStr): |