This extension inserts word counts into Quarto documents in the place of {{wordcount}}.
Word counts can be inserted in the body or metadata (YAML header) of a document.
To include the number of words in the references, use {{wordcountref}}.
You may also be interested in:
- Andrew Heiss's Word Count Extension: this prints word counts by body/references to the log file.
- Ben Marwick's wordcountaddin RStudio Addin: this provides a word count of a markdown document.
quarto add christopherkenny/wordcountThis will install the extension under the _extensions subdirectory.
If you're using version control, you will want to check in this directory.
After installing:
- Add
to the YAML header of your Quarto file
filters: - wordcount
- Add
{{wordcount}}or{{wordcountref}}in your document (without the `tics`). Make sure there are spaces around it.
For example you could write:
There are {{wordcount}} words in this document.
and it will replace {{wordcount}} with its estimate.
You can also include additional settings like the following to control whether inline code is counted in the word total:
filters:
- wordcount
wordcount:
count-code-blocks: false
count-inline-code: falseWhen true:
r 2+2increases the count by 2.r 2 + 2increases the count by 4.
When set to false, inline code does not contribute to the word count.
Here is the source code for a minimal example: example.qmd.
The original wordcount filter is licensed under a MIT license to 2017-2021 pandoc Lua filters contributors. This Quarto extension is also licensed under the MIT license.
