peisar 1.1.0

A practical Markdown parser written in Rust
Documentation

NPM Version NPM Downloads Crates.io Version Documentation


Peisar parses CommonMark Markdown with GitHub Flavored Markdown (GFM), Kramdown block attributes, YAML front matter, source spans, AST visitors, custom parser hooks, and a Rust-first architecture that is also exposed to Node.js through N-API.

[!NOTE] The README is intentionally short so the npm and crates.io pages stay easy to scan. Detailed guides now live in the repository under docs/, which lets the project update documentation between package releases.

Features

  • CommonMark blocks and inlines, including HTML and reference links
  • GFM tables, strikethrough, task lists, and autolinks
  • Kramdown block attributes such as {:#intro .lead key="value"}
  • YAML front matter extraction
  • AST visitors and parser hooks through usePlugin()
  • Native Node.js addon and Rust library surfaces

Install

Node.js

npm i peisar

Rust

[dependencies]
peisar = "1.0.0"

Quick start

Node.js

const { Peisar } = require("peisar");

const document = new Peisar("# Hello **world**", { fragment: true });

console.log(document.html);
console.log(document.ast);
console.log(document.frontmatter);

Rust

use peisar::markdown::ast::{AstOptions, Document};
use peisar::markdown::html::{RenderOptions, render_document_html};

let doc = Document::parse("# Hello **world**\n", &AstOptions::default(), None);
let html = render_document_html(
    &doc,
    Some(RenderOptions {
        fragment: true,
        ..RenderOptions::default()
    }),
);

assert_eq!(html, "<h1>Hello <strong>world</strong></h1>\n");

Documentation

Node.js usage

Browser usage

Rust usage

Benchmarks

Other docs

Packages and examples

Development

npm install
npm run js:test
npm run build
cargo test

More detail in CONTRIBUTING.

AI integration

Peisar supplies Agent Skills for AI coding tools:

npx skills add phothinmg/peisar
  • peisar-parse-markdown: consume the Node.js and Rust Markdown APIs
  • peisar-ast-visitors: make post-parse AST transformations
  • peisar-parser-hooks: add syntax recognized during parsing
  • peisar-development: modify and validate the codebase

License

Apache-2.0 © Pho Thin Maung

Security policy: SECURITY.md