Menu

#472 Node.previous_sibling is broken

closed-fixed
nobody
None
5
2023-06-22
2023-06-05
No

It doesn’t work as advertised, as it never returns None.

def previous_sibling(self):
    """Return preceding sibling node or ``None``."""
    try:
        return self.parent[self.parent.index(self)-1]
    except (AttributeError, IndexError):
        return None

This means that when self is the first child, i.e. self.parent.index(self) == 0, then self.parent[-1] is returned. The last child, not None. If len(node.parent) == 1, that means node.previous_sibling() is node.

This in turn means that the HTML writer for citation elements will emit broken HTML, see https://github.com/mcmtroffaes/sphinxcontrib-bibtex/issues/329

This is pretty severe since it leads to broken HTML markup and therefore completely broken page layout.

Discussion

  • flying sheep

    flying sheep - 2023-06-05

    Ah, it’s been fixed in https://sourceforge.net/p/docutils/patches/195/ / v0.20

     

    Last edit: flying sheep 2023-06-05
  • Günter Milde

    Günter Milde - 2023-06-22
    • status: open --> closed-fixed
    • Priority: 8 --> 5
     
  • Günter Milde

    Günter Milde - 2023-06-22

    This is a duplicate of [patches:#195], fixed in Docutils 0.20.
    Thanks for reporting, anyway.

     

    Related

    Patches: #195


Log in to post a comment.

Auth0 Logo