Changeset 4573 for sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/readme/class-parser.php
- Timestamp:
- 12/23/2016 04:25:57 AM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/readme/class-parser.php
r4571 r4573 561 561 $lines = explode( "\n", $lines ); 562 562 } 563 $trimmed_lines = array_map( 'trim', $lines ); 563 564 564 565 /* 565 566 * The heading style being matched in the block. Can be 'heading' or 'bold'. 566 * Standard Markdown headings (## .. and == ... ==) are matched if they exist. 567 * Full line bolding is otherwise used as the heading style. 568 * This will match sections based on which ever style is encountered in a block of text first. 567 * Standard Markdown headings (## .. and == ... ==) are used, but if none are present. 568 * full line bolding will be used as a heading style. 569 569 */ 570 $heading_style = false; // 'heading' or 'bold' 571 572 while ( ( $line = array_shift( $lines ) ) !== null ) { 573 $trimmed = trim( $line ); 570 $heading_style = 'bold'; // 'heading' or 'bold' 571 foreach ( $trimmed_lines as $trimmed ) { 572 if ( $trimmed[0] == '#' || $trimmed[0] == '=' ) { 573 $heading_style = 'heading'; 574 break; 575 } 576 } 577 578 $line_count = count( $lines ); 579 for ( $i = 0; $i < $line_count; $i++ ) { 580 $line = &$lines[ $i ]; 581 $trimmed = &$trimmed_lines[ $i ]; 574 582 if ( ! $trimmed ) { 575 583 $value .= "\n"; … … 578 586 579 587 $is_heading = false; 580 if ( 581 ( ! $heading_style || 'heading' == $heading_style ) && 582 ( $trimmed[0] == '#' || $trimmed[0] == '=' ) 583 ) { 584 $heading_style = 'heading'; 588 if ( 'heading' == $heading_style && ( $trimmed[0] == '#' || $trimmed[0] == '=' ) ) { 585 589 $is_heading = true; 586 } elseif ( 587 ( ! $heading_style || 'bold' == $heading_style ) && 588 ( substr( $trimmed, 0, 2 ) == '**' && substr( $trimmed, -2 ) == '**' ) 589 ) { 590 $heading_style = 'bold'; 590 } elseif ( 'bold' == $heading_style && ( substr( $trimmed, 0, 2 ) == '**' && substr( $trimmed, -2 ) == '**' ) ) { 591 591 $is_heading = true; 592 592 }
Note: See TracChangeset
for help on using the changeset viewer.