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

@tailmark/core

v0.1.1

Published

React-free streaming Markdown primitives for Tailmark.

Downloads

340

Readme

@tailmark/core

React-free primitives for windowed repair and incremental block lexing of growing Markdown.

bun add @tailmark/core

Session API

import { createLexSession } from "@tailmark/core";

const session = createLexSession();

const first = session.update("# Result\n\nStreaming para");
const second = session.update("# Result\n\nStreaming paragraph complete.");

console.log(second.blocks, second.stableCount, second.openFence);
session.reset();

createLexSession retains an opaque incremental cache. Use lexMarkdownBlocks(previousCache, content) when cache ownership needs to remain with your application, or repairMarkdown(content) when only streaming repairs are needed.

Windowed repair semantics

Default repair starts at the final safe, fence-aware blank-line window. Bytes before that window stay raw and cannot influence repair decisions in the open tail. The one-shot and session APIs use the same definition, so their equivalence is structural. On LF append-only streams with reusable boundaries, the repair and lex stages both do O(open tail) work.

This is intentionally different from applying Remend to the whole document on every update. A tail-local construct is repaired from tail-local context, and a synthetic repair can revert to its original raw bytes after that region settles outside the window.

The fallbacks are explicit:

  • Supplying any custom repairs handler preserves its full-string contract, so repair and lex use the whole-document pipeline on every update.
  • Content containing CRLF or CR uses the whole-document pipeline because Marked normalizes token raw offsets. Normalize line endings to LF upstream to use the windowed path.
  • Documents made entirely from indented code may not expose a safe reusable boundary. They remain correct and honestly fall back to full work.
  • Non-append edits, global link-definition state, or a failed boundary check also retreat to the correct full pipeline.

Custom repairs

Repairs run after Tailmark's built-in Remend pass, in the array order supplied. The priority field is accepted for Remend compatibility but does not reorder caller repairs.

import { createLexSession, type RepairHandler } from "@tailmark/core";

const closeNextSteps: RepairHandler = {
  name: "close-next-steps",
  handle(markdown) {
    const opening = "<TRAYCER_NEXT_STEPS>";
    const closing = "</TRAYCER_NEXT_STEPS>";
    if (!markdown.includes(opening) || markdown.includes(closing)) return markdown;
    return `${markdown}\n${closing}`;
  },
};

const session = createLexSession({ repairs: [closeNextSteps] });
const result = session.update("<TRAYCER_NEXT_STEPS>\n- Review the diff");

Streaming-equivalence guarantee

For every prefix, the blocks returned by a cache-threaded update are identical to a one-shot windowed repair and full lex of that prefix. Tailmark tests this character by character over growing tables, loose and nested lists, Setext headings, lazy continuations, duplicate link definitions, blockquotes, and open code fences in test/lexer.test.ts. The same suite contains timing-free work bounds for the windowed repair and lex paths, plus regressions for every documented fallback.