Trim leading newlines and trailing whitespace from code blocks.

This commit is contained in:
Michael Walker 2016-01-03 21:05:31 +00:00
parent b5532240c8
commit d46428b5b7

View File

@ -2085,6 +2085,8 @@ function markup(&$body, $track_cites = false) {
$code = isset($val[2]) ? $val[2] : $val[1];
$code_lang = isset($val[2]) ? $val[1] : "";
$code = rtrim(ltrim($code, "\r\n"));
$code = "<pre class='code lang-$code_lang'>".str_replace(array("\n","\t"), array("&#10;","&#9;"), htmlspecialchars($code))."</pre>";
$body = str_replace("<code $id>", $code, $body);