Difference between revisions of "FormatISBN13"
From Sega Retro
m (Text replacement - "Category:Sega Retro templates" to "Category:Templates") |
|||
(6 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
− | <includeonly><div style="display:none;">{{#vardefine:isbn13raw|{{#replace:{{{1|}}}|- | + | <includeonly>{{#ifeq:{{{1}}}|none|N/A|<div style="display:none;">{{#if:{{{1|}}}|{{#vardefine:isbn13raw|{{#replace:{{{1|}}}|-|}}}}{{#vardefine:isbn13raw|{{#replace:{{#var:isbn13raw}}| |}}}} |
{{#ifexpr:{{#len:{{#var:isbn13raw}}}} != 13|[[Category:Incorrect ISBN-13]]|}} | {{#ifexpr:{{#len:{{#var:isbn13raw}}}} != 13|[[Category:Incorrect ISBN-13]]|}} | ||
− | |||
{{#vardefine:gs1|{{#sub:{{#var:isbn13raw}}|0|3}}}}{{#ifexpr:{{#var:gs1}} != 978 and {{#var:gs1}} != 979|}[[Category:Incorrect ISBN-13]]|}} | {{#vardefine:gs1|{{#sub:{{#var:isbn13raw}}|0|3}}}}{{#ifexpr:{{#var:gs1}} != 978 and {{#var:gs1}} != 979|}[[Category:Incorrect ISBN-13]]|}} | ||
− | + | {{#vardefine:isbn13region|{{#sub:{{#var:isbn13raw}}|3|1}}}} | |
− | {{#vardefine: | + | {{#ifexpr:{{#var:isbn13region}} > 4 and {{#var:isbn13region}} != 7 |
− | {{#ifexpr:{{#var: | + | |{{#vardefine:isbn13region|{{#sub:{{#var:isbn13raw}}|3|2}}}}{{#vardefine:isbn13etc|{{#sub:{{#var:isbn13raw}}|5|7}}}}{{#ifexpr:{{#var:isbn13region}} != 65 and ({{#var:isbn13region}} < 80 or {{#var:isbn13region}} > 94)|[[Category:ISBN-13 is probably wrong]]|}} |
− | |{{#vardefine: | + | |{{#vardefine:isbn13etc|{{#sub:{{#var:isbn13raw}}|4|8}}}} |
− | |{{#vardefine: | ||
}} | }} | ||
− | {{#vardefine: | + | {{#vardefine:isbn13checkdigit|{{#sub:{{#var:isbn13raw}}|12}}}} |
− | {{#vardefine:isbn13|{{#var:gs1}}-{{#var: | + | {{#vardefine:isbn13|{{#var:gs1}}-{{#var:isbn13region}}-{{#var:isbn13etc}}-{{#var:isbn13checkdigit}}}} |
− | </div>{{#ifeq:{{{link|}}}|yes|[http://www.worldcat.org/isbn/{{#var:isbn13}} {{#var:isbn13}}]|{{#var:isbn13}}}}</includeonly><noinclude> | + | </div>{{#ifeq:{{{link|}}}|yes|[http://www.worldcat.org/isbn/{{#var:isbn13}} {{#var:isbn13}}]|{{#var:isbn13}}}}}}|}}{{#vardefine:isbn13|}}{{#vardefine:gs1|}}{{#vardefine:isbn13raw|}}{{#vardefine:isbn13region|}}{{#vardefine:isbn13etc|}}{{#vardefine:isbn13checkdigit|}}</includeonly><noinclude> |
Template for formatting ISBN-13 numbers. Hypens and spaces are stripped out at the start. | Template for formatting ISBN-13 numbers. Hypens and spaces are stripped out at the start. | ||
Line 31: | Line 29: | ||
{{FormatISBN13|9785073 055501}} | {{FormatISBN13|9785073 055501}} | ||
− | [[Category: | + | [[Category:Templates]] |
</noinclude> | </noinclude> |
Latest revision as of 13:09, 1 January 2022
Template for formatting ISBN-13 numbers. Hypens and spaces are stripped out at the start.
The format for ISBN-13 is
[978/979]-[region]-[publisher]-[title]-[checkdigit]
the region is a fixed length (depending on where it came from), but the publisher and title fields can be any length, so they're currently grouped together.
Examples
{{FormatISBN13|978-4073055501|link=yes}}
{{FormatISBN13|9785073 055501}}
978-50-7305550-1