Automatic PHP code highlighting

This commit is contained in:
Rami 2014-02-17 12:27:11 +01:00
parent bc30ad8e30
commit d39d84842d

View File

@ -688,6 +688,14 @@ class Parsedown
$markup .= ' class="language-'.$block['language'].'"'; $markup .= ' class="language-'.$block['language'].'"';
} }
if (!isset($block['language']) || strtolower($block['language']) == 'php') {
if (strpos($block['text'], '<?') === false) {
$block['text'] = "<?php\n" . $block['text'];
}
$code = highlight_string($block['text'], true);
$text = preg_replace('/\&lt;\?php/', '', $code);
}
$markup .= '>'.$text.'</code></pre>'."\n"; $markup .= '>'.$text.'</code></pre>'."\n";
break; break;