Changeset 6448
- Timestamp:
- 01/26/2018 11:08:46 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-developer/inc/formatting.php
r6382 r6448 34 34 add_filter( 'the_excerpt', array( __CLASS__, 'autolink_references' ), 11 ); 35 35 add_filter( 'the_content', array( __CLASS__, 'autolink_references' ), 11 ); 36 37 add_filter( 'devhub-parameter-type', array( __CLASS__, 'autolink_references' ) ); 38 36 39 add_filter( 'devhub-format-description', array( __CLASS__, 'autolink_references' ) ); 37 add_filter( 'devhub-parameter-type', array( __CLASS__, 'autolink_references' ) );38 39 40 add_filter( 'devhub-format-description', array( __CLASS__, 'fix_param_hash_formatting' ), 9 ); 41 add_filter( 'devhub-format-description', array( __CLASS__, 'fix_param_description_parsedown_bug' ) ); 40 42 41 43 add_filter( 'devhub-function-return-type', array( __CLASS__, 'autolink_references' ) ); … … 507 509 } 508 510 511 /** 512 * Fix Parsedown bug that introduces unbalanced 'code' tags. 513 * 514 * Under very specific criteria, a bug in the Parsedown package used by the 515 * parser causes backtick-to-code-tag conversions to get mishandled, skipping 516 * conversion of a backtick and causing subsequent backticks to be converted 517 * incorrectly as an open or close 'code' tag (opposite of what it should've 518 * been). See referenced tickets for more details. 519 * 520 * Intended to be a temporary fix until/unless Parsedown is fixed. 521 * 522 * @see https://meta.trac.wordpress.org/ticket/2900 523 * @see https://github.com/erusev/parsedown/pull/515 524 */ 525 public static function fix_param_description_parsedown_bug( $text ) { 526 $fixes = array( 527 '/`(.+)<code>/' => '<code>$1</code>', 528 '/<\/code>(.+)`/' => ' <code>$1</code>', 529 '/<\/code>(.+)<code>/' => ' <code>$1</code>', 530 ); 531 532 $matched = true; 533 534 foreach ( $fixes as $regex => $replace ) { 535 if ( $matched && $matched = preg_match( $regex, $text, $match ) ) { 536 $text = preg_replace( $regex, $replace, $text ); 537 } 538 } 539 540 return $text; 541 } 542 509 543 } // DevHub_Formatting 510 544
Note: See TracChangeset
for help on using the changeset viewer.