Template:List normalize: Difference between revisions
Jump to navigation
Jump to search
(+remove blank list entries) |
m (+strip leading/trailing delimiter) |
||
Line 2: | Line 2: | ||
><!-- Set Parameter Space Clean-up.//List_Cleanup. | ><!-- Set Parameter Space Clean-up.//List_Cleanup. | ||
- Input: string, intended to be used in SMW '#set' with 'sep=,' parameter. | - Input: string/list, intended to be used in SMW '#set' with 'sep=,' parameter. | ||
- | - List delimiter: comma. (currently fixed, can be made variable when needed) | ||
- Turns | - Turns consecutive spaces into one. (current max:4) | ||
- Side effect: Converts underscores in input to spaces in output. (after, not before) | - Turns consecutive delimiter's into one. (current max:4) | ||
- Strips leading/trailing delimiter's. (current max:3 (otherMax-1)) | |||
- Side effect: Converts underscores in input to spaces in output. (after cleanup, not before) | |||
-- Not sure yet about turning underscores to spaces at the start. | -- Not sure yet about turning underscores to spaces at the start. | ||
-- Related code: | -- Related code: | ||
#replace:{{ | #replace:{{ | ||
#replace:{{{1|}}}||• | #replace:,{{{1|}}},||• | ||
}}|_|• | }}|_|• | ||
- Open/issue: line-breaks. (other list-stuff trips over them) | |||
- -> | - -> | ||
:+1) cond: {{#ifeq: {{list_normalize | a,b,c }} | a,b,c | <span style="color:green;">Pass</span> | <span style="color:red;">Fail</span> }} | :+1) cond: {{#ifeq: {{list_normalize | a,b,c }} | a,b,c | <span style="color:green;">Pass</span> | <span style="color:red;">Fail</span> }} | ||
:+2) norm: {{#ifeq: {{list_normalize | a, b, c }} | a,b,c | <span style="color:green;">Pass</span> | <span style="color:red;">Fail</span> }} | :+2) norm: {{#ifeq: {{list_normalize | a, b, c }} | a,b,c | <span style="color:green;">Pass</span> | <span style="color:red;">Fail</span> }} | ||
:+3) wide: {{#ifeq: {{list_normalize | x y , z }} | x y,z | <span style="color:green;">Pass</span> | <span style="color:red;">Fail</span> }} | :+3) wide: {{#ifeq: {{list_normalize | x y , z }} | x y,z | <span style="color:green;">Pass</span> | <span style="color:red;">Fail</span> }} | ||
:+4) blank: {{#ifeq: {{list_normalize | a ,,,, b }} | a,b | <span style="color:green;">Pass</span> | <span style="color:red;">Fail</span> }} | :+4) blank: {{#ifeq: {{list_normalize | a ,,,, b }} | a,b | <span style="color:green;">Pass</span> | <span style="color:red;">Fail</span> }} | ||
:+5) undsc: {{#ifeq: {{list_normalize | x __y__ z }} | x y z | <span style="color:green;">Pass</span> | <span style="color:red;">Fail</span> }} | :+5) blank: {{#ifeq: {{list_normalize | ,,,a,b,,, }} | a,b | <span style="color:green;">Pass</span> | <span style="color:red;">Fail</span> }} | ||
: | :+6) undsc: {{#ifeq: {{list_normalize | x __y__ z }} | x y z | <span style="color:green;">Pass</span> | <span style="color:red;">Fail</span> }} | ||
:x7) undsc: {{#ifeq: {{list_normalize | x __y__ z }} | x y z | <span style="color:green;">Pass</span> | <span style="color:red;">Fail</span> }} | |||
--></noinclude><includeonly | --></noinclude><includeonly | ||
Line 25: | Line 31: | ||
| {{ | | {{ | ||
str_us2sp|{{ | str_us2sp|{{ | ||
#sub:{{ | |||
#replace:{{ | #replace:{{ | ||
#replace:{{ | #replace:{{ | ||
Line 32: | Line 39: | ||
#replace:{{ | #replace:{{ | ||
#replace:{{ | #replace:{{ | ||
#replace:{{{1 | #replace:,{{{1}}},||• | ||
}}|••|• | }}|••|• | ||
}}|••|• | }}|••|• | ||
Line 40: | Line 47: | ||
}}|,,|, | }}|,,|, | ||
}}|,,|, | }}|,,|, | ||
}}|1|-1 | |||
}} | }} | ||
}} | }} |
Revision as of 18:18, 2 September 2018
Template documentation (for the template shown above, sometimes hidden or invisible)
- Copied raw notes from related template.
Set Parameter Space Clean-up.//List_Cleanup.
- Input: string/list, intended to be used in SMW '#set' with 'sep=,' parameter.
- Optional list delimiter. Default is comma.
- Turns consecutive inner-spaces into one. (current max:4)
- Turns consecutive inner-delimiters into one. (current max:4)
- Strips leading/trailing delimiters. (current max:3)
- (Leading and trailing spaces are generally ignored/stripped by default.)
- Side effect: Converts underscores in input to spaces in output. (after cleanup, not before!)
- Not sure yet about turning underscores to spaces at the start.
- Related code:
#replace:{{ #replace:,{{{1|}}},||• }}|_|•
- Open/issue: line-breaks. (other list-stuff trips over them)
Visit Template:List normalize/doc to edit this text! (How does this work?)