Making WordPress.org


Ignore:
Timestamp:
12/06/2021 03:21:28 AM (3 years ago)
Author:
dd32
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/handbook/inc/table-of-contents.php

    r11341 r11354  
    110110        }
    111111
     112        // Remove any links we don't need.
     113        foreach ( $items as $i => $item ) {
     114            // If an element is all HTML, don't link to it.
     115            if ( empty( trim( strip_tags( $item['title'] ) ) ) ) {
     116                unset( $items[ $i ] );
     117            }
     118        }
     119
    112120        // Generate a list of the IDs in the document (generating them as needed).
    113121        $this->used_ids = $this->get_reserved_ids();
     
    236244        }
    237245
    238         preg_match_all( "/(?P<tag><{$tag}(?P<attrs>[^>]*)>)(?P<title>.*)(<\/{$tag}>)/iJ", $content, $matches, PREG_SET_ORDER );
     246        preg_match_all( "/(?P<tag><{$tag}(?P<attrs>[^>]*)>)(?P<title>.*?)(<\/{$tag}>)/iJ", $content, $matches, PREG_SET_ORDER );
    239247
    240248        return $matches;
Note: See TracChangeset for help on using the changeset viewer.