User:Nardog/SmartDiff

This script turns wikilinks, external links, and template/module calls in a diff into clickable links. It shows links to nonexistent pages in red, and keeps the linked part to a minimum to avoid WP:SEAOFBLUE, unlike fancy-diffs (further comparison).

Installation
Add the following to your common.js or global.js:

Or you may enable the script installer in and click "Install" in the infobox on this page.

Template parameter linking
You can instruct the script to link certain unnamed parameters in templates, so e.g. appears as. This is useful for linking templates like tl and hatnotes like About. Linking of named parameters is not supported, and the template call and parameters must be in the same line for the latter to be linked.

To do it, add code like below to your common.js (templates vary by wiki, so even if you have installed the script globally, it is recommended to have different code on each wiki).

Example
Here is an example based on templates on English Wikipedia.

Schema
The objects can have the following properties (only  is required):


 * (array of strings)
 * Template names to apply this object to. Must be well-formed names (no, no underscores, start with a capital letter except on Wiktionary). Redirects are not resolved, so include all you expect to find.


 * , (number);, (boolean)
 * Specify the range of parameters to link. If omitted, all unnamed parameters will be linked.


 * (number)
 * Namespace number for the link.


 * (boolean)
 * If, the namespace prefix will be added even if the input begins with a valid namespace prefix (so e.g.  is linked correctly).


 * , (string)
 * String to prepend or append to the input.  is useful for linking to a special page or sister site.


 * , (number)
 * Specify the range of parameters to suppress redirects (by adding  to the URL) in.

Magic words
If you want the script to recognize certain magic words it does not by default and stop linking them as templates, you can do so by adding code like below to your common.js or global.js. This example adds localized variables for  and   in Polish (a trailing colon is required if the magic word accepts a variable).

Comparison with fancy-diffs
This script owes a great debt to Enterprisey's fancy-diffs in its concept, and makes improvements on it. Differences include:


 * Shows links to nonexistent pages.
 * Links only  and , avoiding WP:SEAOFBLUE.
 * Links section headings (e.g. ).
 * Recognizes template names without  in the same line (e.g.  ).
 * Recognizes relative links to and transclusions of subpages (e.g. ).
 * Does not mistake common magic words and template parameters (,, etc.) for template calls.
 * Supports customizable linking of unnamed parameters in templates (e.g., )—see above.
 * Links content inside  in multilingual wikis, as in.
 * Shows external and interwiki links in the same color as in the page body.
 * Adds to links to redirects and disambiguation pages the respective  and   classes, so if you style them in your CSS (or use the gadget ""), they appear the same as in the page body.
 * Verifies the result after processing each line, so it will never alter the substance of a diff even if it makes a mistake (and notifies you in such an event so you can report it).
 * Does not support image previews.

Limitations

 * The detection/retrieval of red links and link classes is capped at 500 unique page names (10 API calls) per diff.