mirror of
https://github.com/markedjs/marked
synced 2024-11-22 17:37:24 +00:00
22ebdb2507
BREAKING CHANGE: deprecated options removed. See https://marked.js.org/using_advanced#options to see how to enable the removed options with extensions.
41 lines
1.1 KiB
JavaScript
Vendored
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);`);
|