Skip to main content

prose-wc

Build Status Coverage Status PyPI

A prose- and Jekyll-aware wordcount utility.

About

Given the proliferation of Markdown and the use of Jekyll as a blogging platform, the builtin wc utility came up short. Even for plain-text prose, wc can leave much to be desired. To that end, prose-wc will calculate proper word, paragraph, and character counts for a given plaintext, or markdown file or stream through STDIN.

Also, Madison wanted to learn how to package for PyPI.

Installing

pip install prose-wc

Running

usage: prose-wc [-h] [-S] [-u] [-f [{yaml,json,default}]] [-i [INDENT]] file

Compute Jekyl- and prose-aware wordcounts

positional arguments:
  file                  file to count (or - for STDIN)

optional arguments:
  -h, --help            show this help message and exit
  -S, --split-hyphens   split hyphenated words rather than counting them as
                        one word ("non-trivial" counts as two words rather
                        than one)
  -u, --update          update the jekyll file in place with the counts. Does
                        nothing if the file is not a Jekyll markdown file.
                        Implies format=yaml, invalid with input from STDIN and
                        non-Jekyll files.
  -f [{yaml,json,default}], --format [{yaml,json,default}]
                        output format.
  -i [INDENT], --indent [INDENT]
                        indentation depth (default: 4).

Accepted filetypes: plaintext, markdown, markdown (Jekyll)

Running prose-wc against a file will generate a series of counts that might be of use. You can get these counts in a simple, tab-separated format, JSON, or YAML. If you’re working with a Jekyll markdown file, you can also choose to have this data embedded in the frontmatter as YAML.

Other filetypes

You can use pandoc to convert your file and pipe it into prose-wc:

pandoc -f latex -t plain my_great_story.tex | prose-wc -

In a Jekyll site

You can add wordcount information to your site by running prose-wc -u <file>, which will update the Jekyll frontmatter to include the results in YAML format. This data can then be included on the page in some place handy such as at the top of a post in _layouts/post.html with:

{% if page.counts %}
    <p class="text-muted small">
        {{ page.counts.paragraphs }} {% if page.counts.paragraphs == 1 %}paragraph{% else %}paragraphs{% endif %} &bullet;
        {{ page.counts.words }} words
    </p>
{% endif %}

This would result in something like this.

You can add wordcounts to posts with a find command like:

find . \( -name '*.md' -or -name '*.markdown' \) -exec prose-wc -u "{}" \;

Further information

Source, issues, and further information:

GitHub

Author

Madison Scott-Clary

Metadata

Release files for prose-wc 0.3.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for prose-wc 0.3.4
File Size Uploaded Provenance Actions
prose-wc-0.3.4.tar.gz 7.1 kB Without provenance Details for prose-wc-0.3.4.tar.gz

Release files / prose-wc-0.3.4.tar.gz

Download URL prose-wc-0.3.4.tar.gz
Size 7.1 kB
Tags Source
SHA-256 checksum
How to use checksums
e2259343d96de0d3672163582d087432fbdf34c499951e6189227685e1e5ce73
BLAKE2b-256 checksum
How to use checksums
a099e5ec5f737636f278a1355fc3e713a24666b7281bae6ccfe4530d8d066eef
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Security for prose-wc 0.3.4

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page