# HG changeset patch # User Dan # Date 1249795665 14400 # Node ID 67a4c839c7e1110b306aa57e3ee19d40f73d2eea # Parent 7f621a3a9cbf526e81d1a7a8679d57dd8c34b4c8 Blockquote functionality in wikitext parser now allows rendering of other block level elements properly diff -r 7f621a3a9cbf -r 67a4c839c7e1 includes/wikiengine/parse_mediawiki.php --- a/includes/wikiengine/parse_mediawiki.php Sun Aug 09 01:26:57 2009 -0400 +++ b/includes/wikiengine/parse_mediawiki.php Sun Aug 09 01:27:45 2009 -0400 @@ -22,6 +22,8 @@ 'externalnotext' => '#\[((?:https?|irc|ftp)://.+?)\]#' ); + private $blockquote_rand_id; + public function lang(&$text) { global $lang; @@ -152,15 +154,24 @@ public function blockquote(&$text) { - if ( !preg_match_all('/^(?:(>+) *.+(?:\r?\n|$))+/m', $text, $quotes) ) - return array(); - - $pieces = array(); - foreach ( $quotes[0] as $quote ) - $pieces[] = "\t" . trim(preg_replace('/^>+ */m', "\t", $quote)); + $rand_id = hexencode(AESCrypt::randkey(16), '', ''); - $text = Carpenter::tokenize($text, $quotes[0]); - return $pieces; + while ( preg_match_all('/^(?:(>+) *.+(?:\r?\n|$))+/m', $text, $quotes) ) + { + foreach ( $quotes[0] as $quote ) + { + $piece = trim(preg_replace('/^> */m', '', $quote)); + $text = str_replace_once($quote, "{blockquote:$rand_id}\n$piece\n{/blockquote:$rand_id}\n", $text); + } + } + //die('
' . htmlspecialchars($text) . '
'); + + $this->blockquote_rand_id = $rand_id; + } + + public function blockquotepost(&$text) + { + return $this->blockquote_rand_id; } public function paragraph(&$text) diff -r 7f621a3a9cbf -r 67a4c839c7e1 includes/wikiengine/render_xhtml.php --- a/includes/wikiengine/render_xhtml.php Sun Aug 09 01:26:57 2009 -0400 +++ b/includes/wikiengine/render_xhtml.php Sun Aug 09 01:27:45 2009 -0400 @@ -114,12 +114,23 @@ return $text; } - public function blockquote($text, $pieces) + public function blockquote($text) + { + return $text; + } + + public function blockquotepost($text, $rand_id) { - foreach ( $pieces as $i => $piece ) - { - $text = str_replace(Carpenter::generate_token($i), "
\n" . nl2br($piece) . "\n
\n", $text); - } + $text = strtr($text, array( + "

{blockquote:$rand_id}
" => '

', + "
\n{/blockquote:$rand_id}

" => '
', + "{blockquote:$rand_id}" => '
', + "{/blockquote:$rand_id}" => '
' + )); + $text = strtr($text, array( + "

" => '
', + "

" => '
' + )); return $text; } diff -r 7f621a3a9cbf -r 67a4c839c7e1 includes/wikiformat.php --- a/includes/wikiformat.php Sun Aug 09 01:26:57 2009 -0400 +++ b/includes/wikiformat.php Sun Aug 09 01:27:45 2009 -0400 @@ -60,11 +60,11 @@ private $rules = array( 'lang', 'templates', + 'blockquote', 'tables', 'heading', // note: can't be named list ("list" is a PHP language construct) 'multilist', - 'blockquote', 'bold', 'italic', 'underline', @@ -72,7 +72,8 @@ 'externalnotext', 'image', 'internallink', - 'paragraph' + 'paragraph', + 'blockquotepost' ); /**