Some headings missing from TOC dropdown in RST
### Summary
In reStructuredText files, headings that are not immediately followed by body text
may be missing from the table of contents dropdown.
### Steps to reproduce
1. Create an `.rst` file with the following content:
```rst
Heading A
=========
Heading B
---------
Heading C
~~~~~~~~~
Heading D
^^^^^^^^^
Heading E
'''''''''
Heading F
"""""""""
```
2. Preview the file and click the table of contents button.
### What is the current *bug* behavior?
Some headings without body text do not appear in the TOC dropdown:
{width=422 height=378}
### What is the expected *correct* behavior?
All headings appear in the TOC dropdown and link to their respective positions in the file.
### Output of checks
This bug happens on GitLab.com
### References
- !241282+
issue