File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -22,8 +22,10 @@ def __init__(self):
2222
2323 exp = mm .expand_all (fname , root )
2424 self .save (exp )
25-
25+
26+
2627 def save (self , el ):
28+ remove_debug_attrs (el )
2729 open (cmdline .outfile (), 'wb' ).write (etree .tostring (el , method = "html" ))
2830
2931def main ():
Original file line number Diff line number Diff line change @@ -42,3 +42,23 @@ def parse_string(s):
4242 soup = BeautifulSoup (s , "html.parser" )
4343 tree = etree .fromstring (str (soup ), _xml_parser )
4444 return tree
45+
46+ # mutates
47+ def deep_rm_attr (el , attr_name ):
48+ '''recursively descend through all elements removing attributes
49+ with `attr_name`.'''
50+
51+ if el is None :
52+ return
53+
54+ if attr_name in el .attrib :
55+ del el .attrib [attr_name ]
56+
57+ for child in el :
58+ deep_rm_attr (child , attr_name )
59+
60+
61+ # mutates
62+ def remove_debug_attrs (el ):
63+ deep_rm_attr (el , ATTR_FILENAME )
64+ deep_rm_attr (el , ATTR_LINENUM )
You can’t perform that action at this time.
0 commit comments