Module:ParseList/doc: Difference between revisions

From bg3.wiki
Jump to navigation Jump to search
No edit summary
No edit summary
Line 23: Line 23:
| <code>delimiter</code> || <code>,</code>
| <code>delimiter</code> || <code>,</code>
| 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.
| 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.
|-
| <code>makeLinks</code> || ''(empty)''
| If provided and not blank, means that each element will be made into a link.
|-
|-
| <code>makePlural</code> || ''(empty)''
| <code>makePlural</code> || ''(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 <code><nowiki>[[Apple|Apples]]</nowiki></code>.
| If provided and not blank, means that each element will be turned into a plural word.
|-
|-
| <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.
|-
| <code>makeLowercase</code> || ''(empty)''
| If provided and not blank, means that each element will be made all-lowercase.
|-
| <code>makeLinks</code> || ''(empty)'' ||
If provided and not blank, means that each element will be made into a link.
 
If any transforms like plural, singular, or lowercase were specified, the original element will be the link destination, and the transformed version the link text.  E.g., the list element "Apple" would become <code><nowiki>[[Apple|apples]]</nowiki></code> if <code>makePlural</code>, <code>makeLowercase</code>, and <code>makeLinks</code> were provided.
|-
|-
| <code>useTemplate</code> || ''(empty)''
| <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.
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.  E.g., the list element "Apple" would become <code><nowiki>{{Template|apples}}</nowiki></code> if <code>makePlural</code>, <code>makeLowercase</code>, and <code>useTemplate</code> were provided.
|-
|-
| <code>useTemplate2</code> || ''(empty)''
| <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>.
If provided, will use the provided template on each element and its transformed form as two template arguments.
 
E.g., the list element "Apple" would become <code><nowiki>{{Template|Apple|apples}}</nowiki></code> if <code>makePlural</code>, <code>makeLowercase</code>, and <code>useTemplate</code> were provided.
|-
|-
| <code>joinWord</code> || <code>and</code>
| <code>joinWord</code> || <code>and</code> ||
| If <code>type</code> is <code>sentence</code>, 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 <code>joinWord = or</code> you can make these become "X or Y" and "X, Y, or Z" respectively.
If <code>type</code> is <code>sentence</code>, 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 <code>joinWord = or</code> 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 <code>staff -> staves</code>, and partly through logical rules like <code>...f --> ...ves</code>.  If you find a word that produces a wrong result, it should be added to the table of explicit conversions.
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 <code>staff -> staves</code>, and partly through logical rules like <code>...f --> ...ves</code>.  If you find a word that produces a wrong result, it should be added to the table of explicit conversions.
The <code>makeLink</code>, <code>useTemplate</code>, and <code>useTemplate2</code> arguments are mutually exclusive; when several are provided, only the first will take effect.


=== Output types ===
=== Output types ===

Revision as of 00:52, 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.
makePlural (empty) If provided and not blank, means that each element will be turned into a plural word.
makeSingular (empty) If provided and not blank, means that each element will be turned into singular.
makeLowercase (empty) If provided and not blank, means that each element will be made all-lowercase.
makeLinks (empty)

If provided and not blank, means that each element will be made into a link.

If any transforms like plural, singular, or lowercase were specified, the original element will be the link destination, and the transformed version the link text. E.g., the list element "Apple" would become [[Apple|apples]] if makePlural, makeLowercase, and makeLinks were provided.

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. E.g., the list element "Apple" would become {{Template|apples}} if makePlural, makeLowercase, and useTemplate were provided.

useTemplate2 (empty)

If provided, will use the provided template on each element and its transformed form as two template arguments.

E.g., the list element "Apple" would become {{Template|Apple|apples}} if makePlural, makeLowercase, and useTemplate were provided.

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.

The makeLink, useTemplate, and useTemplate2 arguments are mutually exclusive; when several are provided, only the first will take effect.

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: