mirror of
https://github.com/erusev/parsedown.git
synced 2024-09-20 03:51:29 +02:00
Automatic PHP code highlighting
This commit is contained in:
parent
bc30ad8e30
commit
d39d84842d
@ -688,6 +688,14 @@ class Parsedown
|
||||
$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('/\<\?php/', '', $code);
|
||||
}
|
||||
|
||||
$markup .= '>'.$text.'</code></pre>'."\n";
|
||||
|
||||
break;
|
||||
|
Loading…
Reference in New Issue
Block a user