From a3789983137f4476e8263c26be23edc2bedbc7e3 Mon Sep 17 00:00:00 2001 From: Krivchikov Dmitry Date: Tue, 29 Sep 2015 23:24:34 +0300 Subject: [PATCH] FIX headers --- ground/classes/Markdown.php | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/ground/classes/Markdown.php b/ground/classes/Markdown.php index 034db46..2f50c82 100644 --- a/ground/classes/Markdown.php +++ b/ground/classes/Markdown.php @@ -17,19 +17,17 @@ class Markdown static private function replaceHeaders($string) { - for ($index = 3; $index > 0; $index--) { + $pr = '(^#{1} (.{1,}))'; + $rep = '

$1

'; + $string = preg_replace($pr, $rep, $string); - $pr = '/(^#{' . $index . '} .{1,})/m'; + $pr = '(^#{2} (.{1,}))'; + $rep = '

$1

'; + $string = preg_replace($pr, $rep, $string); - preg_match_all($pr, $string, $headers); - - if (isset($headers[0][0])) { - foreach ($headers[0] as $header) { - $hI = $index+1; - $string = str_replace($header, "" . mb_substr($header, $index + 1, NULL, 'UTF-8') . "", $string); - } - } - } + $pr = '(^#{3} (.{1,}))'; + $rep = '

$1

'; + $string = preg_replace($pr, $rep, $string); return $string; }