From b9ab495cb4f38c2c50c417eb18e94df750979ff0 Mon Sep 17 00:00:00 2001 From: Emanuil Rusev Date: Thu, 16 Jan 2014 23:43:34 +0200 Subject: [PATCH] parse method doesn't have to use regex --- Parsedown.php | 19 +++---------------- 1 file changed, 3 insertions(+), 16 deletions(-) diff --git a/Parsedown.php b/Parsedown.php index ff55e5b..e461dc6 100755 --- a/Parsedown.php +++ b/Parsedown.php @@ -59,9 +59,6 @@ class Parsedown function parse($text) { - # removes UTF-8 BOM and marker characters - $text = preg_replace('{^\xEF\xBB\xBF|\x1A}', '', $text); - # removes \r characters $text = str_replace("\r\n", "\n", $text); $text = str_replace("\r", "\n", $text); @@ -90,7 +87,6 @@ class Parsedown # ~ - $text = preg_replace('/\n\s*\n/', "\n\n", $text); $text = trim($text, "\n"); $lines = explode("\n", $text); @@ -175,7 +171,9 @@ class Parsedown # * - if ($line === '') + $deindented_line = ltrim($line); + + if ($deindented_line === '') { $element['interrupted'] = true; @@ -255,21 +253,10 @@ class Parsedown # indentation sensitive types - $deindented_line = $line; - switch ($line[0]) { case ' ': - # ~ - - $deindented_line = ltrim($line); - - if ($deindented_line === '') - { - continue 2; - } - # code block if (isset($line[3]) and $line[3] === ' ' and $line[2] === ' ' and $line[1] === ' ')