comark-reading-time
v0.12.0
Published
A document's word count and reading time in meta.readingTime, with code blocks left out and CJK counted by character. A Comark plugin.
Downloads
11,995
Maintainers
Readme
comark-reading-time
A document's word count and reading time, written to meta.readingTime while parsing. A Comark plugin for any renderer.
pnpm add comark comark-reading-timeimport { parseMarkdown } from "comark";
import readingTime from "comark-reading-time";
const { meta } = await parseMarkdown(markdown, { plugins: [readingTime({ wordsPerMinute: 200 })] });
meta.readingTime; // { words: 1240, minutes: 7 }Code blocks, frontmatter, and comments are left out; inline code counts. Chinese, Japanese, and Korean are counted by character, since they're written without spaces between words. minutes is rounded up, and 0 only for a document with no words. countWords(text) counts any string the same way.
It draws nothing and has no components: show the numbers in your layout.
