GitHub Action to count words in markdown files for:
- each document total
- each section (by heading level, configurable)
- repository-wide total
Scanned file extensions: .md, .markdown, .Rmd, .qmd.
- Counts text words from markdown content
- Excludes image caption text (for example
) - Reports per-document totals and per-section totals
- Supports section depth input (
depth); by default all heading levels are included - Publishes results in CI logs using
infotables and in the workflow summary
| Name | Required | Default | Description |
|---|---|---|---|
path |
No | . |
Root directory to scan for markdown files |
depth |
No | (all levels) | Maximum heading depth to include in section tables |
exclude |
No | README.md |
Comma/newline-separated markdown file paths to exclude (relative to path) |
| Name | Description |
|---|---|
repository_total_words |
Total words in all scanned markdown files |
results_json |
JSON payload with document totals and section breakdowns |
name: Count markdown words
on: [push, pull_request]
jobs:
words:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: JJ/github-action-count-markdown-words@v1
with:
path: .
depth: 4
exclude: |
README.md
docs/generated.mdThis is going to generate a markdown summary, which you can check at the "actions" tab of your repo, like this one:
| Document | Total words |
|---|---|
| portafolio-edad-moderna.qmd | 1919 |
Repository total words: 1919
| Level | Section | Words |
|---|---|---|
| 1 | Portafolio de Historia del Arte de la Edad Moderna en España | 106 |
| 2 | Palacio del Marqués de Santa Cruz en el Viso del Marqués | 213 |
| 3 | Arquitectura del palacio del Marqués de Santa Cruz | 11 |
| 4 | Autor | 81 |
| 4 | Cronología | 32 |
| 4 | Tipología | 45 |
| 4 | Análisis descriptivo | 957 |
| 3 | Esculturas de la escalera | 58 |
| 4 | Autor | 41 |
| 4 | Cronología | 24 |
| 4 | Tipología | 66 |
| 4 | Análisis descriptivo | 135 |
| 3 | Frescos del edificio | 0 |
| 4 | Autor | 0 |
| 4 | Cronología | 0 |
| 4 | Tipología: | 0 |
| 4 | Análisis descriptivo | 0 |
| 3 | Contexto histórico-cultural | 0 |
| 4 | Autor | 0 |
| 4 | Cronología | 0 |
| 4 | Tipología: | 0 |
| 4 | Análisis descriptivo | 0 |
| 4 | Contexto histórico-cultural | 0 |
| 4 | Autor | 0 |
| 4 | Cronología | 0 |
| 4 | Tipología: | 0 |
| 4 | Análisis descriptivo | 0 |
| 4 | Contexto histórico-cultural | 0 |
| 4 | Autor | 0 |
| 4 | Cronología | 0 |
| 4 | Tipología: | 0 |
| 4 | Análisis descriptivo | 0 |
| 4 | Contexto histórico-cultural | 0 |
| 4 | Autor | 0 |
| 4 | Cronología | 0 |
| 4 | Tipología: | 0 |
| 4 | Análisis descriptivo | 0 |
| 4 | Contexto histórico-cultural | 0 |
| 4 | Autor | 0 |
| 4 | Cronología | 0 |
| 4 | Tipología: | 0 |
| 4 | Análisis descriptivo | 0 |
| 4 | Contexto histórico-cultural | 0 |
| 4 | Autor | 0 |
| 4 | Cronología | 0 |
| 4 | Tipología: | 0 |
| 4 | Análisis descriptivo | 0 |
| 4 | Contexto histórico-cultural | 0 |
| 2 | Créditos de las imágenes | 17 |
| 2 | Referencias | 0 |
Install dependencies:
npm installRun tests:
npm testBuild single-file action bundle with ncc:
npm run buildThis is (c) JJ Merelo and is licensed under the AGPL v3. See LICENSE for details.