Hello #WordPress friends.
I've made a plugin that converts all your HTML headings to a Table of Contents at the start of your posts.

https://shkspr.mobi/blog/2025/03/create-a-table-of-contents-based-on-html-heading-elements/

Create a Table of Contents based on HTML Heading Elements

Some of my blog posts are long. They have lots of HTML headings like <h2> and <h3>. Say, wouldn't it be super-awesome to have something magically generate a Table of Contents? I've built a utility which runs server-side using PHP. Give it some HTML and it will construct a Table of Contents. Let's dive in! Table of ContentsBackgroundHeading ExampleWhat is the purpose of a table of…

Terence Eden’s Blog
@Edent neat!
https://www.kryogenix.org/code/browser/generated-toc/ does the same but client-side; nearly 20 years old, that, I should probably check that it still works as expected in modern browsers, although it should do, hooray for backwards compatibility
generated-toc: Generate a Table of Contents with the DOM

@Edent Nice. It reminds me of MediaWiki's TOCs which are auto-generated from ===headings===