Changeset 10068
- Timestamp:
- 07/13/2020 10:40:31 PM (5 years ago)
- Location:
- sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-developer
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-developer/inc/formatting.php
r10067 r10068 40 40 add_filter( 'devhub-format-description', array( __CLASS__, 'fix_param_hash_formatting' ), 9 ); 41 41 add_filter( 'devhub-format-description', array( __CLASS__, 'fix_param_description_html_as_code' ) ); 42 add_filter( 'devhub-format-description', array( __CLASS__, 'convert_lists_to_markup' ) ); 42 43 43 44 add_filter( 'devhub-format-hash-param-description', array( __CLASS__, 'autolink_references' ) ); … … 316 317 foreach ( $allowable_tags as $tag ) { 317 318 $text = str_replace( array( "<{$tag}>", "</{$tag}>" ), array( "<{$tag}>", "</{$tag}>" ), $text ); 318 }319 320 // Convert asterisks to a list.321 // Inline lists in param descriptions aren't handled by parser.322 // Example: https://developer.wordpress.org/reference/functions/add_menu_page/323 if ( false !== strpos( $text, ' * ' ) ) {324 // Display as simple plaintext list.325 $text = str_replace( ' * ', '<br /> * ', $text );326 319 } 327 320 … … 485 478 486 479 /** 480 * Converts simple Markdown-like lists into list markup. 481 * 482 * Necessary in cases like hash param descriptions which don't see Markdown 483 * list processing during parsing. 484 * 485 * Recognizes lists where list items are denoted with an asterisk or dash. 486 * 487 * Does not handle nesting of lists. 488 * 489 * @param string $text The text to process for lists. 490 * @return string 491 */ 492 public static function convert_lists_to_markup( $text ) { 493 $inline_list = false; 494 $li = '<br /> * '; 495 496 // Convert asterisks to a list. 497 // Example: https://developer.wordpress.org/reference/functions/add_menu_page/ 498 if ( false !== strpos( $text, ' * ' ) ) { 499 // Display as simple plaintext list. 500 $text = str_replace( ' * ', "\n" . $li, $text ); 501 $inline_list = true; 502 } 503 504 // Convert dashes to a list. 505 // Example: https://developer.wordpress.org/reference/classes/wp_term_query/__construct/ 506 // Example: https://developer.wordpress.org/reference/hooks/password_change_email/ 507 if ( false !== strpos( $text, ' - ' ) ) { 508 // Display as simple plaintext list. 509 $text = str_replace( ' - ', "\n" . $li, $text ); 510 $inline_list = true; 511 } 512 513 // If list detected. 514 if ( $inline_list ) { 515 // Replace first item, ensuring the opening 'ul' tag is prepended. 516 $text = preg_replace( '~^' . preg_quote( $li ) . '(.+)$~mU', "<ul><li>\$1</li>\n", $text, 1 ); 517 // Wrap subsequent list items in 'li' tags. 518 $text = preg_replace( '~^' . preg_quote( $li ) . '(.+)$~mU', "<li>\$1</li>\n", $text ); 519 $text = trim( $text ); 520 521 // Close the list if it hasn't been closed before start of next hash parameter. 522 //$text = preg_replace( '~(</li>)(\s+</li>)~smU', '$1</ul>$2', $text ); 523 $text = preg_replace( '~(</li>)(\s*</li>)~smU', '$1</ul>$2', $text ); 524 525 // Closethe list if it hasn't been closed and it's the end of the description. 526 if ( '</li>' === substr( trim( $text ), -5 ) ) { 527 $text .= '</ul>'; 528 } 529 } 530 531 return $text; 532 } 533 534 /** 487 535 * Formats the output of params defined using hash notation. 488 536 * -
sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-developer/scss/main.scss
r9716 r10068 1088 1088 font-style: italic; 1089 1089 } 1090 1091 ul { 1092 margin-left: 25px; 1093 margin-left: 2.5rem; 1094 } 1090 1095 } 1091 1096 .param-hash { 1092 1097 margin-left: 1.2em; 1093 1098 margin-bottom: 0.5em; 1094 li {1099 > li { 1095 1100 margin-top: 1em; 1101 } 1102 li li { 1103 list-style-type: circle; 1104 } 1105 .param-hash > li { 1106 list-style-type: disc; 1096 1107 } 1097 1108 } -
sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-developer/stylesheets/main.css
r9716 r10068 1477 1477 } 1478 1478 1479 .devhub-wrap .wp-parser-class .parameters dd ul, .devhub-wrap .wp-parser-function .parameters dd ul, .devhub-wrap .wp-parser-hook .parameters dd ul, .devhub-wrap .wp-parser-method .parameters dd ul { 1480 margin-left: 25px; 1481 margin-left: 2.5rem; 1482 } 1483 1479 1484 .devhub-wrap .wp-parser-class .parameters .param-hash, .devhub-wrap .wp-parser-function .parameters .param-hash, .devhub-wrap .wp-parser-hook .parameters .param-hash, .devhub-wrap .wp-parser-method .parameters .param-hash { 1480 1485 margin-left: 1.2em; … … 1482 1487 } 1483 1488 1484 .devhub-wrap .wp-parser-class .parameters .param-hash li, .devhub-wrap .wp-parser-function .parameters .param-hash li, .devhub-wrap .wp-parser-hook .parameters .param-hash li, .devhub-wrap .wp-parser-method .parameters .param-hashli {1489 .devhub-wrap .wp-parser-class .parameters .param-hash > li, .devhub-wrap .wp-parser-function .parameters .param-hash > li, .devhub-wrap .wp-parser-hook .parameters .param-hash > li, .devhub-wrap .wp-parser-method .parameters .param-hash > li { 1485 1490 margin-top: 1em; 1491 } 1492 1493 .devhub-wrap .wp-parser-class .parameters .param-hash li li, .devhub-wrap .wp-parser-function .parameters .param-hash li li, .devhub-wrap .wp-parser-hook .parameters .param-hash li li, .devhub-wrap .wp-parser-method .parameters .param-hash li li { 1494 list-style-type: circle; 1495 } 1496 1497 .devhub-wrap .wp-parser-class .parameters .param-hash .param-hash > li, .devhub-wrap .wp-parser-function .parameters .param-hash .param-hash > li, .devhub-wrap .wp-parser-hook .parameters .param-hash .param-hash > li, .devhub-wrap .wp-parser-method .parameters .param-hash .param-hash > li { 1498 list-style-type: disc; 1486 1499 } 1487 1500
Note: See TracChangeset
for help on using the changeset viewer.