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:expandpagesresult|}}
+
<includeonly>{{clearvar|epresult}}{{#vardefine:epn|0}}{{#while:
{{#loop: chunknum
+
| {{#ifexpr: {{#len:{{#explode:{{{1}}}|,|{{#var:epn}}}}}} > 0 | true }}
|0
+
| {{#vardefine:chunk|{{#explode:{{{1}}}|,|{{#var:epn}}}}}}
|{{#expr:{{charcount|{{{1}}}|,}}+1}}
+
{{#vardefine:epresult|{{#if: {{#pos:{{#var:chunk}}|-}}
|{{#vardefine:chunk|{{#explode:{{{1}}}|,|{{#var:chunknum}}}}}}
+
  | {{#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}}}}
{{#if: {{#pos:{{#var:chunk}}|-}}
+
  | {{#var:epresult}},{{#var:chunk}}
  | {{#vardefine:s1|{{#explode:{{#var:chunk}}|-|0}}}}{{#vardefine:s2|{{#explode:{{#var:chunk}}|-|1}}}}
+
}}}}{{incvar|epn}}}}{{#sub:{{#var:epresult}}|1}}</includeonly><noinclude>
  {{#loop: s | {{#var:s1}} | {{#expr:{{#var:s2}}-{{#var:s1}}+1}} | {{#vardefine:expandpagesresult|{{#var:expandpagesresult}},{{#var:s}}}} }}
+
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.
  | {{#vardefine:expandpagesresult|{{#var:expandpagesresult}},{{#var:chunk}}}}
 
}}
 
}}{{#vardefine:expandpagesresult|{{#sub:{{#var:expandpagesresult}}|1}}}}{{#var:expandpagesresult}}</includeonly><noinclude>
 
Convert a range of pages given by the format "a-c" into a format PdfHandler Classic can cope with. That is, "a-c" becomes a,b,c.
 
  
 
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.