Skip to content

Commit bd7e911

Browse files
committed
fixes bug, some unescaped ampersands were reaching the xml parser.
1 parent aff935f commit bd7e911

2 files changed

Lines changed: 8 additions & 3 deletions

File tree

src/auxml/macro.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ def replace_attrs(self, mcall, mac):
8787
# do this.
8888

8989
try:
90-
tree = etree.fromstring("<temp>" + s + "</temp>")
90+
tree = parser.parse_string("<temp>" + s + "</temp>")
9191
return tree.getchildren()[0]
9292
except Exception as e:
9393
print(s)

src/auxml/parser.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,12 @@ def parse_html_file(fname):
3333

3434
# mutate soup in place
3535
tag_els_with_info(soup, fname)
36-
36+
37+
escaped_html = str(soup)
38+
tree = etree.fromstring(escaped_html, _xml_parser)
39+
return tree
40+
41+
def parse_string(s):
42+
soup = BeautifulSoup(s, "html.parser")
3743
tree = etree.fromstring(str(soup), _xml_parser)
3844
return tree
39-

0 commit comments

Comments
 (0)