Making WordPress.org


Ignore:
Timestamp:
06/20/2016 05:34:18 PM (9 years ago)
Author:
obenland
Message:

Plugin Directory: Documentation and formatting updates.

See #1584.

File:
1 edited

Legend:

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

    r3180 r3511  
    1515class Markdown extends \Michelf\MarkdownExtra {
    1616
     17    /**
     18     * @param string $text
     19     * @return string
     20     */
    1721    public function transform( $text ) {
    1822        $text = $this->code_trick( trim( $text ) );
    19         // Convert any `= Section =` headers into a real header
     23
     24        // Convert any `= Section =` headers into a real header.
    2025        $text = preg_replace( '/^[\s]*=[\s]+(.+?)[\s]+=/m', "\n" . '<h4>$1</h4>' . "\n", $text );
    2126
     
    2530    }
    2631
     32    /**
     33     * @access protected
     34     *
     35     * @param string $text
     36     * @return string
     37     */
    2738    protected function code_trick( $text ) {
    28         // when doing markdown, first take any user formatted code blocks and turn them into backticks so that
    29         // markdown will preserve things like underscores in code blocks
     39
     40        /*
     41         * When doing markdown, first take any user formatted code blocks and turn them into backticks so that
     42         * markdown will preserve things like underscores in code blocks.
     43         */
    3044        $text = preg_replace_callback( "!(<pre><code>|<code>)(.*?)(</code></pre>|</code>)!s", array( $this, 'code_trick_decodeit_cb' ), $text );
    3145        $text = str_replace( array( "\r\n", "\r" ), "\n", $text );
    3246
    33         // Markdown can do inline code, we convert bbPress style block level code to Markdown style
     47        // Markdown can do inline code, we convert bbPress style block level code to Markdown style.
    3448        $text = preg_replace_callback( "!(^|\n)([ \t]*?)`(.*?)`!s", array( $this, 'code_trick_indent_cb' ), $text );
    3549
     
    3751    }
    3852
     53    /**
     54     * @access protected
     55     *
     56     * @param array $matches
     57     * @return string
     58     */
    3959    protected function code_trick_indent_cb( $matches ) {
    4060        $text = $matches[3];
     
    4464    }
    4565
     66    /**
     67     * @access protected
     68     *
     69     * @param array $matches
     70     * @return string
     71     */
    4672    protected function code_trick_decodeit_cb( $matches ) {
    47         $text        = $matches[2];
    4873        $trans_table = array_flip( get_html_translation_table( HTML_ENTITIES ) );
    49         $text        = strtr( $text, $trans_table );
    50         $text        = str_replace( '<br />', '', $text );
    51         $text        = str_replace( '&#38;', '&', $text );
    52         $text        = str_replace( '&#39;', "'", $text );
     74
     75        $text = $matches[2];
     76        $text = strtr( $text, $trans_table );
     77        $text = str_replace( '<br />', '', $text );
     78        $text = str_replace( '&#38;', '&', $text );
     79        $text = str_replace( '&#39;', "'", $text );
    5380
    5481        if ( '<pre><code>' == $matches[1] ) {
Note: See TracChangeset for help on using the changeset viewer.