Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Quick Start

Peisar parses a Markdown string and exposes its abstract syntax tree (AST), rendered HTML, and frontmatter. Choose the Node.js or Rust example to get started.

Node.js

Install the package:

npm install peisar

Parse and render a Markdown document:

import { Peisar } from "peisar";

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

console.log(document.html);
// <h1>Hello <strong>world</strong></h1>
console.log(document.ast);

fragment: true returns only the rendered content. Without it, Peisar generates a complete HTML document. See the Node.js overview for frontmatter and plugin examples.

Rust

Add Peisar to your Cargo.toml:

[dependencies]
peisar = "2.1.0"

Then parse and render Markdown:

#![allow(unused)]
fn main() {
use peisar::{Peisar, PeisarOptions};

let mut document = Peisar::new(
    "# Hello **world**\n".into(),
    Some(PeisarOptions {
        fragment: Some(true),
        ..Default::default()
    }),
);

println!("{}", document.html());
}

See the Rust overview for lower-level AST access and frontmatter.

Next steps