Difference between revisions of "Expandpages"
From Sega Retro
(Created page with "<includeonly>{{#vardefine:expandpagesresult|}} {{#loop: chunknum |0 |{{#expr:{{charcount|{{{1}}}|,}}+1}} |{{#vardefine:chunk|{{#explode:{{{1}}}|,|{{#var:chunknum}}}}}} {{#if:...") |
|||
Line 1: | Line 1: | ||
− | <includeonly>{{#vardefine: | + | <includeonly>{{clearvar|epresult}}{{#vardefine:epn|0}}{{#while: |
− | {{# | + | | {{#ifexpr: {{#len:{{#explode:{{{1}}}|,|{{#var:epn}}}}}} > 0 | true }} |
− | + | | {{#vardefine:chunk|{{#explode:{{{1}}}|,|{{#var:epn}}}}}} | |
− | |{{# | + | {{#vardefine:epresult|{{#if: {{#pos:{{#var:chunk}}|-}} |
− | |{{#vardefine:chunk|{{#explode:{{{1}}}|,|{{#var: | + | | {{#var:epresult}}{{#vardefine:s1|{{#explode:{{#var:chunk}}|-|0}}}}{{#vardefine:s2|{{#explode:{{#var:chunk}}|-|1}}}}{{#loop: s | {{#var:s1}} | {{#expr:{{#var:s2}}-{{#var:s1}}+1}} | ,{{#var:s}}}} |
− | + | | {{#var:epresult}},{{#var:chunk}} | |
− | | {{#vardefine:s1|{{#explode:{{#var:chunk}}|-|0}}}}{{#vardefine:s2|{{#explode:{{#var:chunk}}|-|1}}}} | + | }}}}{{incvar|epn}}}}{{#sub:{{#var:epresult}}|1}}</includeonly><noinclude> |
− | + | Convert a range of pages given by the format "a-c" into a format the [[Template:Gallery|gallery template]] can cope with. That is, "a-c" becomes a,b,c. | |
− | |||
− | |||
− | }}{{ | ||
− | Convert a range of pages given by the format "a-c" into a format | ||
Example: <nowiki>{{expandpages|12-14}}</nowiki> becomes {{expandpages|12-14}}. | Example: <nowiki>{{expandpages|12-14}}</nowiki> becomes {{expandpages|12-14}}. |
Revision as of 20:12, 17 September 2018
Convert a range of pages given by the format "a-c" into a format the gallery template can cope with. That is, "a-c" becomes a,b,c.
Example: {{expandpages|12-14}} becomes 12,13,14.
Example: {{expandpages|12-14,17,20-21}} becomes 12,13,14,17,20,21.