Skip to content

Duplicated headings in nested blocks #609

@percevalw

Description

@percevalw

Describe the bug

Nesting a docstring in another block (e.g., tab or admonition) produces duplicated headings.

tests/fixtures/headings.py
"""
Foo
===

### Bar

###### Baz
"""
index.md
Top.[^aaa]

=== "Tab A"

    ::: tests.fixtures.headings

In this case, the "Foo" header will appear twice in the produced html, both at the right position and after the inserted docstring :

<p>Top.[^aaa]</p>
  <div class="tabbed-set tabbed-alternate" data-tabs="1:1"><input checked="checked" id="__tabbed_1_1" name="__tabbed_1" type="radio" /><div class="tabbed-labels"><label for="__tabbed_1_1">Tab A</label></div>
  <div class="tabbed-content">
  <div class="tabbed-block">
  <div class="mkdocstrings">

  <div class="doc doc-object doc-module">



  <a id="tests.fixtures.headings"></a>
    <div class="doc doc-contents first">

        <h2 id="tests.fixtures.headings--foo">Foo</h2>
  <h4 id="tests.fixtures.headings--bar">Bar</h4>
  <h6 id="tests.fixtures.headings--baz">Baz</h6>

    </div>

  </div><h2 data-role="module" id="tests.fixtures.headings"></h2>
  <h2 id="tests.fixtures.headings--foo">Foo</h2>
  <h4 id="tests.fixtures.headings--bar">Bar</h4>
  <h6 id="tests.fixtures.headings--baz">Baz</h6>
  </div>
  </div>
  </div>
  </div>

Expected behavior

Headings from docstrings should not be duplicated.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions