Giter VIP home page Giter VIP logo

Comments (3)

trepmal avatar trepmal commented on July 20, 2024

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.

$items = $h3s + $h4s;

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.

mrwindowsx avatar mrwindowsx commented on July 20, 2024

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.

trepmal avatar trepmal commented on July 20, 2024

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 photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.