import { describe, expect, it } from 'vitest' import { parseMarkdown, renderHtml } from '../src/index.js' describe('docs markdown fixtures', () => { it('extracts frontmatter without rendering it', () => { const document = parseMarkdown('---\ntitle: Test\n---\n\n# Title') expect(document.frontmatter).toBe('title: Test') expect(renderHtml(document)).toBe('
`) }) it('resolves reference links and images in comparison tables', () => { const markdown = `| Product | Stars | Bundle | Routing | | --- | --- | --- | --- | | TanStack Start | [![][stars-tanstack-router]][gh-tanstack-router] | [![][bp-tanstack-router]][bpl-tanstack-router] | **Routing Features** [_(See Full Comparison)_][router-comparison] | | Next.js [_(Website)_][nextjs] | [![][stars-nextjs]][gh-nextjs] | ❓ | ✅ File-based App Router | [bp-tanstack-router]: https://badgen.net/bundlephobia/minzip/@tanstack/react-router [bpl-tanstack-router]: https://bundlephobia.com/result?p=@tanstack/react-router [gh-tanstack-router]: https://github.com/tanstack/router [stars-tanstack-router]: https://img.shields.io/github/stars/tanstack/router?label=%F0%9F%8C%9F [router-comparison]: /router/latest/docs/framework/react/comparison [nextjs]: https://nextjs.org/ [gh-nextjs]: https://github.com/vercel/next.js [stars-nextjs]: https://img.shields.io/github/stars/vercel/next.js?label=%F0%9F%8C%9F` const html = renderHtml(markdown) expect(html).toContain( 'Note
- one
- two
This has **open strong and [bad](https://example.com
<script>alert(1)</script>
`) }) it('supports lightweight extension hooks', () => { const html = renderHtml(':::note\nUse cache\n:::', { extensions: [ { name: 'note', parseBlock(context) { if (context.lines[context.index] !== ':::note') return undefined const body = context.lines[context.index + 1] ?? '' context.consume(3) return { type: 'paragraph', children: [{ type: 'strong', children: context.parseInline(body) }], } }, }, ], }) expect(html).toBe('Use cache
') }) })