import assert from 'node:assert/strict'; import test from 'node:test'; import { renderMarkdown } from '../src/lib/markdown'; import type { Article } from '../src/lib/api'; const article = (markdown: string): Article => ({ meta: { title: 'Test', slug: 'alice~first', author: 'alice', description: '', tags: [], cover: null, created_at: '', date: '', updated: '', status: 'published' }, markdown, format: 'markdown', entry: 'main.md', pages: [{ name: 'main.md', url: '' }, { name: 'chapter.md', url: '' }], assets: [{ name: 'cover.png', url: '' }], }); test('rewrites only registered documents and assets, preserves anchors and creates heading IDs', () => { const html = renderMarkdown(article('# Intro\n[Next](./chapter.md#details)\n[Back](main.md)\n'), 'alice~first'); assert.match(html, /