User:Sanbeg/poem-nw.patch
--- /home/ssanbeg/wiki/Poem.php 2006-10-03 15:59:14.000000000 -0400 +++ extensions/Poem.php 2006-10-03 18:53:31.000000000 -0400 @@ -25,24 +25,37 @@
} function PoemExtension( $in, $param=array(), $parser=null ) {
- $text = preg_replace(
- array("/^\n/","/\n$/D","/\n/", "/^( +)/me"),
- array("", "", "
\n","str_replace(' ',' ','\\1')"),
- $in );
- $ret = $parser->parse(
- $text,
- $parser->mTitle,
- $parser->mOptions,
- // We begin at line start
- true,
- // Important, otherwise $this->clearState()
- // would get run every time <ref> or
- // <references> is called, fucking the whole
- // thing up.
- false
- );
-
+
global $wgVersion;
+ if( version_compare( $wgVersion, "1.8alpha" ) >= 0 ) {
+ #in 1.8, we can use internal hooks, so that nesting <nowiki> in
+ #<poem> will work.
+ $tag = $parser->insertStripItem("
\n", $parser->mStripState);
+ $text = preg_replace(
+ array("/^\n/","/\n$/D","/\n/", "/^( +)/me"),
+ array("", "", $tag,"str_replace(' ',' ','\\1')"),
+ $in );
+ $text = $parser->recursiveTagParse($text);
+ } else {
+ $text = preg_replace(
+ array("/^\n/","/\n$/D","/\n/", "/^( +)/me"),
+ array("", "", "
\n","str_replace(' ',' ','\\1')"),
+ $in );
+ $ret = $parser->parse(
+ $text,
+ $parser->mTitle,
+ $parser->mOptions,
+ // We begin at line start
+ true,
+ // Important, otherwise $this->clearState()
+ // would get run every time <ref> or
+ // <references> is called, fucking the whole
+ // thing up.
+ false
+ );
+
+ }
+
if( version_compare( $wgVersion, "1.7alpha" ) >= 0 ) { // Pass HTML attributes through to the output. $attribs = Sanitizer::validateTagAttributes( $param, 'div' );
@@ -60,7 +73,8 @@
return wfOpenElement( 'div', $attribs ) . "\n" .
- trim( $ret->getText() ) . + //trim( $ret->getText() ) . + trim($text).
"\n";
}