Skip to content

todolist produce duplicate titles for admonitions #14623

Description

@kdeldycke

Describe the bug

When a named admonition (.. danger::, .. warning::, ...) is nested inside a .. todo:: directive, and the source document is written before a document containing .. todolist::, the admonition appears with two title bars on the todolist page, while the source page renders it correctly with one:

Image

Source: https://kdeldycke.github.io/click-extra/todolist.html

The duplication depends on alphabetical document order: if the todolist page is written first, both pages render correctly.

How to Reproduce

Minimal project, three files, sphinx.ext.todo as the only extension (reproduced on Sphinx 9.1.0).

conf.py:

project = "repro"
extensions = ["sphinx.ext.todo"]
todo_include_todos = True

index.rst:

Index
=====

.. toctree::

   a
   b

a.rst (document holding the todo, written first alphabetically):

Doc A
=====

.. todo::

   A todo entry.

   .. danger::

      Danger inside a todo.

b.rst (the todolist page, written second):

Doc B
=====

.. todolist::

Build with sphinx-build -b html . _build.

Actual: a.html contains one <p class="admonition-title">Danger</p>; b.html contains two.

Expected: exactly one title on both pages, independent of document ordering.

Swapping the names so the todolist page sorts first (todo page becomes z.rst) makes both pages render a single title, which shows the bug is order-dependent.

Environment Information

- Sphinx 9.1.0
- Python 3.14, macOS
- HTML builder, Alabaster and Furo themes

Sphinx extensions

extensions = ["sphinx.ext.todo"]

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions