import * as fs from 'node:fs' import * as os from 'node:os' import * as path from 'node:path' import * as assert from 'remix/assert' import { describe, it, type TestContext } from 'remix/test' import { renderMarkdownFile, type DocFile } from './markdown.ts' describe('renderMarkdownFile()', () => { it('adds linked heading IDs and collects h2 and h3 headings for the table of contents', async (t) => { let result = await renderMarkdown( t, '# API Name\n\n## Summary\n\n### Detail\n\n## Summary\n\n## `Code` and *emphasis*\n', ) assert.equal(result.html.includes('
Code and emphasis',
})
})
it('renders highlighted code blocks with the shared copy contract', async (t) => {
let result = await renderMarkdown(t, '```ts\nlet count = 1\n```\n')
assert.match(result.html, /]*data-code-block-copy/)
assert.match(result.html, /aria-label="Copy code to clipboard"/)
})
it('uses and removes explicit heading IDs', async (t) => {
let result = await renderMarkdown(t, '## Custom title {#custom-id}\n')
assert.deepEqual(result.headings, [
{
id: 'custom-id',
depth: 2,
title: 'Custom title',
titleHtml: 'Custom title',
},
])
assert.equal(result.html.includes(''), true)
assert.equal(result.html.includes('{#custom-id}'), false)
})
it('preserves raw HTML', async (t) => {
let result = await renderMarkdown(t, '\n')
assert.match(result.html, /