diff --git a/bun.lockb b/bun.lockb index e13f334e..d29abf63 100755 Binary files a/bun.lockb and b/bun.lockb differ diff --git a/packages/nuemark/package.json b/packages/nuemark/package.json index 419b1d72..c63386ff 100644 --- a/packages/nuemark/package.json +++ b/packages/nuemark/package.json @@ -18,6 +18,9 @@ "js-yaml": "^4.1.0", "nue-glow": "*" }, + "devDependencies": { + "commonmark-spec": "^0.31.2" + }, "jest": { "setupFilesAfterEnv": [ "jest-extended/all", diff --git a/packages/nuemark/test/cmark.test.js b/packages/nuemark/test/cmark.test.js new file mode 100644 index 00000000..fb245b2a --- /dev/null +++ b/packages/nuemark/test/cmark.test.js @@ -0,0 +1,20 @@ +import { tests } from 'commonmark-spec' +import { nuemark } from '../index.js' + +tests.forEach(v => { + v.markdown = v.markdown.replaceAll('→', '\t').trimEnd() + v.html = v.html.replaceAll('→', '\t').trimEnd() +}) + +const skipSections = ['Tabs', 'Indented code blocks', 'Raw HTML', 'HTML blocks'] +const skipNumbers = [] + +for (const testCase of tests) { + if (skipSections.includes(testCase.section) || + skipNumbers.includes(testCase.number)) continue + + test(`cmark spec: ${testCase.section}; ${testCase.number}`, () => { + console.log(testCase.number, JSON.stringify(testCase.markdown)) + expect(nuemark(testCase.markdown)).toEqual(testCase.html) + }) +}