npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

pepamark

v1.0.2

Published

TypeScript Markdown parser and HTML renderer

Downloads

710

Readme

Pepamark

Pepamark is a TypeScript Markdown parser and HTML renderer. It parses Markdown into a typed AST, reads YAML front matter, supports GFM and Kramdown extensions, and can render either an HTML fragment or a complete HTML document.

Installation

npm install pepamark

Quick start

Create a Pepamark instance with Markdown, then read its html, ast, or frontmatter properties.

import { Pepamark } from "pepamark";

const document = new Pepamark<{ title: string }>(`---
title: Welcome
---
# Hello, Pepamark!

This is **Markdown**.`);

console.log(document.frontmatter);
// { title: "Welcome" }

console.log(document.html);
// <!DOCTYPE html>...

To render only the HTML body content, use fragment: true:

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

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

API

Pepamark

new Pepamark<F>(markdown, options?) is the high-level API. F describes the expected shape of the YAML front matter.

| Property | Description | | --- | --- | | ast | Parsed Markdown document AST. | | frontmatter | Parsed YAML front matter, or undefined when absent. | | html | Rendered HTML document or fragment. |

Options

The constructor accepts parser and renderer options:

| Option | Default | Description | | --- | --- | --- | | gfm | true | Enables GitHub Flavored Markdown extensions, including tables and task lists. | | kramdown | true | Enables Kramdown attributes such as {:#id .class key="value"}. | | fileName | null | Associates a source file name with the AST document. | | fragment | false | Emits only body HTML instead of a complete HTML document. | | charset | true | Includes <meta charset="utf-8"> in full-document output. | | viewport | true | Includes a viewport meta tag in full-document output. | | title | null | Sets the full document's <title>. | | bodyClass | null | Adds classes to the full document's <body>. | | style | null | Adds inline CSS in a <style> element. |

For example:

const document = new Pepamark("# Guide", {
  title: "My guide",
  bodyClass: "documentation",
  style: "body { max-width: 72ch; margin: 2rem auto; }",
});

Front matter

Use frontmatter when you only need YAML metadata and the Markdown body:

import { frontmatter } from "pepamark";

const result = frontmatter<{ draft: boolean; tags: string[] }>(`---
draft: false
tags: [docs, guide]
---
# Getting started`);

console.log(result.data);
// { draft: false, tags: ["docs", "guide"] }

console.log(result.content);
// # Getting started

When no opening and closing front-matter delimiters are present, data is an empty object and content is the original input.

YAML

The yaml export parses YAML independently:

import { yaml } from "pepamark";

const config = yaml.parse<{ enabled: boolean; retries: number }>(`
enabled: true
retries: 3
`);

Plugins

Register AST visitors or parser plugins with use(). Plugins are reapplied whenever the AST, front matter, or HTML is read. Remove a plugin by its name with remove().

import { Pepamark, type pepatype } from "pepamark";

const uppercaseText: pepatype.PepaMarkPlugin = {
  name: "uppercase-text",
  type: "ast",
  visitBlock() {
    return { recurse: true };
  },
  visitInline(node) {
    if (node.type === "text") {
      node.value = node.value.toUpperCase();
    }
    return {};
  },
};

const document = new Pepamark("Hello, world!", { fragment: true });
document.use(uppercaseText);

console.log(document.html);
// <p>HELLO, WORLD!</p>

Development

Install dependencies:

npm install

Available commands:

| Command | Description | | --- | --- | | npm test | Run the Node.js test suite. | | npm run lint | Check code with Oxlint. | | npm run lint:fix | Apply Oxlint fixes. | | npm run fmt | Format code with Oxfmt. | | npm run fmt:check | Check formatting with Oxfmt. | | npm run build | Build with Susee. |

License

Licensed under the Apache License 2.0.