remark-agda/test/index.test.ts

43 lines
1.1 KiB
TypeScript
Raw Permalink Normal View History

2024-09-12 23:38:07 +00:00
import { test } from "bun:test";
import { resolve, dirname, join } from "node:path";
import { unified } from "unified";
import remarkParse from "remark-parse";
import remarkRehype from "remark-rehype";
import rehypeStringify from "rehype-stringify";
2024-09-13 00:43:27 +00:00
import rehypeRaw from "rehype-raw";
import { read } from "to-vfile";
import remarkAgda, { type RemarkAgdaOptions } from "../src";
2024-09-12 23:38:07 +00:00
test("simple case", async () => {
const file = join(dirname(import.meta.path), "Simple.lagda.md");
2024-09-13 00:43:27 +00:00
const vfile = await read(file);
2024-09-12 23:38:07 +00:00
2024-09-13 00:43:27 +00:00
const options: RemarkAgdaOptions = {
destDir: join(dirname(import.meta.path), "results"),
transformHtml: (src) => {
return `
2024-09-12 23:38:07 +00:00
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="generated/agda/Agda.css" />
</head>
<body>
<pre class="Agda">
${src}
</pre>
</body>
</html>
`;
2024-09-13 00:43:27 +00:00
},
};
await unified()
.use(remarkParse)
.use(remarkAgda, options)
.use(remarkRehype, { allowDangerousHtml: true })
.use(rehypeRaw)
2024-09-12 23:38:07 +00:00
.use(rehypeStringify)
.process(vfile);
});