16 $parser->
setHook(
'poem', [ self::class,
'renderPoem' ] );
30 $newline = isset( $param[
'compact'] ) ?
'' :
"\n";
35 $text = preg_replace_callback(
'/^(:+)(.+)$/m', [ self::class,
'indentVerse' ], $in );
41 [
'/^\n/',
'/\n$/D',
'/(?<!^----)\n/m' ],
47 $text = preg_replace_callback(
'/^( +)/m', [ self::class,
'replaceSpaces' ], $text );
53 $text = str_replace(
'<hr />' . $tag,
'<hr />', $text );
55 $attribs = Sanitizer::validateTagAttributes( $param,
'div' );
58 if ( isset( $attribs[
'class'] ) ) {
59 $attribs[
'class'] =
'poem ' . $attribs[
'class'];
61 $attribs[
'class'] =
'poem';
64 return Html::rawElement(
'div', $attribs, $newline . trim( $text ) . $newline );
74 return str_replace(
' ',
' ', $m[1] );
86 'class' =>
'mw-poem-indented',
87 'style' =>
'display: inline-block; margin-left: ' . strlen( $m[1] ) .
'em;'
90 return Html::rawElement(
'span', $attribs, $m[2] );
PHP Parser - Processes wiki markup (which uses a more user-friendly syntax, such as "[[link]]" for ma...
setHook( $tag, callable $callback)
Create an HTML-style tag, e.g.
recursiveTagParse( $text, $frame=false)
Half-parse wikitext to half-parsed HTML.
insertStripItem( $text)
Add an item to the strip state Returns the unique tag which must be inserted into the stripped text T...
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.