summaryrefslogtreecommitdiff
path: root/inc
diff options
context:
space:
mode:
authorMichael Walker <mike@barrucadu.co.uk>2016-01-03 21:05:31 +0000
committerMichael Walker <mike@barrucadu.co.uk>2016-01-03 21:05:31 +0000
commitd46428b5b765f921b4cb633808f22ef303516c62 (patch)
tree2bf0bba4b281b73107c74fa36d9fe7fb3ad48f10 /inc
parentb5532240c88e2555d82c3fe9ba8e7f0e0fc89418 (diff)
Trim leading newlines and trailing whitespace from code blocks.
Diffstat (limited to 'inc')
-rwxr-xr-xinc/functions.php2
1 files changed, 2 insertions, 0 deletions
diff --git a/inc/functions.php b/inc/functions.php
index cd1f8fde..ff5d51df 100755
--- a/inc/functions.php
+++ b/inc/functions.php
@@ -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);