Making WordPress.org


Ignore:
Timestamp:
12/21/2016 01:13:58 AM (8 years ago)
Author:
dd32
Message:

Plugin Directory: When parsing the FAQ and Update Notice sections, match sub-sections based on EITHER headings or full-line bolding, not both. This changes it to only match the first style it encounters, to avoid scenario's where a full-line bolding exists within an otherwise properly formatted heading block.

Fixes #2336

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/readme/class-parser.php

    r4486 r4562  
    551551        }
    552552
     553        /*
     554         * The heading style being matched in the block. Can be 'heading' or 'bold'.
     555         * Standard Markdown headings (## .. and == ... ==) are matched if they exist.
     556         * Full line bolding is otherwise used as the heading style.
     557         * This will match sections based on which ever style is encountered in a block of text first.
     558         */
     559        $heading_style = false; // 'heading' or 'bold'
     560
    553561        while ( ( $line = array_shift( $lines ) ) !== null ) {
    554562            $trimmed = trim( $line );
     
    558566            }
    559567
    560             // Normal headings (##.. == ... ==) are matched if they exist, Bold is only used if it starts and ends the line.
    561             if ( $trimmed[0] == '#' || $trimmed[0] == '=' || ( substr( $trimmed, 0, 2 ) == '**' && substr( $trimmed, -2 ) == '**' ) ) {
     568            $is_heading = false;
     569            if (
     570                ( ! $heading_style || 'heading' == $heading_style ) &&
     571                ( $trimmed[0] == '#' || $trimmed[0] == '=' )
     572                ) {
     573                $heading_style = 'heading';
     574                $is_heading = true;
     575            } elseif (
     576                ( ! $heading_style || 'bold' == $heading_style ) &&
     577                ( substr( $trimmed, 0, 2 ) == '**' && substr( $trimmed, -2 ) == '**' )
     578                ) {
     579                $heading_style = 'bold';
     580                $is_heading = true;
     581            }
     582
     583            if ( $is_heading ) {
    562584                if ( $value ) {
    563585                    $return[ $key ] = trim( $value );
Note: See TracChangeset for help on using the changeset viewer.