Index: Poem.php
===================================================================
--- Poem.php (revision 17861)
+++ Poem.php (working copy)
@@ -21,16 +21,28 @@
$wgExtensionFunctions[]="wfPoemExtension";
$wgExtensionCredits['parserhook'][] = array(
'name' => 'Poem',
- 'author' => 'Nikola Smolenski',
+ 'author' => 'Nikola Smolenski, Brion Vibber, Steve Sanbeg',
'description' => 'adds tag for poem formatting',
'url' => 'http://meta.wikimedia.org/wiki/Poem_Extension'
);
+$wgParserTestFiles[] = dirname( __FILE__ ) . "/lstpoemParserTests.txt";
function wfPoemExtension() {
$GLOBALS['wgParser']->setHook("poem","PoemExtension");
}
function PoemExtension( $in, $param=array(), $parser=null ) {
+
+ if (method_exists($parser, 'recursiveTagParse')) {
+ //new methods in 1.8 allow nesting in .
+ $tag = $parser->insertStripItem("
", $parser->mStripState);
+ $text = preg_replace(
+ array("/^\n/","/\n$/D","/\n/", "/^( +)/me"),
+ array("", "", "$tag\n","str_replace(' ',' ','\\1')"),
+ $in );
+ $text = $parser->recursiveTagParse($text);
+ } else {
+
$text = preg_replace(
array("/^\n/","/\n$/D","/\n/", "/^( +)/me"),
array("", "", "
\n","str_replace(' ',' ','\\1')"),
@@ -47,7 +59,9 @@
// thing up.
false
);
-
+ $text = $ret->getText();
+ }
+
global $wgVersion;
if( version_compare( $wgVersion, "1.7alpha" ) >= 0 ) {
// Pass HTML attributes through to the output.
@@ -66,7 +80,7 @@
return wfOpenElement( 'div', $attribs ) .
"\n" .
- trim( $ret->getText() ) .
+ trim( $text ) .
"\n";
}