feat: add md<->html document converters
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
@@ -74,4 +74,30 @@ describe('document converters', () => {
|
||||
const detected = await detectInputMime(outputPath);
|
||||
expect(detected.mime).toBe('application/pdf');
|
||||
}, 20000);
|
||||
|
||||
it('converts MD to HTML', async () => {
|
||||
const inputPath = path.join(tmpDir, 'fixture.md');
|
||||
await fs.writeFile(inputPath, '# Heading\n\nSome **bold** text.');
|
||||
const outputPath = path.join(tmpDir, 'from-md.html');
|
||||
const entry = resolve('md', 'html');
|
||||
|
||||
await entry.convert(inputPath, outputPath);
|
||||
|
||||
const html = await fs.readFile(outputPath, 'utf8');
|
||||
expect(html).toContain('<h1>Heading</h1>');
|
||||
expect(html).toContain('<strong>bold</strong>');
|
||||
});
|
||||
|
||||
it('converts HTML to MD', async () => {
|
||||
const inputPath = path.join(tmpDir, 'fixture-for-md.html');
|
||||
await fs.writeFile(inputPath, '<h1>Heading</h1><p>Some <strong>bold</strong> text.</p>');
|
||||
const outputPath = path.join(tmpDir, 'from-html.md');
|
||||
const entry = resolve('html', 'md');
|
||||
|
||||
await entry.convert(inputPath, outputPath);
|
||||
|
||||
const markdown = await fs.readFile(outputPath, 'utf8');
|
||||
expect(markdown).toContain('# Heading');
|
||||
expect(markdown).toContain('**bold**');
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user