textlane 0.7.0

Rust-native text processing pipeline — a unified replacement with native and JavaScript plugins
Documentation

Textlane

Textlane is a Rust-native text processing pipeline: a replacement for unified whose plugins run natively, while existing JavaScript plugins can still join the same pipeline. One Rust crate ships to crates.io, npm and PyPI at one version.

Installation

cargo add textlane

Usage

A processor chains plugins with use, as unified does, then parses, transforms and serializes text with process. Each language reaches the same crate; plugins are grouped by domain (md, html, mdx, nl) and named as the pipeline names them.

Rust:

use textlane::{Processor, html, md};

let processor = Processor::new()
    .with(md::Parse::default())
    .with(md::Gfm::default())
    .with(md::ToHtml::default())
    .with(html::Stringify::default())
    .freeze()?;
assert_eq!(processor.process("# hi")?.value, "<h1>hi</h1>");

Node.js:

import { textlane } from "textlane"
import * as html from "textlane/html"
import * as md from "textlane/md"

const file = await textlane()
  .use(md.parse())
  .use(md.gfm())
  .use(md.toHtml({ allowDangerousHtml: true }))
  .use(html.stringify())
  .process("# hi")
file.value // "<h1>hi</h1>"

Python:

from textlane import html, md, textlane

file = (
    textlane()
    .use(md.parse())
    .use(md.gfm())
    .use(md.to_html({"allowDangerousHtml": True}))
    .use(html.stringify())
    .process("# hi")
)
file["value"]  # "<h1>hi</h1>"

Node.js and Python also offer parse, run, stringify, data and freeze, with Node.js's process/run returning a Promise beside processSync/runSync, and Python's returning the result beside the coroutines aprocess/arun. Errors carry the crate's code, such as unknown-plugin. A JavaScript or Python function joins a pipeline as a unified attacher returning a transformer; it cannot add syntax, a parser or a compiler.

Documentation

Read the docs at textlane.dev.

License

MIT.