Module:ParseList/doc

From bg3.wiki
Jump to navigation Jump to search

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.
makePlural (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|Apples]].
makeSingular (empty) If provided and not blank, means that each element will be turned into singular. This happens after turning them into links, so e.g. the word "Apples" would become [[Apples|Apple]].
joinWord 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 joinWord = 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

Make plural

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

Result:

Fighters, Clerics, and Wizards

Make Plural Links

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

Result:

Fighters, Clerics, and Wizards

Make Plural Links, end with "or"

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

Result:

Fighters, Clerics, and Wizards

Make Plural Links, turn into HTML list

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

Result: