**Steps to replicate**:
* Run `noreferences.py` on a page with footer templates directly under the references heading.
* Diff: https://ckb.wikipedia.org/w/index.php?diff=prev&oldid=1581970
**What happens?**:
The script matches and skips portal/footer templates (like `{{portal bar}}`, `{{commons category}}` and/or navigation templates) immediately under the heading because the `templates_or_comments` regex matches all templates. This pushes `{{reflist}}` to the bottom of the section, below those templates.
**What should happen?**:
The references list should be placed immediately under the heading (skipping HTML comments). **Why was the original regex designed to match and skip templates in a references section?**
**Software version**: 11.3.0
**Proposed solution**:
Modify the regex to only match and skip HTML comments instead of templates:
```lang=diff
- r'^((?:\s*(?:\{\{[^\{\}]*?\}\}|<!--.*?-->))*)',
+ r'^((?:\s*(?:<!--.*?-->))*)',
```
Also, please find `templates_or_comments` (2 matches) and replace them with `comments`, or whatever you think fits best.