Template:Normalize volume and edition/doc
| This is a documentation subpage for Template:Normalize volume and edition. It may contain usage information, categories and other content that is not part of the original template page. |
| This template uses Lua: |
This module normalizes unformatted text input for |volume= and |edition= parameters. It can, for example, allow templates to reliably route citation data using `#switch` statements.
Example: values that normalize as 1 (not exhaustive):
1, 1st, one, first, I, i, uno, un, una, primer, primera, 1ª, premier, première, ein, eine, eins, erste, een, eerste, primo, prima, primus, 初版, 第1巻, (1), [1], "1", 1., -1-, Volume 1, Vol 1, Vol. 1, Book 1, Part 1, 1 (Print), v. 1, v 1, v. I, ed. 1, first edition, edition 1
Usage
[edit]To use this module, invoke it with either the `volume` or `edition` function, followed by the raw parameter data.
Normalizing |edition=Uno
{{#switch:{{#invoke:Normalize volume and edition|edition|{{{edition|}}}}}
| 1 = {{#invoke:IA Citation|BOOK_NAME_FIRST}}
| 2 | #default = {{#invoke:IA Citation|BOOK_NAME_SECOND}}
}}
Normalizing |volume=Vol 1
{{#switch:{{#invoke:Normalize volume and edition|volume|{{{volume|}}}}}
| 1 = {{#invoke:IA Citation|MULTI_VOL_BOOK_V1}}
| 2 = {{#invoke:IA Citation|MULTI_VOL_BOOK_V2}}
| 3 = {{#invoke:IA Citation|MULTI_VOL_BOOK_V3}}
| #default = {{#invoke:IA Citation|MULTI_VOL_BOOK_V1}}
}}
Supported Inputs
[edit]This template accepts raw, unformatted text added by editors in the |volume= and |edition= fields and normalizes it into a single-character digit or letter for use in `#switch` statements in templates that need to route based on vol. and ed. It is case-insensitive and ignores punctuation.
| Raw User Input Example | Type Passed | Normalized Output | Explanation |
|---|---|---|---|
1 | Volume or Edition | 1 | Pure digits pass through. |
Vol. 2 | Volume | 2 | "Vol." is ignored; digit is extracted. |
Volume 3 of 5 | Volume | 3 | Stops at the first recognized digit. |
v. 4 | Volume | 4 | Ignores "v." abbreviation. |
First | Volume or Edition | 1 | Spelled words (1-10) map to digits. |
2nd ed. | Edition | 2 | Ordinals map to digits; "ed." is ignored. |
Second Edition | Edition | 2 | Words map to digits; "edition" is ignored. |
Part III | Volume | 3 | Roman numerals (I-X) map to digits. |
Book iv | Volume | 4 | Case-insensitive Roman numerals. |
Part A | Volume | A | Isolated letters pass through as uppercase. |
Section b | Volume | B | Lowercase letters converted to uppercase. |