Skip to content
Use this GitHub action with your project
Add this Action to an existing workflow or create a new one
View on Marketplace

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

github-action-count-markdown-words

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.

Features

  • Counts text words from markdown content
  • Excludes image caption text (for example ![caption](img.png))
  • 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 info tables and in the workflow summary

Inputs

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)

Outputs

Name Description
repository_total_words Total words in all scanned markdown files
results_json JSON payload with document totals and section breakdowns

Usage

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.md

This is going to generate a markdown summary, which you can check at the "actions" tab of your repo, like this one:

Markdown word count

DocumentTotal words
portafolio-edad-moderna.qmd1919

Repository total words: 1919

Sections for portafolio-edad-moderna.qmd

LevelSectionWords
1Portafolio de Historia del Arte de la Edad Moderna en España106
2Palacio del Marqués de Santa Cruz en el Viso del Marqués213
3Arquitectura del palacio del Marqués de Santa Cruz11
4Autor81
4Cronología32
4Tipología45
4Análisis descriptivo957
3Esculturas de la escalera58
4Autor41
4Cronología24
4Tipología66
4Análisis descriptivo135
3Frescos del edificio0
4Autor0
4Cronología0
4Tipología:0
4Análisis descriptivo0
3Contexto histórico-cultural0
4Autor0
4Cronología0
4Tipología:0
4Análisis descriptivo0
4Contexto histórico-cultural0
4Autor0
4Cronología0
4Tipología:0
4Análisis descriptivo0
4Contexto histórico-cultural0
4Autor0
4Cronología0
4Tipología:0
4Análisis descriptivo0
4Contexto histórico-cultural0
4Autor0
4Cronología0
4Tipología:0
4Análisis descriptivo0
4Contexto histórico-cultural0
4Autor0
4Cronología0
4Tipología:0
4Análisis descriptivo0
4Contexto histórico-cultural0
4Autor0
4Cronología0
4Tipología:0
4Análisis descriptivo0
4Contexto histórico-cultural0
2Créditos de las imágenes17
2Referencias0

Development

Install dependencies:

npm install

Run tests:

npm test

Build single-file action bundle with ncc:

npm run build

License

This is (c) JJ Merelo and is licensed under the AGPL v3. See LICENSE for details.

About

Count words in markdown files in a project

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages