百科.dev
全部条目AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
R

retext

> 编程语言
开源

由 @unifiedjs 团队的插件提供支持的自然语言处理器

2.4K stars0 点赞0 次浏览
访问官网GitHub

工具介绍

由 @unifiedjs 团队的插件提供支持的自然语言处理器

retext

Build Coverage Downloads Size Sponsors Backers Chat

retext is a tool that transforms natural language with plugins. These plugins can inspect and change the natural language. You can use retext on the server, the client, deno, etc.

Intro

retext is an ecosystem of plugins that work with natural language as structured data, specifically CSTs (concrete syntax trees). Syntax trees make it easy for programs to deal with prose. We call those programs plugins. Plugins inspect and change trees. You can use the many existing plugins or you can make your own. Some example use cases are to check spelling, fix typography, or make sure text is readable.

  • for more about us, see unifiedjs.com
  • for questions, see support
  • to help, see contribute or sponsor below

Contents

  • What is this?
  • When should I use this?
  • Plugins
  • Types
  • Compatibility
  • Contribute
  • Sponsor
  • License

What is this?

With this project and a plugin, you can turn simple punctuation:

He said, "A 'simple' english sentence. . .

…into smart punctuation:

He said, “A ‘simple’ english sentence…”
Show example code
javascript
import retextLatin from 'retext-latin'
import retextSmartyPants from 'retext-smartypants'
import retextStringify from 'retext-stringify'
import {unified} from 'unified'

const file = await unified()
  .use(retextLatin)
  .use(retextSmartyPants)
  .use(retextStringify)
  .process("He said, \"A 'simple' english sentence. . .")

console.log(String(file))

With another plugin, you can check natural language:

In:

Where can I find an ATM machine?

Out:

1:21-1:32 warning Unexpected redundant `ATM machine`, expected `ATM` atm retext-redundant-acronyms

⚠ 1 warning
Show example code
javascript
import retextEnglish from 'retext-english'
import retextRedundantAcronyms from 'retext-redundant-acronyms'
import retextStringify from 'retext-stringify'
import {unified} from 'unified'
import {reporter} from 'vfile-reporter'

const file = await unified()
  .use(retextEnglish)
  .use(retextRedundantAcronyms)
  .use(retextStringify)
  .process('Where can I find an ATM machine?')

console.log(reporter(file))

…and you can make your own plugins.

You can use retext for many different things. unified is the core project that transforms content with ASTs. retext adds support for natural language to unified. nlcst is the natural language AST that retext uses.

This GitHub repository is a monorepo that contains the following packages:

  • retext-dutch — parse Dutch prose to a syntax tree
  • retext-english — parse English prose to a syntax tree
  • retext-latin — parse any Latin-script prose to a syntax tree
  • retext-stringify — serialize a syntax tree
  • retext — programmatic interface with both retext-latin and retext-stringify

When should I use this?

It is recommended to use unified with retext-english (or retext-dutch) and retext-stringify if your content is in English (or Dutch). Otherwise, if your content is in another Latin-script language, use retext.

Plugins

retext plugins deal with natural language. You can choose from the many plugins that already exist. Here are three good ways to find plugins:

  • awesome-retext — selection of the most awesome projects
  • List of plugins — list of all plugins
  • retext-plugin topic — any tagged repo on GitHub

Some plugins are maintained by us here in the @retextjs organization while others are maintained by folks elsewhere. Anyone can make retext plugins, so as always when choosing whether to include dependencies in your project, make sure to carefully assess the quality of retext plugins too.

Types

The retext organization and the unified collective as a whole is fully typed with TypeScript. Types for nlcst are available in @types/nlcst.

For TypeScript to work, it is important to type your plugins. For example:

javascript
/**
 * @import {Root} from 'nlcst'
 */

/**
 * @typedef Options
 *   Configuration (optional).
 * @property {boolean | null | undefined} [someField]
 *   Some option.
 */

/**
 * My plugin.
 *
 * @param {Options | null | undefined} [options]
 *   Configuration (optional).
 * @returns
 *   Transform.
 */
export function myRetextPluginAcceptingOptions(options) {
  /**
   * @param {Root} tree
   *   Tree.
   * @param {VFile} file
   *   File.
   * @returns {undefined}
   *   Nothing.
   */
  return function (tree, file) {
    // Do things.
  }
}

Compatibility

Projects maintained by the unified collective are compatible with maintained versions of Node.js.

When we cut a new major release, we drop support for unmaintained versions of Node. This means we try to keep the current release line compatible with Node.js 16.

Contribute

See contributing.md in retextjs/.github for ways to get started. See support.md for ways to get help.

This project has a code of conduct. By interacting with this repository, organization, or community you agree to abide by its terms.

For info on how to submit a security report, see our security policy.

Sponsor

Support this effort and give back by sponsoring on OpenCollective!

Vercel

Motif

HashiCorp

GitBook

Gatsby

Netlify

Coinbase

ThemeIsle

Expo

Boost Note

Markdown Space

Holloway


You?

License

MIT © Titus Wormer

Issues· 0 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

JavaScriptastcstjavascriptnatural-language

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月17日
分类编程语言
定价开源

> 相关工具

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言