Template:Format ISBN/doc

This template formats ISBNs. By convention, printed ISBNs use either hyphens or spaces to separate the elements within the number. The template accepts a string that represents an ISBN, and returns a formatted ISBN string. The input ISBN must be valid. That is:
 * it must be 10 or 13 characters long after removing any existing hyphen or space formatting; and
 * for 13 character ISBNs, all the characters must be digits, and it must start with 978 or 979;
 * for 10 character ISBNs, all the characters except the final one must be digits, and the final character must be either a digit or X;
 * and, the final character must be the correct check digit.

The formatted ISBN uses hyphens or spaces, with hyphens as the default. The default prefix is ISBN, but the prefix is settable. ISBNs with 10 characters may optionally be converted to equivalent 13 character ISBNs. For invalid input ISBNs, the error return value is settable, and the default is ISBN error.

Usage
Invoke with:

Parameters:
 * isbn: The ISBN to format. Must be supplied. Should be a valid 10 character or 13 character ISBN.
 * prefix: ISBN format prefix. Optional. Default is ISBN. If not empty, it is separated from the ISBN by.
 * use_spaces (or spaces): Indicate formatting with spaces instead of hyphens. Boolean. Optional. Default is false.
 * use_conversion (or convert): Convert 10 character ISBNs to 13 character ones before formatting. Boolean. Optional. Default is false. This parameter has no effect if the input ISBN is a 13 character one.
 * error: Return value to use in place of ISBN error. Optional.
 * use_link (or link): Link the displayed ISBN to Special:BookSources. Optional. Useful where prefix is not ISBN.

Parameters may also be supplied by position, in the order shown above. If using positional parameters, a shorthand way to set prefix to the empty string is to follow the positional isbn with a single pipe character. For example, equivalent to.

Examples

 * Using results in:
 * Using results in:
 * Using results in:
 * Using results in:
 * Using results in:
 * Using results in:
 * Using results in:
 * Using results in:
 * Using results in:

Canonical uses

 * To format an ISBN in article text:
 * Replace wikitext ISBN 978-1843560289 with to generate:
 * Alternatively, replace wikitext ISBN 978-1843560289 with ISBN to generate: ISBN
 * To format an ISBN in a book citation or other template with an parameter:
 * Replace wikitext with  to generate:

In all cases, ISBN magic links, wiki article categorisation, and so on will continue to work correctly. MediaWiki recognises and treats both formatted and unformatted valid ISBNs equivalently, and it checks for and triggers ISBN magic links only after all template and other processing is finished.