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

markdown-or-chalk

v0.3.2

Published

Prints through a single interface as Chalk enhanced CLI output or as Markdown

Readme

Markdown or Chalk

Print through a single interface as Markdown or terminal output (ansi / chalk).

npm version npm downloads neostandard javascript style Module type: ESM Types in JS Ask DeepWiki

Usage

The core idea: keep your formatting calls the same, and decide output style at runtime.

import { getOutputStyler } from 'markdown-or-chalk';

const printAsMarkdown = true;

const format = getOutputStyler(printAsMarkdown);

format.header('Wow');

This lets one code path support terminal UX and markdown/report output.

API

getOutputStyler(style)

Returns a formatter for one of these styles:

  • 'markdown' – Markdown output
  • 'ansi' – ANSI terminal output
  • 'chalk' – Chalk-flavored terminal output (legacy compatibility; prefer 'ansi')

getMdastOutputter(style)

Returns only the fromMdast renderer function for the selected style.

Instance Methods

| Method | Description | | -------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------ | | header(text, level?) | Heading (1-6, default 1). Markdown: # text. Terminal: bold+underline | | bold(text) | Bold. Markdown: **text**. Terminal: bold | | dim(text) | Dim/italic. Markdown: _text_. Terminal: dim | | italic(text) | Italic. Markdown: _text_. Terminal: italic | | strikethrough(text) | Strikethrough. Markdown: ~~text~~. Terminal: strikethrough | | code(text) | Inline code. Markdown: `text`. Terminal: plain text | | hyperlink(text, url, options?) | Link. Markdown: [text](url) (options ignored). Terminal: terminal link. Options: { fallback?: boolean, fallbackToUrl?: boolean } | | list(items) | Bullet list. Markdown: * item. Terminal: - item | | indent(text, level?) | Indent by level × 2 spaces (default level is 1) | | json(value) | JSON output. Markdown: fenced code block. Terminal: plain JSON | | table(rows, align?, options?) | Table. Markdown: GFM table (supports { tablePipeAlign?: boolean }). Terminal: aligned columns | | fromMdast(node, options?) | Render any mdast node to string |

Getters

| Getter | Returns | | ----------------- | ------------------------------------------------------------- | | type | 'markdown', 'ansi', or 'chalk' | | logSymbols | {info, success, warning, error} — emoji or styled symbols | | logSymbolsMdast | {info, success, warning, error} — mdast-compatible symbols | | chalk | ChalkInstance in chalk mode (deprecated, prefer 'ansi') |

Exported Helpers

| Helper | Description | | -------------------------------------- | -------------------------------- | | mdastTableHelper(rows, align?) | Build an mdast Table node | | mdastListHelper(items) | Build an mdast List node | | mdastLinkify(value, url, skipLinks?) | Build an mdast Link or Text node |

Advanced: mdast helpers

Compose fromMdast with the mdast helpers to build rich structured output:

import { getMdastOutputter, mdastListHelper, mdastLinkify } from 'markdown-or-chalk';

const fromMdast = getMdastOutputter('markdown');

const list = mdastListHelper([
  [mdastLinkify('chalk', 'https://www.npmjs.com/package/chalk')],
  [mdastLinkify('mdast', 'https://www.npmjs.com/package/mdast')],
  ['plain text item'],
]);

console.log(fromMdast(list));
// * [chalk](https://www.npmjs.com/package/chalk)
// * [mdast](https://www.npmjs.com/package/mdast)
// * plain text item

Migration: 0.2.x → 0.3.x

What changed

  • Constructor-based usage was replaced with a selector function:
    • getOutputStyler('markdown' | 'ansi' | 'chalk')
  • getMdastOutputter('markdown' | 'ansi' | 'chalk') was added as a convenience for mdast-only flows.
    • Existing getOutputStyler(style).fromMdast(node) usage still works.
  • Style is now selected using explicit string modes ('markdown', 'ansi', 'chalk').
  • type is the mode discriminator.
  • chalk getter is legacy (deprecated) and only relevant in 'chalk' mode (prefer 'ansi').

Before / after

// Before (0.2.x)
import MarkdownOrChalk from 'markdown-or-chalk';

const formatMd = new MarkdownOrChalk(true);
const formatCli = new MarkdownOrChalk(false);
// After (0.3.x)
import { getOutputStyler } from 'markdown-or-chalk';

const formatMd = getOutputStyler('markdown');
const formatCli = getOutputStyler('ansi');
// After (0.3.x), mdast-only outputter
import { getMdastOutputter } from 'markdown-or-chalk';

const fromMdast = getMdastOutputter('markdown');
const output = fromMdast(node);

Migration checklist

  • Replace constructor usage with getOutputStyler() / getMdastOutputter().
  • Replace boolean mode selection with explicit style strings.
  • If branching by mode, check .type.
  • Keep .chalk usage only for legacy paths.
  • Re-check output-sensitive behavior:
    • hyperlink() in markdown mode
    • list() formatting
    • table() formatting

Used by

See also