Module:ParseList/doc: Difference between revisions

From bg3.wiki
Jump to navigation Jump to search
No edit summary
Line 32: Line 32:
| <code>makeSingular</code> || ''(empty)''
| <code>makeSingular</code> || ''(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 <code><nowiki>[[Apples|Apple]]</nowiki></code>.
| 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 <code><nowiki>[[Apples|Apple]]</nowiki></code>.
|-
| <code>useTemplate</code> || ''(empty)''
| If provided, will use the provided template on each element, i.e., turn every <code>X</code> into <code><nowiki>{{Template|X}}</nowiki></code>.  This is done ''after'' any transforms like plural/singular and lowercase.
|-
| <code>useTemplate2</code> || ''(empty)''
| If provided, will use the provided template on each element and its transformed form as two template arguments.  For example, if you had specified <code>makePlural = yes</code> and the input element was <code>Sword</code>, then the output element will be <code><nowiki>{{Template|Sword|Swords}}</nowiki></code>.
|-
|-
| <code>joinWord</code> || <code>and</code>
| <code>joinWord</code> || <code>and</code>

Revision as of 00:22, 2 August 2023

Doc page: Module:ParseList/doc

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]].
useTemplate (empty) If provided, will use the provided template on each element, i.e., turn every X into {{Template|X}}. This is done after any transforms like plural/singular and lowercase.
useTemplate2 (empty) If provided, will use the provided template on each element and its transformed form as two template arguments. For example, if you had specified makePlural = yes and the input element was Sword, then the output element will be {{Template|Sword|Swords}}.
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 plural/singular transforms are able to recognize certain irregular plurals and handle them correctly, such as "thieves" and "quarterstaves." This is handled partly through a table of explicit special conversions like staff -> staves, and partly through logical rules like ...f --> ...ves. If you find a word that produces a wrong result, it should be added to the table of explicit conversions.

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: