mirror of
https://github.com/zulip/zulip.git
synced 2025-11-06 15:03:34 +00:00
bugdown: Fix buggy rendering of pre elements inside bullets.
Our nested code block processor wasn't using the correct test for whether a paragraph was empty of other content; first, we need to confirm no children, and second, we need to confirm there is no text before/after the code block element inside the p tag.
This commit is contained in:
@@ -41,10 +41,11 @@ class NestedCodeBlocksRendererTreeProcessor(markdown.treeprocessors.Treeprocesso
|
||||
parent = code_tag.family.parent # type: Any
|
||||
grandparent = code_tag.family.grandparent # type: Any
|
||||
if parent.tag == "p" and grandparent.tag == "li":
|
||||
# if the parent (<p>) has no text, that means that the <code>
|
||||
# element inside is its only child and thus, we can confidently
|
||||
# say that this is a nested code block
|
||||
if parent.text is None:
|
||||
# if the parent (<p>) has no text, and no children,
|
||||
# that means that the <code> element inside is its
|
||||
# only thing inside the bullet, we can confidently say
|
||||
# that this is a nested code block
|
||||
if parent.text is None and len(list(parent)) == 1 and len(list(parent.itertext())) == 1:
|
||||
nested_code_blocks.append(code_tag)
|
||||
|
||||
return nested_code_blocks
|
||||
|
||||
Reference in New Issue
Block a user