From 7f6a057dae76ddc639fd9a9d07e10620d1bd60a5 Mon Sep 17 00:00:00 2001 From: Jukka Svahn Date: Thu, 31 Oct 2013 15:11:24 +0200 Subject: [PATCH] Parser::doSpecial() uses named sub-patterns. See #121 --- src/Netcarver/Textile/Parser.php | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/src/Netcarver/Textile/Parser.php b/src/Netcarver/Textile/Parser.php index 821a37da..50982f63 100644 --- a/src/Netcarver/Textile/Parser.php +++ b/src/Netcarver/Textile/Parser.php @@ -2998,8 +2998,7 @@ protected function code($text) protected function fCode($m) { - list(, $before, $text, $after) = array_pad($m, 4, ''); - return $before.$this->shelve(''.$this->rEncodeHTML($text).'').$after; + return $m['before'].$this->shelve(''.$this->rEncodeHTML($m['content']).'').$m['after']; } /** @@ -3011,8 +3010,7 @@ protected function fCode($m) protected function fPre($m) { - list(, $before, $text, $after) = array_pad($m, 4, ''); - return $before.'
'.$this->shelve($this->rEncodeHTML($text)).'
'.$after; + return $m['before'].'
'.$this->shelve($this->rEncodeHTML($m['content'])).'
'.$m['after']; } /** @@ -3088,7 +3086,7 @@ protected function cleanWhiteSpace($text) protected function doSpecial($text, $start, $end, $method = 'fSpecial') { - return preg_replace_callback('/(^|\s|[|[({>])'.preg_quote($start, '/').'(.*?)'.preg_quote($end, '/').'(\s|$|[\])}|])?/ms', array(&$this, $method), $text); + return preg_replace_callback('/(?P^|\s|[|[({>])'.preg_quote($start, '/').'(?P.*?)'.preg_quote($end, '/').'(?P\s|$|[\])}|])?/ms', array(&$this, $method), $text); } /** @@ -3104,9 +3102,7 @@ protected function doSpecial($text, $start, $end, $method = 'fSpecial') protected function fSpecial($m) { - // A special block like notextile or code - list(, $before, $text, $after) = array_pad($m, 4, ''); - return $before.$this->shelve($this->encodeHTML($text)).$after; + return $m['before'].$this->shelve($this->encodeHTML($m['content'])).$m['after']; } /** @@ -3131,8 +3127,7 @@ protected function noTextile($text) protected function fTextile($m) { - list(, $before, $notextile, $after) = array_pad($m, 4, ''); - return $before.$this->shelve($notextile).$after; + return $m['before'].$this->shelve($m['content']).$m['after']; } /**