blob: c52955f8390200734908e9558d51f21902538d86 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
import assert from 'node:assert/strict';
import { describe, it } from 'node:test';
import { fileURLToPath } from 'node:url';
import { createMarkdownProcessor } from '../dist/index.js';
describe('plugins', () => {
it('should be able to get file path when passing fileURL', async () => {
let context;
const processor = await createMarkdownProcessor({
remarkPlugins: [
() => {
const transformer = (_tree, file) => {
context = file;
};
return transformer;
},
],
});
await processor.render(`test`, {
fileURL: new URL('virtual.md', import.meta.url),
});
assert.ok(typeof context === 'object');
assert.equal(context.path, fileURLToPath(new URL('virtual.md', import.meta.url)));
});
});
|