Page MenuHomePhabricator

poem.patch

Authored By
bzimport
Nov 21 2014, 9:28 PM
Size
1 KB
Referenced Files
None
Subscribers
None

poem.patch

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 <nowiki><poem></nowiki> 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 <nowiki> in <poem>.
+ $tag = $parser->insertStripItem("<br />", $parser->mStripState);
+ $text = preg_replace(
+ array("/^\n/","/\n$/D","/\n/", "/^( +)/me"),
+ array("", "", "$tag\n","str_replace(' ','&nbsp;','\\1')"),
+ $in );
+ $text = $parser->recursiveTagParse($text);
+ } else {
+
$text = preg_replace(
array("/^\n/","/\n$/D","/\n/", "/^( +)/me"),
array("", "", "<br />\n","str_replace(' ','&nbsp;','\\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</div>";
}

File Metadata

Mime Type
text/x-diff
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2957
Default Alt Text
poem.patch (1 KB)

Event Timeline