Skip to content

Commit

Permalink
Phew, try #2, this time actually catching the serializer bug it intro…
Browse files Browse the repository at this point in the history
…duced.
  • Loading branch information
tabatkins committed Jul 22, 2021
1 parent 0d715ae commit 3d037a4
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 5 deletions.
1 change: 1 addition & 0 deletions bikeshed/Spec.py
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,7 @@ def serialize(self):
).serialize(self.document)
except Exception as e:
die("{0}", e)
return
rendered = finalHackyCleanup(rendered)
return rendered

Expand Down
24 changes: 20 additions & 4 deletions bikeshed/h/dom.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,16 +144,16 @@ def innerHTML(el):
return (el.text or "") + "".join(tostring(x, encoding="unicode") for x in el)


def outerHTML(el, literal=False):
def outerHTML(el, literal=False, with_tail=False):
if el is None:
return ""
if isinstance(el, str):
return el
if isinstance(el, list):
return "".join(map(outerHTML, el))
return "".join(outerHTML(x) for x in el)
if el.get("bs-autolink-syntax") is not None and not literal:
return el.get("bs-autolink-syntax")
return tostring(el, with_tail=False, encoding="unicode")
return tostring(el, with_tail=with_tail, encoding="unicode")


def serializeTag(el):
Expand Down Expand Up @@ -419,7 +419,23 @@ def childNodes(parentEl, clear=False, skipOddNodes=True):
if it's false, there might be comments, PIs, etc.
"""
if isinstance(parentEl, list):
return parentEl
ret = []
for c in parentEl:
if isinstance(c, str):
ret.append(c)
continue
if skipOddNodes and isOddNode(c):
pass
else:
ret.append(c)
if not emptyText(c.tail, wsAllowed=False):
ret.append(c.tail)
if clear:
c.tail = None
if clear:
parentEl[:] = []
return ret

ret = []
if not emptyText(parentEl.text, wsAllowed=False):
ret.append(parentEl.text)
Expand Down
2 changes: 1 addition & 1 deletion bikeshed/h/serializer.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ def _categorizeBlockChildren(self, el):
"""
if len(el) == 0 and dom.emptyText(el.text):
return "empty", None
children = dom.childNodes(el)
children = dom.childNodes(el, clear=True)
for child in children:
if self.isElement(child) and self.isBlockElement(child.tag):
return "blocks", self._blocksFromChildren(children)
Expand Down

0 comments on commit 3d037a4

Please sign in to comment.