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

@gram-lang/renderer

v1.0.0

Published

Universal Markdown and HTML AST renderer for the Gram recipe language.

Readme

@gram-lang/renderer

npm version License: GPL v3

Part of the Gram monorepo.

The universal renderer for the Gram recipe language. It takes compiled or analyzed recipe ASTs and renders them into structured Markdown or semantic HTML with support for custom visual elements and class names.


📚 General Documentation

For full syntax specifications, grammar details, cheatsheets, and best practices, please refer to the Gram Documentation.


🛠️ Installation

npm install @gram-lang/renderer
# or
bun add @gram-lang/renderer

⚡ Usage

import {
  toMarkdown,
  toHTML,
  toPrintHTML,
  toGanttHTML,
  attachGanttInteractivity
} from '@gram-lang/renderer';

const recipe = {
  title: "Simple Crepes",
  metrics: { totalTime: 30, activeTime: 10 },
  shopping_list: [
    { id: "flour", qty: 200, unit: "g" }
  ],
  sections: [
    {
      title: "Preparation",
      steps: [
        { type: "text", value: "Whisk everything together." }
      ]
    }
  ]
};

// 1. Simple Markdown rendering
const markdown = toMarkdown(recipe);

// 2. Customized HTML rendering with custom icons (Inversion of Control)
const html = toHTML(recipe, {
  icons: {
    clock: '<span class="icon-clock">🕒</span>',
    fire: '<span class="icon-fire">🔥</span>'
  },
  classes: {
    recipeTitle: "custom-title",
    recipeMeta: "flex gap-2"
  }
});

// 3. Print-optimized HTML rendering (self-contained, single-page layout)
const printHtml = toPrintHTML(recipe);

// 4. Gantt Chart timeline rendering (HTML fragment + client-side interactivity)
const ganttHtml = toGanttHTML(recipe, { lang: 'en' });
const container = document.getElementById('gantt-container');
container.innerHTML = ganttHtml;

const handle = attachGanttInteractivity(container, {
  timeMode: 'forward',   // 'forward' (T+), 'reverse' (T-), or 'target'
  targetTime: '19:30',   // Target serve time when timeMode is 'target'
  isCompactMode: false   // Toggle compact row height
});

🏗️ Structure

  • src/index.ts: The main entry point exporting public APIs.
  • src/types.ts: TypeScript interfaces for RendererOptions, RendererIcons, and RendererClasses.
  • src/utils.ts: Common helpers (decimal-to-fraction formatting, HTML escaping, duration formatting).
  • src/gantt/: Gantt chart layout computation, HTML fragment rendering, and event delegation interactivity (layout.ts, render.ts, interactivity.ts, types.ts).
  • src/formatters/element.ts: Universal formatter for individual AST nodes (ingredients, cookware, timers, alternative groups).
  • src/formatters/markdown.ts: Orchestrates Markdown generation for full recipes.
  • src/formatters/html.ts: Orchestrates HTML generation for full recipes using classes and icons injection.
  • src/formatters/print.ts: Orchestrates self-contained, print-optimized HTML generation (toPrintHTML).
  • gantt.css: Stylesheet for the Gantt chart timeline component.

📄 License

This project is licensed under the GPL-3.0 License.