Changeset 3511 for sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/class-markdown.php
- Timestamp:
- 06/20/2016 05:34:18 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/class-markdown.php
r3180 r3511 15 15 class Markdown extends \Michelf\MarkdownExtra { 16 16 17 /** 18 * @param string $text 19 * @return string 20 */ 17 21 public function transform( $text ) { 18 22 $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. 20 25 $text = preg_replace( '/^[\s]*=[\s]+(.+?)[\s]+=/m', "\n" . '<h4>$1</h4>' . "\n", $text ); 21 26 … … 25 30 } 26 31 32 /** 33 * @access protected 34 * 35 * @param string $text 36 * @return string 37 */ 27 38 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 */ 30 44 $text = preg_replace_callback( "!(<pre><code>|<code>)(.*?)(</code></pre>|</code>)!s", array( $this, 'code_trick_decodeit_cb' ), $text ); 31 45 $text = str_replace( array( "\r\n", "\r" ), "\n", $text ); 32 46 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. 34 48 $text = preg_replace_callback( "!(^|\n)([ \t]*?)`(.*?)`!s", array( $this, 'code_trick_indent_cb' ), $text ); 35 49 … … 37 51 } 38 52 53 /** 54 * @access protected 55 * 56 * @param array $matches 57 * @return string 58 */ 39 59 protected function code_trick_indent_cb( $matches ) { 40 60 $text = $matches[3]; … … 44 64 } 45 65 66 /** 67 * @access protected 68 * 69 * @param array $matches 70 * @return string 71 */ 46 72 protected function code_trick_decodeit_cb( $matches ) { 47 $text = $matches[2];48 73 $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( '&', '&', $text ); 52 $text = str_replace( ''', "'", $text ); 74 75 $text = $matches[2]; 76 $text = strtr( $text, $trans_table ); 77 $text = str_replace( '<br />', '', $text ); 78 $text = str_replace( '&', '&', $text ); 79 $text = str_replace( ''', "'", $text ); 53 80 54 81 if ( '<pre><code>' == $matches[1] ) {
Note: See TracChangeset
for help on using the changeset viewer.