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

@origints/markdown

v0.2.0

Published

Markdown parsing and manipulation for Origins with full lineage tracking

Downloads

135

Readme

@origints/markdown

Markdown parsing and manipulation for Origins with full lineage tracking.


Features

  • Parse Markdown with GFM (GitHub Flavored Markdown) support
  • YAML frontmatter extraction
  • Source position tracking for all nodes
  • Type-safe navigation and extraction
  • Convert to HTML
  • Support for tables, task lists, and footnotes
  • Integrates with Origins transform registry

Installation

npm install @origints/markdown @origints/core

Usage with Planner

Extract content from a Markdown file

import { Planner, loadFile, run } from '@origints/core'
import { parseMarkdown } from '@origints/markdown'

const plan = new Planner()
  .in(loadFile('README.md'))
  .mapIn(parseMarkdown())
  .emit((out, $) => out.add('title', $.select('heading').text()))
  .compile()

const result = await run(plan, { readFile, registry })
// result.value: { title: 'My Project' }

Extract collections with selectAll

Use selectAll() to extract data from all matching nodes as an array:

// Extract all heading texts from a document
const plan = new Planner()
  .in(loadFile('README.md'))
  .mapIn(parseMarkdown())
  .emit((out, $) =>
    out.add(
      'headings',
      $.selectAll('heading', node => node.text())
    )
  )
  .compile()

const result = await run(plan, { readFile, registry })
// result.value: { headings: ['Introduction', 'Getting Started', 'API'] }

Extract structured data from repeated nodes

// Extract all link URLs and labels
const plan = new Planner()
  .in(loadFile('README.md'))
  .mapIn(parseMarkdown())
  .emit((out, $) =>
    out.add(
      'links',
      $.selectAll('link', node => node.text())
    )
  )
  .compile()

Extract top-level children

Use children() to extract each direct child of a node:

const plan = new Planner()
  .in(loadFile('README.md'))
  .mapIn(parseMarkdown())
  .emit((out, $) =>
    out.add(
      'blocks',
      $.children(node => node.text())
    )
  )
  .compile()

Extract frontmatter fields

// doc.md:
// ---
// title: My Post
// date: 2024-01-15
// tags:
//   - typescript
//   - origins
// ---
// # Content here

const plan = new Planner()
  .in(loadFile('doc.md'))
  .mapIn(parseMarkdown())
  .emit((out, $) => out.add('title', $.select('yaml').text()))
  .compile()

Combine Markdown with other sources

const plan = new Planner()
  .in(loadFile('README.md'))
  .mapIn(parseMarkdown())
  .emit((out, $) => out.add('title', $.select('heading').text()))
  .in(loadFile('package.json'))
  .mapIn(parseJson())
  .emit((out, $) =>
    out
      .add('version', $.get('version').string())
      .add('name', $.get('name').string())
  )
  .compile()

Standalone usage (without Planner)

For direct Markdown navigation:

import { parseMarkdownImpl, MarkdownNode } from '@origints/markdown'

const node = parseMarkdownImpl.execute(markdownString) as MarkdownNode

// Select nodes using CSS-like selectors
const headingResult = node.select('heading')
if (headingResult.ok) {
  console.log(headingResult.value.text())
}

// Select by attribute
const h1Result = node.select('heading[depth=1]')
const codeResult = node.select('code[lang="typescript"]')

// Nested selectors
const listItems = node.selectAll('list > listItem')

// Get all text content
console.log(node.text())

Typed node extraction

const headingResult = node.select('heading')
if (headingResult.ok) {
  const data = headingResult.value.asHeading()
  if (data.ok) {
    console.log(data.value.depth) // 1, 2, 3, etc.
  }
}

const linkResult = node.select('link')
if (linkResult.ok) {
  const data = linkResult.value.asLink()
  if (data.ok) {
    console.log(data.value.url)
  }
}

Converting to HTML

import { parseMarkdownImpl, toHtml } from '@origints/markdown'

const node = parseMarkdownImpl.execute('# Hello\n\nWorld') as MarkdownNode
const html = toHtml(node)
// <h1>Hello</h1>\n<p>World</p>

Frontmatter extraction (standalone)

import { parseMarkdownImpl, extractFrontmatter } from '@origints/markdown'

const node = parseMarkdownImpl.execute(markdownWithFrontmatter) as MarkdownNode
const frontmatter = extractFrontmatter(node)
if (frontmatter) {
  console.log(frontmatter.title)
}

API

| Export | Description | | -------------------------------------- | ----------------------------------------------------- | | parseMarkdown(options?) | Create a transform AST for use with Planner.mapIn() | | parseMarkdownImpl | Sync transform implementation (string input) | | parseMarkdownAsyncImpl | Async transform implementation (string or stream) | | registerMarkdownTransforms(registry) | Register all Markdown transforms with a registry | | MarkdownNode | Navigable wrapper with selector support | | toHtml(node) | Convert Markdown to HTML | | toJson(node, options?) | Convert MarkdownNode to JSON | | extractFrontmatter(node) | Extract YAML frontmatter |


License

MIT