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

tabmark-core

v0.1.2

Published

Core Markdown parser for Tabmark with hierarchical structure support

Downloads

13

Readme

tabmark-core

Read this in other languages: English | 日本語

Core Markdown parser for Tabmark with hierarchical structure support and safe HTML/Markdown escaping.

Features

  • 📝 Parse hierarchical Markdown (# → ## → ###)
  • 🔄 Convert between Markdown and grid data
  • 🛡️ HTML escaping (prevent XSS)
  • 🔒 Markdown syntax escaping (prevent structure breaking)
  • 📦 Preserve code fences (no escaping inside ```)
  • 🎯 YAML frontmatter support

Installation

npm install tabmark-core

Usage

Basic Example

import { MarkdownParser } from 'tabmark-core';

const parser = new MarkdownParser();

// Parse Markdown
const markdown = `
# products
## 0
### name
Product A
### price
$99.99
`;

const parsed = parser.parseHierarchical(markdown);
const gridData = parser.toGridData(parsed);

console.log(gridData);
// {
//   headers: ['name', 'price'],
//   rows: [['Product A', '$99.99']]
// }

// Convert back to Markdown
const newMarkdown = parser.fromGridData('products', gridData);

Default Behavior (Recommended)

const parser = new MarkdownParser();
// Default: escapeHtml=true, escapeMarkdown=false

const gridData = {
  headers: ['description'],
  rows: [['**Important**: [Details](https://example.com)'], ['<script>alert("xss")</script>']],
};

const markdown = parser.fromGridData('products', gridData);
// HTML escaped: <script> → &lt;script&gt; ✅
// Markdown preserved: **Important** → **Important** ✅

Strict Escaping (High Security)

const parser = new MarkdownParser({
  escapeHtml: true,
  escapeMarkdown: true, // Enable Markdown escaping
});

const gridData = {
  headers: ['description'],
  rows: [['**bold** and # heading']],
};

const markdown = parser.fromGridData('products', gridData);
// Markdown escaped: **bold** → \*\*bold\*\*
// Heading escaped: # → \#

API

MarkdownParser

Constructor

new MarkdownParser(options?: ParserOptions)

Options:

  • escapeHtml (boolean, default: true) - Escape HTML special characters (XSS prevention)
  • escapeMarkdown (boolean, default: false) - Escape Markdown syntax (preserve formatting)

Methods

parseHierarchical(content: string): ParsedMarkdown

Parse hierarchical Markdown structure.

toGridData(parsed: ParsedMarkdown): GridData

Convert parsed Markdown to grid format.

fromGridData(sheetName: string, gridData: GridData, frontmatter?: Frontmatter): string

Convert grid data to Markdown.

Escaping Functions

import { escapeHtml, escapeMarkdownSyntax } from 'tabmark-core';

escapeHtml('<script>alert("xss")</script>');
// → '&lt;script&gt;alert(&quot;xss&quot;)&lt;/script&gt;'

escapeMarkdownSyntax('# Heading');
// → '\# Heading'

// Code fences are preserved
escapeMarkdownSyntax('```\n# Not escaped\n```');
// → '```\n# Not escaped\n```'

Types

interface GridData {
  headers: string[];
  rows: string[][];
}

interface ParsedMarkdown {
  frontmatter: Frontmatter | null;
  sheets: {
    [sheetName: string]: {
      type: 'hierarchical';
      rows: {
        [rowIndex: string]: {
          [columnName: string]: string;
        };
      };
    };
  };
}

interface ParserOptions {
  escapeHtml?: boolean;
  escapeMarkdown?: boolean;
}

Multi-line Cells

Newlines in cell values are converted to <br> tags:

const gridData = {
  headers: ['description'],
  rows: [['Line 1\nLine 2\nLine 3']],
};

const markdown = parser.fromGridData('sheet', gridData);
// ### description
// Line 1<br>Line 2<br>Line 3

License

MIT