Toggle menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

Module:ParseList/doc

From bg3.wiki
< Module:ParseList
Revision as of 23:10, 23 July 2023 by Taylan (talk | contribs) (Created page with "This module allows you to process a list of values (separated by a comma by default) and display them in a variety of useful formats. <pre> {{#invoke:ParseList|main|Fighter, Cleric, Wizard}} </pre> Becomes: : {{#invoke:ParseList|main|Fighter, Cleric, Wizard}} == Parameters == The first parameter is the list to be processed. The remaining parameters are optional: {| class="wikitable" ! parameter !! default !! meaning |- | <code>type</code> || <code>sentence</code>...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

This is the documentation page for Module:ParseList

This module allows you to process a list of values (separated by a comma by default) and display them in a variety of useful formats.

{{#invoke:ParseList|main|Fighter, Cleric, Wizard}}

Becomes:

Fighter, Cleric, and Wizard

Parameters

The first parameter is the list to be processed. The remaining parameters are optional:

parameter default meaning
type sentence The desired output format, see below for possibilities.
delimiter , The character that should serve as a delimiter of the list. This can actually be a string of multiple characters which will all work as a delimiter, but that usage is discouraged as it may cause confusion.
makeLinks (empty) If provided and not blank, means that each element will be made into a link.
pluralize (empty) If provided and not blank, means that each element will be turned into a plural word. This happens after turning them into links, so e.g. the word "Apple" would become [[Apple]]s.
joiningWord and If type is sentence, this defines whether to use "and" or "or" (or any other word) for the last two elements of the list. E.g., the default would be to turn "X, Y" into "X and Y" and "X, Y, Z" into "X, Y, and Z", but by providing joiningWord = or you can make these become "X or Y" and "X, Y, or Z" respectively.

The automatic pluralization is able to recognize certain irregular plurals and handle them correctly, such as "thieves" and "quarterstaves." This is handled through a simple table in the code mapping words to their irregular plural form. If you find a word that's not supported yet, you can simply add it to the table.

Output types

The value of the type parameter can be the following:

value example output
sentence Fighter, Cleric, and Wizard
htmlList
  • Fighter
  • Cleric
  • Wizard
simpleList Fighter, Cleric, Wizard

Examples

Make Links

{{#invoke: ParseList | main | Fighter, Cleric, Wizard | makeLinks = yes }}

Result:

Fighter, Cleric, and Wizard

Pluralize

{{#invoke: ParseList | main | Fighter, Cleric, Wizard | pluralize = yes }}

Result:

Fighter, Cleric, and Wizard

Make Links & Pluralize

{{#invoke: ParseList | main | Fighter, Cleric, Wizard | makeLinks = yes | pluralize = yes }}

Result:

Fighter, Cleric, and Wizard

Make Links & Pluralize, end with "or"

{{#invoke: ParseList | main | Fighter, Cleric, Wizard | makeLinks = yes | pluralize = yes | joiningWord = or }}

Result:

Fighter, Cleric, and Wizard

Make Links & Pluralize, turn into HTML list

{{#invoke: ParseList | main | Fighter, Cleric, Wizard | makeLinks = yes | pluralize = yes | type = htmlList }}

Result: