Diffdown is a real-time collaborative Markdown editor/previewer built on the AT Protocol diffdown.com
at 4fbddf8a36e2f679a0f490560cd9d74df92ba020 29 lines 880 B view raw
1import {parser, configureNesting} from "../dist/index.js" 2import {parser as jsParser} from "@lezer/javascript" 3import {fileTests} from "@lezer/generator/dist/test" 4 5import * as fs from "fs" 6import * as path from "path" 7import {fileURLToPath} from "url" 8let caseDir = path.dirname(fileURLToPath(import.meta.url)) 9 10let mixed = parser.configure({ 11 wrap: configureNesting([{ 12 tag: "script", 13 attrs(attrs) { 14 return !attrs.type || /^(?:text|application)\/(?:x-)?(?:java|ecma)script$|^module$|^$/i.test(attrs.type) 15 }, 16 parser: jsParser 17 }]) 18}) 19 20for (let file of fs.readdirSync(caseDir)) { 21 if (!/\.txt$/.test(file)) continue 22 let name = /^[^\.]*/.exec(file)[0] 23 describe(name, () => { 24 let p = name == "mixed" ? mixed : parser 25 for (let {name, run} of fileTests(fs.readFileSync(path.join(caseDir, file), "utf8"), file)) 26 it(name, () => run(p)) 27 }) 28} 29