Making WordPress.org


Ignore:
Timestamp:
11/14/2018 12:30:35 AM (8 years ago)
Author:
coffee2code
Message:

Developer: Wrap single-quoted HTML in parameter descriptions within 'code' tags.

Of course, HTML meant to be shown as HTML should have originally been wrapped in backticks instead of single-quotes, but fastidious adherence to documentation formatting standards isn't currently enforced.

See https://core.trac.wordpress.org/ticket/38721.
Fixes #3920.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-developer/inc/formatting.php

    r7769 r7844  
    4040                add_filter( 'devhub-format-description', array( __CLASS__, 'fix_param_hash_formatting' ), 9 );
    4141                add_filter( 'devhub-format-description', array( __CLASS__, 'fix_param_description_parsedown_bug' ) );
     42                add_filter( 'devhub-format-description', array( __CLASS__, 'fix_param_description_html_as_code' ) );
    4243
    4344                add_filter( 'devhub-function-return-type', array( __CLASS__, 'autolink_references' ) );
     
    569570        }
    570571
     572        /**
     573         * Wraps single-quoted HTML within 'code' tags.
     574         *
     575         * The HTML should have been denoted with backticks in the original source, in
     576         * which case it would have been parsed properly, but committers aren't
     577         * always sticklers for documentation formatting.
     578         *
     579         * @access public
     580         *
     581         * @param string $text Text.
     582         * @return string
     583         */
     584        public static function fix_param_description_html_as_code( $text ) {
     585                if ( false !== strpos( $text, "'<" ) ) {
     586                        $text = preg_replace( '/\'(&lt;[^\']+&gt;)\'/', '<code>$1</code>', $text );
     587                }
     588
     589                return $text;
     590        }
     591
    571592} // DevHub_Formatting
    572593
Note: See TracChangeset for help on using the changeset viewer.