Extension:Negref

MediaWiki extensions manual
Negref
Release status: unmaintained
Implementation Parser function
Description Provides a #negref parser function for negotiating the location of <ref> tags.
Author(s) Daniel Friesen (Dantmantalk)
Latest version 0.3.0 (2014-04-01)
MediaWiki
Database changes No
License GNU General Public License 2.0 or later
Download
Quarterly downloads 0
Translate the Negref extension if it is available at translatewiki.net

The Negref extension provides a #negref parser function with the ability to negotiate the location of <ref> tags within a chunk of WikiText. This parser function is primarily useful on semantic wiki, especially those using Semantic Forms, though it can also be very useful to a wiki that uses a lot of infobox like templates and likes to keep template parameters clean and simple.

Negref solves the problem of having template parameters you want to turn into some sort of link or semantic property but where the value may contain a <ref> tag. Instead of being forced to drop the ref tag, put it in another template parameter, or force people to hardcode the complex wikitext in articles the #negref parser function allows you to take a template parameter's value, and separate the ref tag from the rest of the value.

Usage

edit
{{#negref:wikitext to negotiate|token for data|token for ref tags|pattern}}

The first parameter to the negref parser function is the wikitext you want to negotiate the location of the ref tags inside. The next two parameters are replacement tokens for the data, and the ref tags, something like $s$ and $ref$ work, these tokens will be used with the following pattern. The final parameter is the pattern you want to put the data and the ref tags from the wikitext into. For example if your goal was to create a link from the data of a template parameter and you were trying to keep the ref tags outside of that link to prevent them from breaking the link you would use {{#negref:{{{template param|}}}|$s$|$ref$|[[$s$]]$ref$}}. Now if {{{template param|}}} contained something like FooBar<ref>Book of Baz</ref> the result would be [[FooBar]]<ref>Book of Baz</ref>. The value here beind that if you had instead used [[{{{template param|}}}]] the result would have been [[FooBar<ref>Book of Baz</ref>]] which of course would have broke the link.

Installation

edit
  • Download and move the extracted Negref folder to your extensions/ directory.
    Developers and code contributors should install the extension from Git instead, using:cd extensions/
    git clone https://gerrit.wikimedia.org/r/mediawiki/extensions/Negref
  • Add the following code at the bottom of your LocalSettings.php file:
    require_once "$IP/extensions/Negref/Negref.php";
    
  •   Done – Navigate to Special:Version on your wiki to verify that the extension is successfully installed.