Template:Word count
From Wikipedia, the free encyclopedia
This template uses Lua: |
This template counts the number of words that goes into its first parameter. It serves as a basic word count function in areas where word count is important (such as Arbitration Committee statements, etc.)
Usage
{{word count|1=[phrase to count]|limit=[number of words to limit?]|trim=[whether to trim?]|showcount=[whether to show the word count?]}|prepend=[what to prepend?]|append=[what to append after?]}}
Examples
{{word count|
One two three four five six seven
|limit=20|trim=no|showcount=yes}}
Word count: 7/20
One two three four five six seven
{{word count|
One two three four five six seven eight nine ten
eleven twelve
|limit=20|trim=yes|showcount=yes}}
Word count: 12/20
One two three four five six seven eight nine ten
eleven twelve
{{word count|
One two three four five six seven eight nine ten
eleven twelve thirteen fourteen fifteen sixteen seventeen eighteen nineteen twenty
|limit=20|trim=yes|showcount=yes}}
Word count: 20/20
One two three four five six seven eight nine ten
eleven twelve thirteen fourteen fifteen sixteen seventeen eighteen nineteen twenty
{{word count|
One two three four five six seven eight nine ten
eleven twelve thirteen fourteen fifteen sixteen seventeen eighteen nineteen twenty twenty-one twenty-two
|limit=20|trim=yes|showcount=yes}}
Word count: 22/20
One two three four five six seven eight nine ten
eleven twelve thirteen fourteen fifteen sixteen seventeen eighteen nineteen twenty
{{word count|
One two three four five six seven eight nine ten
eleven twelve thirteen fourteen fifteen sixteen seventeen eighteen nineteen twenty twenty-one twenty-two
|trim=yes|showcount=yes}}
Word count: 22
One two three four five six seven eight nine ten
eleven twelve thirteen fourteen fifteen sixteen seventeen eighteen nineteen twenty twenty-one twenty-two
Parameter trim= example showing all text (trim=no) or truncated text (trim=yes)
{{word count|prepend=<div style="border:1px solid red;">|
One two three four five six seven eight nine ten
eleven twelve thirteen fourteen fifteen sixteen seventeen eighteen nineteen twenty twenty-one twenty-two
|append=</div>|limit=20|trim=no|showcount=yes}}
{{word count|prepend=<div style="border:1px solid red;">|
One two three four five six seven eight nine ten
eleven twelve thirteen fourteen fifteen sixteen seventeen eighteen nineteen twenty twenty-one twenty-two
|append=</div>|limit=20|trim=yes|showcount=yes}}
Possible errors
The |trim=yes
option truncates text at a word boundary, which may leave formatting markup unclosed. This can affect formatting of text that follows the template text, and can cause Linter errors.
See also
- {{Counter}} – To count the parameters of a template
- {{InternalLinkCounter}} – To count number of internal links
Editors can experiment in this template's sandbox (create | mirror) and testcases (create) pages.
Add categories to the /doc subpage. Subpages of this template.