From 10ee07db0d11ec050ef4d643c4c47bcd2c2529ec Mon Sep 17 00:00:00 2001 From: Sam Minnee Date: Sun, 14 Dec 2008 23:57:07 +0000 Subject: [PATCH] Improved rendering of [php] tags in BBCode view git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/branches/2.3@68873 467b73ca-7a2a-4603-9d3b-597d59a354a9 --- parsers/BBCodeParser.php | 4 ++++ parsers/HTML/BBCodeParser/Filter/Extended.php | 8 ++++---- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/parsers/BBCodeParser.php b/parsers/BBCodeParser.php index b35d93282..f69c26797 100644 --- a/parsers/BBCodeParser.php +++ b/parsers/BBCodeParser.php @@ -107,6 +107,10 @@ class BBCodeParser extends TextParser { $this->content = str_replace(array('&', '<', '>'), array('&', '<', '>'), $this->content); $this->content = SSHTMLBBCodeParser::staticQparse($this->content); $this->content = "

".$this->content."

"; + + $this->content = preg_replace('/(]*>)\s+/i', '\\1', $this->content); + $this->content = preg_replace('/\s+(<\/p[^>]*>)/i', '\\1', $this->content); + $this->content = preg_replace("/\n\s*\n/", "

", $this->content); $this->content = str_replace("\n", "
", $this->content); return $this->content; diff --git a/parsers/HTML/BBCodeParser/Filter/Extended.php b/parsers/HTML/BBCodeParser/Filter/Extended.php index 7f49dafc9..9858ad4c9 100644 --- a/parsers/HTML/BBCodeParser/Filter/Extended.php +++ b/parsers/HTML/BBCodeParser/Filter/Extended.php @@ -65,12 +65,12 @@ class SSHTMLBBCodeParser_Filter_Extended extends SSHTMLBBCodeParser_Filter 'htmlclose' => 'q', 'allowed' => 'all', 'attributes'=> array('quote' =>'cite=%2$s%1$s%2$s')), - 'code' => array('htmlopen' => 'div class="codesnippet"', - 'htmlclose' => 'div', + 'code' => array('htmlopen' => 'div class="codesnippet"> 'p> 'all', 'attributes' => array()), - 'php' => array('htmlopen' => 'div class="codesnippet"', - 'htmlclose' => 'div', + 'php' => array('htmlopen' => 'div class="codesnippet"> 'p> 'all', 'attributes' => array()), 'h1' => array('htmlopen' => 'h1',