Skip to content

Commit 3d037a4

Browse files
committed
Phew, try #2, this time actually catching the serializer bug it introduced.
1 parent 0d715ae commit 3d037a4

File tree

3 files changed

+22
-5
lines changed

3 files changed

+22
-5
lines changed

bikeshed/Spec.py

+1
Original file line numberDiff line numberDiff line change
@@ -314,6 +314,7 @@ def serialize(self):
314314
).serialize(self.document)
315315
except Exception as e:
316316
die("{0}", e)
317+
return
317318
rendered = finalHackyCleanup(rendered)
318319
return rendered
319320

bikeshed/h/dom.py

+20-4
Original file line numberDiff line numberDiff line change
@@ -144,16 +144,16 @@ def innerHTML(el):
144144
return (el.text or "") + "".join(tostring(x, encoding="unicode") for x in el)
145145

146146

147-
def outerHTML(el, literal=False):
147+
def outerHTML(el, literal=False, with_tail=False):
148148
if el is None:
149149
return ""
150150
if isinstance(el, str):
151151
return el
152152
if isinstance(el, list):
153-
return "".join(map(outerHTML, el))
153+
return "".join(outerHTML(x) for x in el)
154154
if el.get("bs-autolink-syntax") is not None and not literal:
155155
return el.get("bs-autolink-syntax")
156-
return tostring(el, with_tail=False, encoding="unicode")
156+
return tostring(el, with_tail=with_tail, encoding="unicode")
157157

158158

159159
def serializeTag(el):
@@ -419,7 +419,23 @@ def childNodes(parentEl, clear=False, skipOddNodes=True):
419419
if it's false, there might be comments, PIs, etc.
420420
"""
421421
if isinstance(parentEl, list):
422-
return parentEl
422+
ret = []
423+
for c in parentEl:
424+
if isinstance(c, str):
425+
ret.append(c)
426+
continue
427+
if skipOddNodes and isOddNode(c):
428+
pass
429+
else:
430+
ret.append(c)
431+
if not emptyText(c.tail, wsAllowed=False):
432+
ret.append(c.tail)
433+
if clear:
434+
c.tail = None
435+
if clear:
436+
parentEl[:] = []
437+
return ret
438+
423439
ret = []
424440
if not emptyText(parentEl.text, wsAllowed=False):
425441
ret.append(parentEl.text)

bikeshed/h/serializer.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ def _categorizeBlockChildren(self, el):
222222
"""
223223
if len(el) == 0 and dom.emptyText(el.text):
224224
return "empty", None
225-
children = dom.childNodes(el)
225+
children = dom.childNodes(el, clear=True)
226226
for child in children:
227227
if self.isElement(child) and self.isBlockElement(child.tag):
228228
return "blocks", self._blocksFromChildren(children)

0 commit comments

Comments
 (0)