Skip to content

markwylde/gramadoc

Repository files navigation

Gramadoc

Gramadoc is a grammar and writing toolkit for analyzing text and building rich-text editing experiences with inline suggestions.

Packages

@markwylde/gramadoc

Core analysis engine for grammar, spelling, punctuation, formatting, readability, and structured-text checks.

Install:

npm install @markwylde/gramadoc

Use:

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)

@markwylde/gramadoc-react

React bindings for Gramadoc, including a rich-text input component and a background analysis hook.

Install:

npm install @markwylde/gramadoc-react

You will usually install it alongside React and the core engine:

npm install react react-dom @markwylde/gramadoc @markwylde/gramadoc-react

Use:

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..."
    />
  )
}

Development

This repository is a pnpm workspace.

Install dependencies:

pnpm install

Start development apps:

pnpm dev

Build packages and apps:

pnpm build

Run the core package tests:

pnpm test

About

A grammar and writing toolkit for analyzing text and building rich-text editing experiences with inline suggestions

Topics

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages