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

@specify-text/parser

v0.2.0

Published

DSL parser for specify-text — zero-dependency tagged-text AST generator

Downloads

22

Readme

@specify-text/parser

DSL parser for specify-text — a zero-dependency tagged-text AST generator.

Parses text containing [display text](type:value) syntax into structured segments, with built-in LRU caching for performance.

Installation

npm install @specify-text/parser

API

parse(text, options?)

Parses a string into an array of Segment or plain string items.

import { parse } from '@specify-text/parser';

const result = parse('Hello [world](bold:true)');
// [{ text: 'world', type: 'bold', typeVal: 'true' }]
  • options.regex — custom RegExp for pre-checking if text contains tags.
  • options.parse — fully custom parse function (text: string) => Segment[].

parseDeep(text, options?)

Recursively parses nested tagged text into a tree of DeepSegment objects. Inner tagged text (e.g. [text](type:val) inside a segment's text) is automatically parsed into the children array.

import { parseDeep } from '@specify-text/parser';

const result = parseDeep('[[Bold](strong:true)](colorful:red)');
// [
//   '',
//   {
//     text: '[Bold](strong:true)',
//     type: 'colorful',
//     typeVal: 'red',
//     children: [
//       '',
//       { text: 'Bold', type: 'strong', typeVal: 'true' }
//     ]
//   }
// ]

### `isValidText(text, regex?)`

Returns `true` if the text contains any tag patterns.

```ts
import { isValidText } from '@specify-text/parser';

isValidText('Hello [world](bold:true)'); // true
isValidText('Plain text');               // false

escape(text) / unescape(text)

Escape or unescape bracket characters in text.

import { escape, unescape } from '@specify-text/parser';

escape('hello [world]');   // 'hello \\[world\\]'
unescape('hello \\[world\\]'); // 'hello [world]'

LRUCache

Generic LRU cache class exported for advanced use.

import { LRUCache } from '@specify-text/parser';

const cache = new LRUCache<string, number>(100);
cache.put('key', 42);
cache.get('key'); // 42

clearCache()

Clears the internal parse result cache.

import { clearCache } from '@specify-text/parser';
clearCache();

printDeepAst(text, options?) / printDeepAstToConsole(text, options?)

Like printAst / printAstToConsole, but uses parseDeep internally to visualize the full nested AST tree with indented children.

Types

  • Segment{ text: string; type?: string; typeVal?: string }
  • DeepSegmentSegment with optional children: (DeepSegment | string)[]
  • ParseOptions{ regex?: RegExp; parse?: (text: string) => Segment[] }