16 $parser->setHook(
'poem', [ self::class,
'renderPoem' ] );
30 $newline = isset( $param[
'compact'] ) ?
'' :
"\n";
32 $tag =
$parser->insertStripItem(
"<br />" );
35 $text = preg_replace_callback(
'/^(:+)(.+)$/m', [ self::class,
'indentVerse' ], $in );
40 [
"/^\n/",
"/\n$/D",
"/\n/" ],
46 $text = preg_replace_callback(
'/^( +)/m', [ self::class,
'replaceSpaces' ], $text );
48 $text =
$parser->recursiveTagParse( $text, $frame );
50 $attribs = Sanitizer::validateTagAttributes( $param,
'div' );
59 return Html::rawElement(
'div',
$attribs, $newline . trim( $text ) . $newline );
69 return str_replace(
' ',
' ', $m[1] );
81 'class' =>
'mw-poem-indented',
82 'style' =>
'display: inline-block; margin-left: ' . strlen( $m[1] ) .
'em;'
85 return Html::rawElement(
'span',
$attribs, $m[2] );
PHP Parser - Processes wiki markup (which uses a more user-friendly syntax, such as "[[link]]" for ma...
This class handles formatting poems in WikiText, specifically anything within <poem></poem> tags.
static replaceSpaces(array $m)
Callback for preg_replace_callback() that replaces spaces with non-breaking spaces.
static indentVerse(array $m)
Callback for preg_replace_callback() that wraps content in an indented span.
static renderPoem( $in, array $param=[], Parser $parser, PPFrame $frame)
Parse the text into proper poem format.
static init(Parser $parser)
Bind the renderPoem function to the <poem> tag.
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