forked from mxx1111/mdlook
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathverify-preview.mjs
More file actions
27 lines (23 loc) · 837 Bytes
/
Copy pathverify-preview.mjs
File metadata and controls
27 lines (23 loc) · 837 Bytes
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
/**
* Verify bundled previewRenderer.js can render HTML in Node.
*/
import { createRequire } from 'node:module'
import path from 'node:path'
import { fileURLToPath } from 'node:url'
const __dirname = path.dirname(fileURLToPath(import.meta.url))
const require = createRequire(import.meta.url)
const { buildPreviewHtml } = require(path.join(__dirname, `..`, `dist`, `previewRenderer.js`))
const html = buildPreviewHtml({
markdown: `# Test\n\n[link](https://example.com)`,
primaryColor: `#000000`,
fontFamily: `sans-serif`,
fontSize: `16px`,
theme: `default`,
countStatus: false,
isMacCodeBlock: false,
citeStatus: false,
})
if (!html.includes(`Test`) || !html.includes(`example.com`)) {
throw new Error(`previewRenderer output missing expected content`)
}
console.log(`✓ previewRenderer.js renders HTML in Node`)