Expand description
A library for counting words and characters in Typst documents.
This crate provides functionality to compile Typst documents and count the words and characters in the rendered output. It works by:
- Compiling Typst documents using the Typst compiler
- Traversing the compiled document’s element tree
- Extracting plain text from rendered elements
- Counting words (by whitespace) and characters
§Features
- Count words and characters from compiled Typst documents
- Handle imported and included files
- Multiple output formats (human-readable, JSON, CSV)
- CI/CD integration with limit checking
§Examples
use typst_count::compile_document;
use std::path::Path;
let path = Path::new("document.typ");
let count = compile_document(path, false).unwrap();
println!("Words: {}, Characters: {}", count.words, count.characters);Modules§
- cli
- Command-line interface definitions for typst-count.
- counter
- Document counting logic for Typst documents.
- output
- Output formatting for word and character count results.
- world
- A minimal implementation of Typst’s World trait for document compilation.
Functions§
- check_
limits - Checks if word and character counts are within specified limits.
- compile_
document - Compiles a Typst document and counts its words and characters.
- process_
files - Processes multiple Typst files and returns their counts.