Extension:Poem

The Poem extension makes a text a separate paragraph, with after every line, i.e., it suppresses reformatting of a single newline to a blank space.

This allows for easy inclusion of poems and similar material in MediaWiki pages, by simply putting them between &lt;poem></poem&gt; tags, instead of adding &lt;br&gt; to the end or : to the beginning of every line, which is common practice now. Though small, it might be useful, especially on Wikisource or similar projects (there are poems with thousands of lines, so obviously using isn't practical). The extension preserves wikilinks, bolding, etc. if they are present in the poem, as well as indenting lines which start with spaces.

Nikola Smolenski made the extension in order to practice working on extensions, after an idea by Yann Forget.

It was activated on Wikisource and tested on 2006-06-23, and on the rest of the project sites on 2007-02-07.

Style
The poem text is wrapped in a div, which has no style by default; but inherits any style or class option passed to the poem.

For example, while indented text can be used for simple examples to prevent filling and draw a nice blue box, it can be hard to read in some cases, since long lines aren't broken. A similar, but somewhat better effect can be obtained with  When applied to the above example, the result is as follows:  In Xanadu did Kubla Khan A stately pleasure-dome decree: Where Alph, the sacred river, ran Through caverns measureless to man Down to a sunless sea.

So twice five miles of fertile ground With walls and towers were girdled round: And there were gardens bright with sinuous rills, Where blossomed many an incense-bearing tree; And here were forests ancient as the hills, Enfolding sunny spots of greenery.

"compact" option
Applying the tag with the compact option to a text of more than two lines, every line becomes a separate paragraph. (This seems to be a bug, as it is opposite to what the term suggests.)

Subsequent use of the tag with the compact option, with up to two newlines in between, gives just a single newline between texts, not a new paragraph. Thus, applied to texts of more than two lines each, every line becomes a separate paragraph, except that the last line of each text and the first line of the next text are combined into one paragraph.

Problems and solutions

 * Variables and ParserFunctions do work inside the ... container, but NOT within the  tag itself ; this prevents templates with code such as .
 * One workaround is to use  ... instead.
 * Another way is to use the  magic word:.
 * NB: this would however seem not to work with the "compact" option.

Installation

 * 1) Download the files from Git or download a snapshot (select your version of MediaWiki) and place the files under $IP/extensions/Poem
 * 2) Add to the end of LocalSettings.php:
 * 3) Installation can now be verified through Special:Version on your wiki