diff --git a/inc/functions.php b/inc/functions.php index 76b44cb3..54e3a287 100644 --- a/inc/functions.php +++ b/inc/functions.php @@ -284,7 +284,10 @@ function markup(&$body) { global $board; - + + if(MARKUP_URLS) + $body = preg_replace(URL_REGEX, "$0", $body); + if(AUTO_UNICODE) { $body = str_replace('...', '…', $body); $body = str_replace('<--', '←', $body); @@ -321,22 +324,24 @@ // Find the position of the cite $position = strpos($body, $cites[0][$index]); + + + // Replace the found string with "xxxx[...]". (allows duplicate tags). Keeps whitespace. $body = substr_replace($body, str_repeat('x', strlen($cites[0][$index]) - $whitespace[0] - $whitespace[1]), $position + $whitespace[0], strlen($cites[0][$index]) - $whitespace[0] - $whitespace[1]); - + $temp .= substr($body, $previousPosition, $position-$previousPosition) . $cites[1][$index] . $replacement . $cites[3][$index]; $previousPosition = $position+strlen($cites[0][$index]); } + // The rest $temp .= substr($body, $previousPosition); - + $body = $temp; } $body = str_replace("\r", '', $body); - - if(MARKUP_URLS) - $body = preg_replace(URL_REGEX, "$0", $body); + $body = preg_replace("/(^|\n)([\s]+)?(>)([^\n]+)?($|\n)/m", '$1$2$3$4$5', $body); if(WIKI_MARKUP) {