July 13, 2023

Show word count with Pandoc and a lua script

To show word and character count (skipping metadata and Markdown syntax) of a file, first download the lua script wordcount.lua (there is a copy of the script hosted on this website) by running:

$ wget https://yctct.com/wordcount.lua

Then, to show word and character count of a file run:

$ pandoc file --lua-filter=path/to/file/wordcount.lua

If the file containing the script wordcount.lua is located in the same directory as the file you wish to count words of, you can run:

$ pandoc file --lua-filter=wordcount.lua

The terminal should print something like:

449 words in body
2114 characters in body
2551 characters in body (including spaces)

If you need to download Pandoc, on Trisquel GNU/Linux run:

$ sudo apt install pandoc

What is the difference between using the programme wc and the script wordcount.lua to count words?

wc will count all characters, including those that are commented out, Markdown syntax and metadata whereas wordcount.lua will skip those.

✍✍✍✍✍✍✍✍✍✍✍✍✍✍

I do self-funded research and I'm writing a book.

> What's the book about?

About technologies and agency.

Meaning, technologies can foster agency. No doubt. But I am also asking:

Can usage of technologies give us a sense of empowerment while in fact undermining our abilities?

I posted a summary of the prologue on the homepage: https://yctct.com/

✍✍✍✍✍✍✍✍✍✍✍✍✍✍


command-line interface (cli) personal computing pandoc trisquel GNU linux text processing office applications wiki shell literacy

No affiliate links, no analytics, no tracking, no cookies. This work © 2016-2024 by yctct.com is licensed under CC BY-ND 4.0 .   about me   contact me   all entries & tags   FAQ   GPG public key

GPG fingerprint: 2E0F FB60 7FEF 11D0 FB45 4DDC E979 E52A 7036 7A88