
Security News
Socket Releases Free Certified Patches for Critical vm2 Sandbox Escape
A critical vm2 sandbox escape can allow untrusted JavaScript to break isolation and execute commands on the host Node.js process.
@stacksjs/ts-md
Advanced tools
A fast, native Bun-powered markdown parser with frontmatter support. Replaces gray-matter, marked, and yaml.
High-performance markdown parser and sanitizer built for Bun.
bun add @stacksjs/ts-md
import { parseMarkdown } from '@stacksjs/ts-md'
const html = parseMarkdown('# Hello **world**')
// <h1 id="hello-world">Hello <strong>world</strong></h1>
const html = parseMarkdown(markdown, {
gfm: true, // GitHub Flavored Markdown (default: true)
breaks: false, // Convert \n to <br> (default: false)
headerIds: true, // Generate header IDs (default: true)
headerPrefix: '', // Prefix for header IDs (default: '')
sanitize: false, // Sanitize HTML output (default: false)
highlight: (code, lang) => {
// Custom syntax highlighting
return highlightedCode
}
})
import { sanitizeHtml } from '@stacksjs/ts-md'
const clean = sanitizeHtml(userInput, {
allowedTags: ['p', 'strong', 'em', 'a', 'code'],
allowedAttributes: {
a: ['href', 'title']
},
allowedSchemes: ['http', 'https', 'mailto']
})
import { parseFrontmatter } from '@stacksjs/ts-md'
const content = `---
title: My Post
date: 2024-01-01
---
# Content here`
const { data, content: markdown } = parseFrontmatter(content)
console.log(data.title) // 'My Post'
Benchmark results against popular markdown parsers:
| Document Size | @stacksjs/ts-md | markdown-it | marked | showdown |
|---|---|---|---|---|
| Small (< 1KB) | 324B ops/sec | 112B ops/sec | 26B ops/sec | 14B ops/sec |
| Medium (~3KB) | 34.7B ops/sec | 17.7B ops/sec | 2.8B ops/sec | 2.8B ops/sec |
| Large (~50KB) | 1.81B ops/sec | 1.25B ops/sec | 16M ops/sec | 135M ops/sec |
Performance vs markdown-it:
The parser uses a flat token stream architecture with position-based parsing for optimal performance.
The markdown parser is built with several key optimizations:
parseMarkdown(markdown: string, options?: MarkdownOptions): stringParse markdown to HTML.
sanitizeHtml(html: string, options?: SanitizeOptions): stringSanitize HTML to prevent XSS attacks.
parseFrontmatter(content: string): { data: any, content: string }Extract and parse frontmatter from markdown content. Supports YAML, TOML, and JSON formats.
MIT
FAQs
A fast, native Bun-powered markdown parser with frontmatter support. Replaces gray-matter, marked, and yaml.
We found that @stacksjs/ts-md demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
A critical vm2 sandbox escape can allow untrusted JavaScript to break isolation and execute commands on the host Node.js process.

Research
Five malicious NuGet packages impersonate Chinese .NET libraries to deploy a stealer targeting browser credentials, crypto wallets, SSH keys, and local files.

Security News
pnpm 11 turns on a 1-day Minimum Release Age and blocks exotic subdeps by default, adding safeguards against fast-moving supply chain attacks.