Comments (3)
Confirmed.
Initially, it looked like h4s headings might have been a fallback, as they will appear if there are no h3s. However a closer look shows this is a bug for sure.
table-of-contents/table-of-contents.php
Line 52 in 5b3da29
This union operator means a) we'll end up with a weird TOC if there are more h4s than h3s and b) the original order won't be maintained.
I'm working on a few general updates in my fork, here's a changeset that will make the headings used for the TOC filterable.
In my fork, h3 is kept as the default heading to use in the TOC. h4s are ignored altogether. To add additional headings, a filter can be used:
add_filter( 'toc_tags_for_toc', function( $tags) {
return [ 'h3', 'h4' ];
}, 11 );
If you have a chance to test out my change, that would be great! I'll work on getting my fork's updates merged over here properly.
from table-of-contents.
Hi, thanks for this fix, however, this fix only worked when there is no Gutenberg align style applied on the headings, for example, when you add heading h3 and change the block align style into a center, this TOC won't generate this heading, this also same when you add these headings into a group block.
from table-of-contents.
I think that's technically a separate issue, so I've created issue #10 to track that.
from table-of-contents.
Related Issues (6)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from table-of-contents.