Gramadoc is a grammar and writing toolkit for analyzing text and building rich-text editing experiences with inline suggestions.
Core analysis engine for grammar, spelling, punctuation, formatting, readability, and structured-text checks.
Install:
npm install @markwylde/gramadocUse:
import { analyzeHtml, analyzeText, htmlToPlainText } from '@markwylde/gramadoc'
const result = analyzeText('I has a apple.')
console.log(result.matches)
console.log(htmlToPlainText('<p>Hello <strong>world</strong></p>'))
console.log(analyzeHtml('<p>I has a apple.</p>').matches)React bindings for Gramadoc, including a rich-text input component and a background analysis hook.
Install:
npm install @markwylde/gramadoc-reactYou will usually install it alongside React and the core engine:
npm install react react-dom @markwylde/gramadoc @markwylde/gramadoc-reactUse:
import { useState } from 'react'
import {
GramadocInput,
useGrammerAnalysis,
} from '@markwylde/gramadoc-react'
import '@markwylde/gramadoc-react/styles.css'
export function Editor() {
const [value, setValue] = useState('<p>I has a apple.</p>')
const analysis = useGrammerAnalysis({ value })
return (
<GramadocInput
value={value}
warnings={analysis.warnings}
analysisPlainText={analysis.plainText}
onChange={setValue}
placeholder="Start writing..."
/>
)
}This repository is a pnpm workspace.
Install dependencies:
pnpm installStart development apps:
pnpm devBuild packages and apps:
pnpm buildRun the core package tests:
pnpm test