Extension:NoUnwrap

From MediaWiki.org
Jump to: navigation, search
MediaWiki extensions manual - list
Crystal Clear action run.png
NoUnwrap

Release status: beta

Implementation Tag
Description text surrounded by <nounwrap></nounwrap> has its linefeeds left intact instead of unwrapping them into paragraphs
Last version 1.0 (2009-Nov-27)
MediaWiki 1.15
License public domain
Download No link
Tags
nounwrap

Check usage (experimental)

Contents

[edit] What can this extension do?

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>

[edit] Usage

<nounwrap>
line1
line2
line3
</nounwrap>

[edit] Download instructions

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.

[edit] Installation

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

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

[edit] Code

<?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;
 }
Personal tools
Namespaces

Variants
Actions
Navigation
Support
Download
Development
Communication
Print/export
Toolbox