Extension:NaturalLanguageList

This is a syntax proposal for a parser function to make natural language lists (e.g. 1, 2, 3, ... n-1 and n).

Code

 * NaturalLanguageList.php
 * NaturalLanguageList.i18n.php

Live!
Since this extension is not implemented anywhere else than my place, you can currently see it in action here:


 * http://dev.sviip.dk/List_tests

First parameter (or 'options')
The first parameter (i.e. ) will be the options for the list, using the following basic syntax (inspired by mplayer's filter flag options):

param1=opt:param2=opt:...paramN=opt

Basically parameter separated by colons. The following parameters should be available (along with their defaults):


 * duplicates (boolean)
 * (Default: false) Whether the list should include duplicates, if true duplicates will be included, per default they won't.


 * blanks (boolean)
 * (Default: false) Whether the list should include blank elements, if true blank elements will be included, per default they won't.


 * inputseparator (string)
 * (Default: empty) If set to something, it will assumed the first input parameter is a list of data (perhaps provided by a template and/or parser function, etc.), which is separated by something other than a pipe.


 * separator or outputseparator (string)
 * (Default: empty) The output's separation character(s), if not set, it will default to the 1, 2, 3, ... n-1 and n format.  If set, however, the ' and ' feature will not be available, and all elements will be separated the same way.  So if you set it to a comma, it will simply be the same but the two last elements separated by a comma rather than an ' and '.


 * lastseparator (string)
 * (Default: empty) Allows to set a specific separator for the last two elements, if not set, it will default to the language's setting for ' and '.

#ignore:
Only one option is outside of these options, and dwells inside the input data. The first element beginning with #ignore: will include arguments to be ignored by the data inserted already.

In which case the result would be 1, 3 and 5.