marked/test/recheck.js
Tony Brix 22ebdb2507
fix: remove deprecated options (#2936)
BREAKING CHANGE: deprecated options removed. See https://marked.js.org/using_advanced#options to see how to enable the removed options with extensions.
2023-09-02 22:02:24 -06:00

41 lines
1.1 KiB
JavaScript
Vendored

import { inline, block } from '../src/rules.js';
import { check } from 'recheck';
function checkRegexp(obj, name) {
return Promise.all(Object.keys(obj).map(async(prop) => {
const item = obj[prop];
const itemName = `${name}.${prop}`;
let source = '';
let flags = '';
if (item instanceof RegExp) {
source = item.source;
flags = item.flags;
} else if (typeof item === 'string') {
source = item;
} else {
return checkRegexp(item, itemName);
}
const gfm = itemName.includes('.gfm.');
const pedantic = itemName.includes('.pedantic.');
const recheckObj = await check(source, flags);
if (recheckObj.status !== 'safe') {
console.log(`// ${itemName}: /${recheckObj.source}/${recheckObj.flags}`);
console.log(`// marked(${recheckObj.attack.pattern}, { pedantic: ${pedantic ? 'true' : 'false'}, gfm: ${gfm ? 'true' : 'false'} });`);
}
}));
}
console.log(`
import { marked } from './src/marked.js';
const start = Date.now();
`);
await Promise.all([
checkRegexp(inline, 'inline'),
checkRegexp(block, 'block')
]);
console.log(`
console.log(Date.now() - start);`);