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

@tangkikodo/mdiff

v0.1.0

Published

Framework-agnostic structural diff for rendered Markdown

Readme

mdiff

npm version License: MIT

Framework-agnostic structural diff for two Markdown strings. The library compares parsed GFM nodes rather than rendered HTML, so changes inside tables, lists, links, and other nested structures remain valid and renderable.

Install

npm install @tangkikodo/mdiff

The package is ESM-only and supports Node.js 20 or newer and modern browsers.

Usage

import { diffMarkdown } from "@tangkikodo/mdiff";

const diff = diffMarkdown(
  `
| Service | Status |
| --- | --- |
| API | healthy |
`,
  `
| Service | Status |
| --- | --- |
| API | degraded |
| Web | healthy |
`
);

console.log(diff.children[0]?.table?.rows);

diffMarkdown() returns data only. It does not emit HTML or depend on a UI framework.

Model

Every DiffNode has a stable ID for that invocation, its Markdown node type, its change state, and optional before and after snapshots:

type ChangeType = "unchanged" | "added" | "removed" | "modified";

Changed leaf nodes expose text segments. Renderers can map removed segments to <del> and added segments to <ins>.

Tables expose additional structure:

  • columns maps old and new indexes, including inserted, removed, or moved columns.
  • rows maps old and new zero-based row indexes. The header is row 0, so body rows start at 1.
  • Added or removed rows assign the same state to every cell in that row.
  • Modified cells contain their own recursive Markdown and text diff.

For an inline renderer, iterate the aligned rows and render removed rows before added rows, using the row or cell state for red/green styling. For a split renderer, order each side by beforeIndex or afterIndex and use the shared row and column IDs to align both sides.

Options

diffMarkdown(before, after, {
  blockMatchThreshold: 0.35,
  tableRowMatchThreshold: 0.3,
  tableColumnMatching: "header-similarity",
  characterRefinement: true
});
  • Text is compared by words, with automatic character-level refinement for similar replacements and CJK text.
  • Table columns use header similarity by default. Blank headers fall back to positional matching.
  • Ordinary block moves are represented as removal plus addition.
  • Raw HTML is converted to plain text nodes with escapedHtml: true and emits a warning. Consumers must still escape all text when rendering HTML.

Development

npm run check   # typecheck + test + build
npm run bench   # run benchmarks
npm run demo    # build + serve the local visual demo at http://localhost:3000

License

MIT © allmonday