def _makeTags(tagStr, xml,<EOL>suppress_LT=Suppress("<STR_LIT:<>"),<EOL>suppress_GT=Suppress("<STR_LIT:>>")):
if isinstance(tagStr,basestring):<EOL><INDENT>resname = tagStr<EOL>tagStr = Keyword(tagStr, caseless=not xml)<EOL><DEDENT>else:<EOL><INDENT>resname = tagStr.name<EOL><DEDENT>tagAttrName = Word(alphas,alphanums+"<STR_LIT>")<EOL>if (xml):<EOL><INDENT>tagAttrValue = dblQuotedString.copy().setParseAction( removeQuotes )<EOL>openTag = (suppress_LT<EOL>+ tagStr("<STR_LIT>")<EOL>+ Dict(ZeroOrMore(Group(tagAttrName + Suppress("<STR_LIT:=>") + tagAttrValue )))<EOL>+ Optional("<STR_LIT:/>", default=[False])("<STR_LIT>").setParseAction(lambda s,l,t:t[<NUM_LIT:0>]=='<STR_LIT:/>')<EOL>+ suppress_GT)<EOL><DEDENT>else:<EOL><INDENT>tagAttrValue = quotedString.copy().setParseAction( removeQuotes ) | Word(printables, excludeChars="<STR_LIT:>>")<EOL>openTag = (suppress_LT<EOL>+ tagStr("<STR_LIT>")<EOL>+ Dict(ZeroOrMore(Group(tagAttrName.setParseAction(downcaseTokens)<EOL>+ Optional(Suppress("<STR_LIT:=>") + tagAttrValue))))<EOL>+ Optional("<STR_LIT:/>",default=[False])("<STR_LIT>").setParseAction(lambda s,l,t:t[<NUM_LIT:0>]=='<STR_LIT:/>')<EOL>+ suppress_GT)<EOL><DEDENT>closeTag = Combine(_L("<STR_LIT>") + tagStr + "<STR_LIT:>>", adjacent=False)<EOL>openTag.setName("<STR_LIT>" % resname)<EOL>openTag.addParseAction(lambda t: t.__setitem__("<STR_LIT:start>"+"<STR_LIT>".join(resname.replace("<STR_LIT::>","<STR_LIT:U+0020>").title().split()), t.copy()))<EOL>closeTag = closeTag("<STR_LIT:end>"+"<STR_LIT>".join(resname.replace("<STR_LIT::>","<STR_LIT:U+0020>").title().split())).setName("<STR_LIT>" % resname)<EOL>openTag.tag = resname<EOL>closeTag.tag = resname<EOL>openTag.tag_body = SkipTo(closeTag())<EOL>return openTag, closeTag<EOL>
Internal helper to construct opening and closing tag expressions, given a tag name