WordPress.org

Making WordPress.org

Opened 8 weeks ago

Closed 8 weeks ago

Last modified 5 weeks ago

#5963 closed defect (fixed)

ToC plugin doesn't support Gutenberg

Reported by: dd32 Owned by: dd32
Milestone: Priority: normal
Component: Handbooks Keywords:
Cc:

Description

The ToC plugin on handbooks doesn't currently support Gutenberg generated pages.

This is due to one primary reason, automatically including IDs:

  • Markup is <h3 id="this-is-title">This is title</h3>

But in addition to that, Gutenberg can style headings (for example, colouring, or text-transforms, etc)

  • Markup is <h3 class="has-vivid-red-color" id="example">Example</h3>
  • Markup is <h3 id="example" style="text-transform:uppercase">Example</h3>

Change History (3)

#1 @dd32
8 weeks ago

  • Resolution set to fixed
  • Status changed from assigned to closed

In 11341:

Handbooks, ToC: Update the TOC generation to support Gutenberg usage.

In gutenberg, the headings automatically have IDs present, and can have class and style attributes which also didn't work with the plugin.

This change alters how markup is generated significantly by generating IDs once per the_content call, and makes use of named matching groups for readability.

This change means that:

  • It works with Gutenberg header blocks including id=..
  • Custom IDs can be specified for headings (In the Advanced panel in Gutenberg) to avoid changing the ID when changing the title
  • Headings can be styled inside Gutenberg and it'll still be presented correctly in the ToC markup (both style and class attributes)

Fixes #5963.

#2 @dd32
6 weeks ago

In 11354:

Handbooks, ToC: Be less greedy when matching headings within the content.

[11341] didn't change the greedyness, but as it was now matching headings with attributes, it was matching too much on reference pages.

Additionally, we now don't use style-only headings (those without text) as valid sections.

See #5963.
Fixes #5973.

#3 @dd32
5 weeks ago

In 11365:

Support: HelpHub: Attempt to replace the TOC plugin within the HelpHub site with the original WordPress.org-supported TOC plugin it was based on.

The HelpHub plugin was based on the Handbooks plugin, but customised and further plugin-ised, resulting in two different plugins on WordPress.org doing the same thing, in different ways.

This is an attempt to make it easier to sync the Handbook plugin changes to Support pages.

See #5979, #5963.

Note: See TracTickets for help on using tickets.