Back to articles
Build a Hemingway Editor Clone with TypeScript in 50 Lines

Build a Hemingway Editor Clone with TypeScript in 50 Lines

via Dev.to Webdevckmtools

The Hemingway Editor highlights hard-to-read sentences, flags adverbs, and shows your text's grade level. It costs $20 and doesn't have an API. You can't plug it into a build step, run it against your docs folder, or automate it in any way. Let's build a readability checker for developers that does what Hemingway does — from the command line, in about 50 lines of TypeScript. What We're Building A CLI tool called hemingway-check that: Reads a markdown or text file Reports the grade level and Flesch Reading Ease score Flags hard-to-read sentences (grade 10+) Flags very hard sentences (grade 14+) Counts adverbs Exits with code 1 if the text is too complex (for CI use) Setup mkdir hemingway-check && cd hemingway-check npm init -y npm install textlens npm install -D typescript @types/node npx tsc --init --target es2020 --module nodenext --moduleResolution nodenext --outDir dist The Full Script Create src/index.ts : import { readFileSync } from ' fs ' ; import { readability , statistics } fr

Continue reading on Dev.to Webdev

Opens in a new tab

Read Full Article
4 views

Related Articles