usepages-render-blocks
Version:
A renderer of blocks for https://usePages.today
75 lines (72 loc) • 954 B
JavaScript
const RESERVED = [
'break',
'case',
'class',
'catch',
'const',
'continue',
'debugger',
'default',
'delete',
'do',
'else',
'export',
'extends',
'finally',
'for',
'function',
'if',
'import',
'in',
'new',
'return',
'super',
'switch',
'this',
'throw',
'try',
'var',
'void',
'while',
'with',
'yield',
'=>',
'abstract',
'boolean',
'byte',
'char',
'double',
'final',
'float',
'goto',
'int',
'long',
'native',
'short',
'synchronized',
'throws',
'transient',
'volatile',
'async',
'await',
'implements',
'package',
'protected',
'static',
'let',
'interface',
'private',
'public',
'Boolean',
'Number',
'RegExp',
'String'
].map(w => `\\s+${w}\\s+|^${w}$|\\s+${w}$|^${w}\\s+`).join('|');
const SYMBOLS = [
';',
'\\(',
'\\)',
'window',
'[\\s+|\\w+]=[\\s+|\\w+]'
].join('|');
export default new RegExp(`${RESERVED}|${SYMBOLS}`, 'i');