Skip to content

Commit df26e89

Browse files
committed
Make sure we aren't dropping any span content
1 parent 8a0ecf3 commit df26e89

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

markdown/extensions/md_in_html.py

+8-6
Original file line numberDiff line numberDiff line change
@@ -331,28 +331,30 @@ def parse_element_content(self, element: etree.Element) -> None:
331331
# Replace the placeholder with the element and process it.
332332
# Content after the placeholder should be attached to the tail.
333333
if child is None:
334-
element.text = block[start:end]
334+
element.text += block[start:end]
335335
else:
336-
child.tail = f"{child.tail if child.tail is not None else ''}{block[start:end]}"
336+
child.tail += block[start:end]
337337
element.append(el)
338338
self.parse_element_content(el)
339339
child = el
340+
if child.tail is None:
341+
child.tail = ''
340342
self.parser.md.htmlStash.rawHtmlBlocks.pop(index)
341343
self.parser.md.htmlStash.rawHtmlBlocks.insert(index, '')
342344

343345
else:
344346
# Not an element object, so insert content back into the element
345347
if child is None:
346-
element.text = block[start:end]
348+
element.text += block[start:end]
347349
else:
348-
child.tail = f"{child.tail if child.tail is not None else ''}{block[start:end]}"
350+
child.tail += block[start:end]
349351
start = end
350352

351353
# Insert anything left after last element
352354
if child is None:
353-
element.text = block[start:]
355+
element.text += block[start:]
354356
else:
355-
child.tail = (child.tail if child.tail is not None else '') + block[start:]
357+
child.tail += block[start:]
356358

357359
else:
358360
# Disable inline parsing for everything else

0 commit comments

Comments
 (0)