Extension:NoUnwrap

MediaWiki extensions manual
OOjs UI icon advanced.svg
NoUnwrap
Release status: unmaintained
Implementation Tag
Description text surrounded by <nounwrap></nounwrap> has its linefeeds left intact instead of unwrapping them into paragraphs
Author(s) (Justdavetalk)
Latest version 1.0 (2009-11-27)
MediaWiki 1.15
License public domain
Download No link
nounwrap
Check usage and version matrix.

What can this extension do?Edit

This extension adds a <nounwrap> tag that makes linefeeds within it get treated as linefeeds, while still performing all other wikitext processing. This is useful for copy/pasting large documents into a wiki page that need to be able to wordwrap or contain other wiki formatting without having to indent the entire thing or wrap it in <pre>

UsageEdit

<nounwrap>
line1
line2
line3
</nounwrap>

Download instructionsEdit

Please cut and paste the code found below and place it in $IP/extensions/nounwrap.php. Note: $IP stands for the root directory of your MediaWiki installation, the same directory that holds LocalSettings.php .

InstallationEdit

To install this extension, add the following to LocalSettings.php :

require_once("$IP/extensions/nounwrap.php");

CodeEdit

<?php
// MediaWiki nounwrap Extension Ver 1.0
// set up MediaWiki to react to the "<nounwrap>" tag
// created by David D. Miller
// released to the public domain 2009-Nov-27

$wgExtensionFunctions[] = 'efNoUnwrapSetup';
function efNoUnwrapSetup() {
        global $wgParser;
        $wgParser->setHook( "nounwrap", "RenderNoUnwrap" );
}
function RenderNoUnwrap( $input, $argv, &$parser ) {
     // <nounwrap>
     // line1
     // line2
     // </nounwrap>
     // linebreaks will be replaced with <br> so they won't unwrap
     // all other wikitext processing is still done.
     $output = str_replace("\n", "<br>\n", $input);
     $output = $parser->recursiveTagParse( $output );
     return $output;
}