A lightweight JavaScript library for converting markup documents into an annotated text format consumable by LanguageTool as AnnotatedText.
For details, please see https://www.prosegrinder.org/annotatedtext.
npm:
npm install annotatedtext –saveannotatedtext provides a basic set of types and functions useful for converting markup documents into AnnotatedText.
For example, to convert Markdown to AnnotatedText using the nifty remark-parse parser, you would do:
import { compose } from "annotatedtext"; import { parse } from "remark-parse"; import { unified } from "unified"; const text = "This is a sentence."; const processor = unified() .use(remarkparse, options.remarkoptions) .use(frontmatter, ["yaml", "toml"]) .parse(text); const annotatedtext = compose(text, parse); JSON.stringify(annotatedtext);Running the object through JSON.stringfy() creates a string suitable for passing to LanguageTool's data parameter.
The following packages wrap annotatedtext for specific parsers:
annotatedtext-remarkfor markdown using remark-parse.annotatedtext-rehypefor html using rehype-parse.