Skip to content

Commit

Permalink
Tweaked code processing
Browse files Browse the repository at this point in the history
  • Loading branch information
visoft committed Aug 13, 2012
1 parent e96daad commit ed29493
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions wp-markdown-syntax-sugar.php
Expand Up @@ -35,10 +35,14 @@
add_filter('get_the_excerpt', 'process_markdown', 7);

function process_markdown( $text ) {
return preg_replace( '|<pre><code>#!([^\\n]+)\n(.*?)</code></pre>|se', 'process_language(\'$2\',\'$1\');', $text);
return preg_replace( '|<pre><code>#!([^\n]+)\n(.*?)</code></pre>|se', 'process_language(\'$2\',\'$1\');', $text);
}

function process_language( $code, $language) {
$code = stripslashes( trim( htmlspecialchars_decode( $code, ENT_NOQUOTES ) ) );
if(strcasecmp($language, 'xml') == 0) {
$code = stripslashes( trim( str_replace(array('&amp;', '&#039;', '&quot;'), array('&','\'','"'), $code) ) );
} else {
$code = stripslashes( trim( htmlspecialchars_decode( $code, ENT_NOQUOTES ) ) );
}
return '<pre><code class="'. $language . '">' . $code . '</code></pre>';
}

0 comments on commit ed29493

Please sign in to comment.