13 $parser->setHook(
'poem', [
'Poem',
'renderPoem' ] );
28 $newline = isset( $param[
'compact'] ) ?
'' :
"\n";
33 $text = preg_replace_callback(
'/^(:+)(.+)$/m', [
'Poem',
'indentVerse' ], $in );
38 [
"/^\n/",
"/\n$/D",
"/\n/" ],
43 $text = preg_replace_callback(
'/^( +)/m', [
'Poem',
'replaceSpaces' ], $text );
45 $text =
$parser->recursiveTagParse( $text, $frame );
47 $attribs = Sanitizer::validateTagAttributes( $param,
'div' );
56 return Html::rawElement(
'div',
$attribs, $newline . trim( $text ) . $newline );
66 return str_replace(
' ',
' ', $m[1] );
78 'class' =>
'mw-poem-indented',
79 'style' =>
'display: inline-block; margin-left: ' . strlen( $m[1] ) .
'em;'
82 return Html::rawElement(
'span',
$attribs, $m[2] );
This class handles formatting poems in WikiText, specifically anything within <poem></poem> tags.
static renderPoem( $in, $param=[], $parser=null, $frame=false)
Parse the text into proper poem format.
static replaceSpaces( $m)
Callback for preg_replace_callback() that replaces spaces with non-breaking spaces.
static init(&$parser)
Bind the renderPoem function to the <poem> tag.
static indentVerse( $m)
Callback for preg_replace_callback() that wraps content in an indented span.
do that in ParserLimitReportFormat instead $parser
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped noclasses just before the function returns a value If you return an< a > element with HTML attributes $attribs and contents $html will be returned If you return $ret will be returned and may include noclasses after processing & $attribs