{"id":50902955,"url":"https://github.com/stacksjs/ts-md","last_synced_at":"2026-06-16T04:31:31.719Z","repository":{"id":323265280,"uuid":"1092674166","full_name":"stacksjs/ts-md","owner":"stacksjs","description":"Extremely performant markdown parser \u0026 compiler.","archived":false,"fork":false,"pushed_at":"2026-06-04T15:09:04.000Z","size":479,"stargazers_count":2,"open_issues_count":11,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-06-04T17:07:43.727Z","etag":null,"topics":["compiler","markdown","markdown-it","marked","parser"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/stacksjs.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":".github/CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE.md","code_of_conduct":".github/CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":".github/SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null},"funding":{"github":["stacksjs","chrisbbreuer"],"open_collective":"stacksjs"}},"created_at":"2025-11-09T04:30:09.000Z","updated_at":"2026-05-27T14:35:33.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/stacksjs/ts-md","commit_stats":null,"previous_names":["stacksjs/ts-markdown","stacksjs/ts-md"],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/stacksjs/ts-md","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stacksjs%2Fts-md","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stacksjs%2Fts-md/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stacksjs%2Fts-md/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stacksjs%2Fts-md/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/stacksjs","download_url":"https://codeload.github.com/stacksjs/ts-md/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stacksjs%2Fts-md/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34391702,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-16T02:00:06.860Z","response_time":126,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["compiler","markdown","markdown-it","marked","parser"],"created_at":"2026-06-16T04:31:29.790Z","updated_at":"2026-06-16T04:31:31.713Z","avatar_url":"https://github.com/stacksjs.png","language":"TypeScript","funding_links":["https://github.com/sponsors/stacksjs","https://github.com/sponsors/chrisbbreuer","https://opencollective.com/stacksjs"],"categories":[],"sub_categories":[],"readme":"# ts-md\n\nHigh-performance markdown parser and sanitizer built for Bun.\n\n## Features\n\n- GitHub Flavored Markdown (GFM) support\n- Tables, task lists, strikethrough\n- Header ID generation\n- Syntax highlighting support\n- HTML sanitization\n- Frontmatter parsing (YAML, TOML, JSON)\n\n## Installation\n\n```bash\nbun add @stacksjs/ts-md\n```\n\n## Usage\n\n### Basic Markdown Parsing\n\n```typescript\nimport { parseMarkdown } from '@stacksjs/ts-md'\n\nconst html = parseMarkdown('# Hello **world**')\n// \u003ch1 id=\"hello-world\"\u003eHello \u003cstrong\u003eworld\u003c/strong\u003e\u003c/h1\u003e\n```\n\n### With Options\n\n```typescript\nconst html = parseMarkdown(markdown, {\n  gfm: true,              // GitHub Flavored Markdown (default: true)\n  breaks: false,          // Convert \\n to \u003cbr\u003e (default: false)\n  headerIds: true,        // Generate header IDs (default: true)\n  headerPrefix: '',       // Prefix for header IDs (default: '')\n  sanitize: false,        // Sanitize HTML output (default: false)\n  highlight: (code, lang) =\u003e {\n    // Custom syntax highlighting\n    return highlightedCode\n  }\n})\n```\n\n### HTML Sanitization\n\n```typescript\nimport { sanitizeHtml } from '@stacksjs/ts-md'\n\nconst clean = sanitizeHtml(userInput, {\n  allowedTags: ['p', 'strong', 'em', 'a', 'code'],\n  allowedAttributes: {\n    a: ['href', 'title']\n  },\n  allowedSchemes: ['http', 'https', 'mailto']\n})\n```\n\n### Frontmatter Parsing\n\n```typescript\nimport { parseFrontmatter } from '@stacksjs/ts-md'\n\nconst content = `---\ntitle: My Post\ndate: 2024-01-01\n---\n\n# Content here`\n\nconst { data, content: markdown } = parseFrontmatter(content)\nconsole.log(data.title) // 'My Post'\n```\n\n## Performance\n\nBenchmark results against popular markdown parsers:\n\n| Document Size | @stacksjs/ts-md | markdown-it | marked | showdown |\n|--------------|-------------------|-------------|---------|----------|\n| Small (\u003c 1KB) | 324B ops/sec | 112B ops/sec | 26B ops/sec | 14B ops/sec |\n| Medium (~3KB) | 34.7B ops/sec | 17.7B ops/sec | 2.8B ops/sec | 2.8B ops/sec |\n| Large (~50KB) | 1.81B ops/sec | 1.25B ops/sec | 16M ops/sec | 135M ops/sec |\n\n**Performance vs markdown-it:**\n\n- Small documents: 2.89x faster\n- Medium documents: 1.96x faster\n- Large documents: 1.45x faster\n\nThe parser uses a flat token stream architecture with position-based parsing for optimal performance.\n\n## Architecture\n\nThe markdown parser is built with several key optimizations:\n\n- **Flat token stream**: Avoids nested object allocations for better cache locality\n- **Position-based parsing**: Minimizes string allocations with substring operations\n- **Optimized escapeHtml**: Fast-path for strings without special characters\n- **Direct inline matching**: Efficient emphasis and link parsing\n- **Recursive nested parsing**: Proper support for nested inline elements\n\n## API\n\n### `parseMarkdown(markdown: string, options?: MarkdownOptions): string`\n\nParse markdown to HTML.\n\n### `sanitizeHtml(html: string, options?: SanitizeOptions): string`\n\nSanitize HTML to prevent XSS attacks.\n\n### `parseFrontmatter(content: string): { data: any, content: string }`\n\nExtract and parse frontmatter from markdown content. Supports YAML, TOML, and JSON formats.\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstacksjs%2Fts-md","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstacksjs%2Fts-md","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstacksjs%2Fts-md/lists"}