markdown-it-import/tests/utils.ts

12 lines
464 B
TypeScript
Raw Permalink Normal View History

2024-10-07 09:11:19 +00:00
import { readFile } from 'node:fs/promises'
import { join } from 'node:path'
2023-11-16 14:13:19 +00:00
import MarkdownIt from 'markdown-it'
import { Options, importPlugin } from '../src/index.ts'
export async function render(path: string, options: Options | undefined = undefined): Promise<string> {
const filename = join('./tests/fixtures', path)
const input = await readFile(filename, 'utf-8')
const output = MarkdownIt().use(importPlugin, options).render(input)
return output
}