Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3389
poem.patch
Public
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Authored By
•
bzimport
Nov 21 2014, 9:28 PM
2014-11-21 21:28:24 (UTC+0)
Size
1 KB
Referenced Files
None
Subscribers
None
poem.patch
View Options
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(' ',' ','\\1')"),
+ $in );
+ $text = $parser->recursiveTagParse($text);
+ } else {
+
$text = preg_replace(
array("/^\n/","/\n$/D","/\n/", "/^( +)/me"),
array("", "", "<br />\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</div>";
}
File Metadata
Details
Attached
Mime Type
text/x-diff
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2957
Default Alt Text
poem.patch (1 KB)
Attached To
Mode
T9503: poem doesn't work with nested nowiki
Attached
Detach File
Event Timeline
Log In to Comment