Skip to content

Commit aa4f654

Browse files
fix sigil_bs4 to work with lxml 4.4.X which returns null strings for namespace prefixes instead of None
1 parent 05fbe7c commit aa4f654

File tree

1 file changed

+10
-0
lines changed
  • src/Resource_Files/plugin_launchers/python/sigil_bs4/builder

1 file changed

+10
-0
lines changed

src/Resource_Files/plugin_launchers/python/sigil_bs4/builder/_lxml.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,16 @@ def start(self, name, attrs, nsmap={}):
167167
attrs = dict(attrs)
168168
nsprefix = None
169169

170+
# ARRGGHH lxml 4.4.X has changes empty prefixes on namespaces to be the null string
171+
# and not None which all prior versions used! So remap '' prefixes to be None
172+
# so we can work with all lxml versions
173+
new_nsmap = {}
174+
for pfx, ns in list(nsmap.items()):
175+
if pfx is not None and pfx == '':
176+
pfx = None
177+
new_nsmap[pfx] = ns
178+
nsmap = new_nsmap
179+
170180
# Fix bug in bs4 _lxml.py that ignores attributes that specify namespaces on this tag
171181
# Invert each namespace map as it comes in.
172182
if len(nsmap) > 0:

0 commit comments

Comments
 (0)