peisar
v1.0.12
Published
A practical Markdown parser written in Rust
Readme
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 peisarRust
[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
Rust usage
Benchmarks
Other docs
Packages and examples
- npm: https://www.npmjs.com/package/peisar
- crates.io: https://crates.io/crates/peisar
- Next.js example: https://github.com/phothinmg/peisar/tree/main/examples/next
- Vite example: https://github.com/phothinmg/peisar/tree/main/examples/vite
Development
npm install
npm run js:test
npm run build
cargo testMore 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
Security policy: SECURITY.md
