magicpen-prism
Advanced tools
Comparing version 4.1.1 to 5.0.0
(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.magicPenPrism = f()}})(function(){var define,module,exports;return (function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:[function(require,module,exports){ | ||
(function (global){ | ||
(function (global){(function (){ | ||
var oldPrismGlobal = global.Prism; | ||
@@ -134,3 +134,3 @@ var prism = (global.Prism = require(5)); | ||
}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) | ||
}).call(this)}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) | ||
},{"2":2,"3":3,"4":4,"5":5,"6":6}],2:[function(require,module,exports){ | ||
@@ -149,12 +149,16 @@ /** | ||
Prism.languages.csp = { | ||
'directive': { | ||
pattern: /\b(?:base-uri|block-all-mixed-content|(?:child|connect|default|font|frame|img|manifest|media|object|script|style|worker)-src|disown-opener|form-action|frame-ancestors|plugin-types|referrer|reflected-xss|report-to|report-uri|require-sri-for|sandbox|upgrade-insecure-requests)\b/i, | ||
'directive': { | ||
pattern: /(^|[^-\da-z])(?:base-uri|block-all-mixed-content|(?:child|connect|default|font|frame|img|manifest|media|object|prefetch|script|style|worker)-src|disown-opener|form-action|frame-(?:ancestors|options)|input-protection(?:-(?:clip|selectors))?|navigate-to|plugin-types|policy-uri|referrer|reflected-xss|report-(?:to|uri)|require-sri-for|sandbox|(?:script|style)-src-(?:attr|elem)|upgrade-insecure-requests)(?=[^-\da-z]|$)/i, | ||
lookbehind: true, | ||
alias: 'keyword' | ||
}, | ||
'safe': { | ||
pattern: /'(?:self|none|strict-dynamic|(?:nonce-|sha(?:256|384|512)-)[a-zA-Z\d+=/]+)'/, | ||
// CSP2 hashes and nonces are base64 values. CSP3 accepts both base64 and base64url values. | ||
// See https://tools.ietf.org/html/rfc4648#section-4 | ||
// See https://tools.ietf.org/html/rfc4648#section-5 | ||
pattern: /'(?:deny|none|report-sample|self|strict-dynamic|top-only|(?:nonce|sha(?:256|384|512))-[-+/\d=_a-z]+)'/i, | ||
alias: 'selector' | ||
}, | ||
'unsafe': { | ||
pattern: /(?:'unsafe-inline'|'unsafe-eval'|'unsafe-hashed-attributes'|\*)/, | ||
pattern: /(?:'unsafe-(?:allow-redirects|dynamic|eval|hash-attributes|hashed-attributes|hashes|inline)'|\*)/i, | ||
alias: 'function' | ||
@@ -214,6 +218,6 @@ } | ||
Prism.languages.jsx = Prism.languages.extend('markup', javascript); | ||
Prism.languages.jsx.tag.pattern= /<\/?(?:[\w.:-]+\s*(?:\s+(?:[\w.:$-]+(?:=(?:("|')(?:\\[\s\S]|(?!\1)[^\\])*\1|[^\s{'">=]+|\{(?:\{(?:\{[^{}]*\}|[^{}])*\}|[^{}])+\}))?|\{\s*\.{3}\s*[a-z_$][\w$]*(?:\.[a-z_$][\w$]*)*\s*\}))*\s*\/?)?>/i; | ||
Prism.languages.jsx.tag.pattern = /<\/?(?:[\w.:-]+(?:\s+(?:[\w.:$-]+(?:=(?:"(?:\\[^]|[^\\"])*"|'(?:\\[^]|[^\\'])*'|[^\s{'">=]+|\{(?:\{(?:\{[^{}]*\}|[^{}])*\}|[^{}])+\}))?|\{\s*\.{3}\s*[a-z_$][\w$]*(?:\.[a-z_$][\w$]*)*\s*\}))*\s*\/?)?>/i; | ||
Prism.languages.jsx.tag.inside['tag'].pattern = /^<\/?[^\s>\/]*/i; | ||
Prism.languages.jsx.tag.inside['attr-value'].pattern = /=(?!\{)(?:("|')(?:\\[\s\S]|(?!\1)[^\\])*\1|[^\s'">]+)/i; | ||
Prism.languages.jsx.tag.inside['attr-value'].pattern = /=(?!\{)(?:"(?:\\[^]|[^\\"])*"|'(?:\\[^]|[^\\'])*'|[^\s'">]+)/i; | ||
Prism.languages.jsx.tag.inside['tag'].inside['class-name'] = /^[A-Z]\w*(?:\.[A-Z]\w*)*$/; | ||
@@ -338,3 +342,3 @@ | ||
},{}],5:[function(require,module,exports){ | ||
(function (global){ | ||
(function (global){(function (){ | ||
@@ -802,3 +806,4 @@ /* ********************************************** | ||
* 1. `before-highlightall` | ||
* 2. All hooks of {@link Prism.highlightElement} for each element. | ||
* 2. `before-all-elements-highlight` | ||
* 3. All hooks of {@link Prism.highlightElement} for each element. | ||
* | ||
@@ -835,3 +840,3 @@ * @param {ParentNode} container The root element, whose descendants that have a `.language-xxxx` class will be highlighted. | ||
* 2. `before-highlight` | ||
* 3. All hooks of {@link Prism.highlight}. These hooks will only be run by the current worker if `async` is `true`. | ||
* 3. All hooks of {@link Prism.highlight}. These hooks will be run by an asynchronous worker if `async` is `true`. | ||
* 4. `before-insert` | ||
@@ -841,2 +846,5 @@ * 5. `after-highlight` | ||
* | ||
* Some the above hooks will be skipped if the element doesn't contain any text or there is no grammar loaded for | ||
* the element's language. | ||
* | ||
* @param {Element} element The element containing the code. | ||
@@ -1170,3 +1178,22 @@ * It must have a class of `language-xxxx` to be processed, where `xxxx` is a valid language identifier. | ||
/** | ||
* @param {RegExp} pattern | ||
* @param {number} pos | ||
* @param {string} text | ||
* @param {boolean} lookbehind | ||
* @returns {RegExpExecArray | null} | ||
*/ | ||
function matchPattern(pattern, pos, text, lookbehind) { | ||
pattern.lastIndex = pos; | ||
var match = pattern.exec(text); | ||
if (match && lookbehind && match[1]) { | ||
// change the match to remove the text matched by the Prism lookbehind group | ||
var lookbehindLength = match[1].length; | ||
match.index += lookbehindLength; | ||
match[0] = match[0].slice(lookbehindLength); | ||
} | ||
return match; | ||
} | ||
/** | ||
* @param {string} text | ||
* @param {LinkedList<string | Token>} tokenList | ||
@@ -1202,3 +1229,2 @@ * @param {any} grammar | ||
greedy = !!patternObj.greedy, | ||
lookbehindLength = 0, | ||
alias = patternObj.alias; | ||
@@ -1237,6 +1263,6 @@ | ||
var removeCount = 1; // this is the to parameter of removeBetween | ||
var match; | ||
if (greedy && currentNode != tokenList.tail.prev) { | ||
pattern.lastIndex = pos; | ||
var match = pattern.exec(text); | ||
if (greedy) { | ||
match = matchPattern(pattern, pos, text, lookbehind); | ||
if (!match) { | ||
@@ -1246,3 +1272,3 @@ break; | ||
var from = match.index + (lookbehind && match[1] ? match[1].length : 0); | ||
var from = match.index; | ||
var to = match.index + match[0].length; | ||
@@ -1281,20 +1307,12 @@ var p = pos; | ||
} else { | ||
pattern.lastIndex = 0; | ||
var match = pattern.exec(str); | ||
match = matchPattern(pattern, 0, str, lookbehind); | ||
if (!match) { | ||
continue; | ||
} | ||
} | ||
if (!match) { | ||
continue; | ||
} | ||
if (lookbehind) { | ||
lookbehindLength = match[1] ? match[1].length : 0; | ||
} | ||
var from = match.index + lookbehindLength, | ||
matchStr = match[0].slice(lookbehindLength), | ||
to = from + matchStr.length, | ||
var from = match.index, | ||
matchStr = match[0], | ||
before = str.slice(0, from), | ||
after = str.slice(to); | ||
after = str.slice(from + matchStr.length); | ||
@@ -1652,3 +1670,3 @@ var reach = pos + str.length; | ||
def[tagName] = { | ||
pattern: RegExp(/(<__[\s\S]*?>)(?:<!\[CDATA\[(?:[^\]]|\](?!\]>))*\]\]>|(?!<!\[CDATA\[)[\s\S])*?(?=<\/__>)/.source.replace(/__/g, function () { return tagName; }), 'i'), | ||
pattern: RegExp(/(<__[^>]*>)(?:<!\[CDATA\[(?:[^\]]|\](?!\]>))*\]\]>|(?!<!\[CDATA\[)[\s\S])*?(?=<\/__>)/.source.replace(/__/g, function () { return tagName; }), 'i'), | ||
lookbehind: true, | ||
@@ -1684,7 +1702,7 @@ greedy: true, | ||
'atrule': { | ||
pattern: /@[\w-]+[\s\S]*?(?:;|(?=\s*\{))/, | ||
pattern: /@[\w-](?:[^;{\s]|\s+(?![\s{]))*(?:;|(?=\s*\{))/, | ||
inside: { | ||
'rule': /^@[\w-]+/, | ||
'selector-function-argument': { | ||
pattern: /(\bselector\s*\((?!\s*\))\s*)(?:[^()]|\((?:[^()]|\([^()]*\))*\))+?(?=\s*\))/, | ||
pattern: /(\bselector\s*\(\s*(?![\s)]))(?:[^()\s]|\s+(?![\s)])|\((?:[^()]|\([^()]*\))*\))+(?=\s*\))/, | ||
lookbehind: true, | ||
@@ -1713,3 +1731,3 @@ alias: 'selector' | ||
}, | ||
'selector': RegExp('[^{}\\s](?:[^{};"\']|' + string.source + ')*?(?=\\s*\\{)'), | ||
'selector': RegExp('[^{}\\s](?:[^{};"\'\\s]|\\s+(?![\\s{])|' + string.source + ')*(?=\\s*\\{)'), | ||
'string': { | ||
@@ -1719,3 +1737,3 @@ pattern: string, | ||
}, | ||
'property': /[-_a-z\xA0-\uFFFF][-\w\xA0-\uFFFF]*(?=\s*:)/i, | ||
'property': /(?!\s)[-_a-z\xA0-\uFFFF](?:(?!\s)[-\w\xA0-\uFFFF])*(?=\s*:)/i, | ||
'important': /!important\b/i, | ||
@@ -1734,15 +1752,25 @@ 'function': /[-a-z0-9]+(?=\()/i, | ||
'style-attr': { | ||
pattern: /\s*style=("|')(?:\\[\s\S]|(?!\1)[^\\])*\1/i, | ||
pattern: /(^|["'\s])style\s*=\s*(?:"[^"]*"|'[^']*')/i, | ||
lookbehind: true, | ||
inside: { | ||
'attr-name': { | ||
pattern: /^\s*style/i, | ||
inside: markup.tag.inside | ||
'attr-value': { | ||
pattern: /=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+)/, | ||
inside: { | ||
'style': { | ||
pattern: /(["'])[\s\S]+(?=["']$)/, | ||
lookbehind: true, | ||
alias: 'language-css', | ||
inside: Prism.languages.css | ||
}, | ||
'punctuation': [ | ||
{ | ||
pattern: /^=/, | ||
alias: 'attr-equals' | ||
}, | ||
/"|'/ | ||
] | ||
} | ||
}, | ||
'punctuation': /^\s*=\s*['"]|['"]\s*$/, | ||
'attr-value': { | ||
pattern: /.+/i, | ||
inside: Prism.languages.css | ||
} | ||
}, | ||
alias: 'language-css' | ||
'attr-name': /^style/i | ||
} | ||
} | ||
@@ -1763,3 +1791,4 @@ }, markup.tag); | ||
pattern: /(^|[^\\])\/\*[\s\S]*?(?:\*\/|$)/, | ||
lookbehind: true | ||
lookbehind: true, | ||
greedy: true | ||
}, | ||
@@ -1786,3 +1815,3 @@ { | ||
'function': /\w+(?=\()/, | ||
'number': /\b0x[\da-f]+\b|(?:\b\d+\.?\d*|\B\.\d+)(?:e[+-]?\d+)?/i, | ||
'number': /\b0x[\da-f]+\b|(?:\b\d+(?:\.\d*)?|\B\.\d+)(?:e[+-]?\d+)?/i, | ||
'operator': /[<>]=?|[!=]=?=?|--?|\+\+?|&&?|\|\|?|[?*/~^%]/, | ||
@@ -1801,3 +1830,3 @@ 'punctuation': /[{}[\];(),.:]/ | ||
{ | ||
pattern: /(^|[^$\w\xA0-\uFFFF])[_$A-Z\xA0-\uFFFF][$\w\xA0-\uFFFF]*(?=\.(?:prototype|constructor))/, | ||
pattern: /(^|[^$\w\xA0-\uFFFF])(?!\s)[_$A-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\.(?:prototype|constructor))/, | ||
lookbehind: true | ||
@@ -1816,5 +1845,5 @@ } | ||
], | ||
// Allow for all non-ASCII characters (See http://stackoverflow.com/a/2008444) | ||
'function': /#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*(?:\.\s*(?:apply|bind|call)\s*)?\()/, | ||
'number': /\b(?:(?:0[xX](?:[\dA-Fa-f](?:_[\dA-Fa-f])?)+|0[bB](?:[01](?:_[01])?)+|0[oO](?:[0-7](?:_[0-7])?)+)n?|(?:\d(?:_\d)?)+n|NaN|Infinity)\b|(?:\b(?:\d(?:_\d)?)+\.?(?:\d(?:_\d)?)*|\B\.(?:\d(?:_\d)?)+)(?:[Ee][+-]?(?:\d(?:_\d)?)+)?/, | ||
// Allow for all non-ASCII characters (See http://stackoverflow.com/a/2008444) | ||
'function': /#?[_$a-zA-Z\xA0-\uFFFF][$\w\xA0-\uFFFF]*(?=\s*(?:\.\s*(?:apply|bind|call)\s*)?\()/, | ||
'operator': /--|\+\+|\*\*=?|=>|&&=?|\|\|=?|[!=]==|<<=?|>>>?=?|[-+*/%&|^!=<>]=?|\.{3}|\?\?=?|\?\.?|[~:]/ | ||
@@ -1829,7 +1858,17 @@ }); | ||
lookbehind: true, | ||
greedy: true | ||
greedy: true, | ||
inside: { | ||
'regex-source': { | ||
pattern: /^(\/)[\s\S]+(?=\/[a-z]*$)/, | ||
lookbehind: true, | ||
alias: 'language-regex', | ||
inside: Prism.languages.regex | ||
}, | ||
'regex-flags': /[a-z]+$/, | ||
'regex-delimiter': /^\/|\/$/ | ||
} | ||
}, | ||
// This must be declared before keyword because we use "function" inside the look-forward | ||
'function-variable': { | ||
pattern: /#?[_$a-zA-Z\xA0-\uFFFF][$\w\xA0-\uFFFF]*(?=\s*[=:]\s*(?:async\s*)?(?:\bfunction\b|(?:\((?:[^()]|\([^()]*\))*\)|[_$a-zA-Z\xA0-\uFFFF][$\w\xA0-\uFFFF]*)\s*=>))/, | ||
pattern: /#?(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*[=:]\s*(?:async\s*)?(?:\bfunction\b|(?:\((?:[^()]|\([^()]*\))*\)|(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*)\s*=>))/, | ||
alias: 'function' | ||
@@ -1839,3 +1878,3 @@ }, | ||
{ | ||
pattern: /(function(?:\s+[_$A-Za-z\xA0-\uFFFF][$\w\xA0-\uFFFF]*)?\s*\(\s*)(?!\s)(?:[^()]|\([^()]*\))+?(?=\s*\))/, | ||
pattern: /(function(?:\s+(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*)?\s*\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\))/, | ||
lookbehind: true, | ||
@@ -1845,7 +1884,7 @@ inside: Prism.languages.javascript | ||
{ | ||
pattern: /[_$a-z\xA0-\uFFFF][$\w\xA0-\uFFFF]*(?=\s*=>)/i, | ||
pattern: /(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*(?=\s*=>)/i, | ||
inside: Prism.languages.javascript | ||
}, | ||
{ | ||
pattern: /(\(\s*)(?!\s)(?:[^()]|\([^()]*\))+?(?=\s*\)\s*=>)/, | ||
pattern: /(\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\)\s*=>)/, | ||
lookbehind: true, | ||
@@ -1855,3 +1894,3 @@ inside: Prism.languages.javascript | ||
{ | ||
pattern: /((?:\b|\s|^)(?!(?:as|async|await|break|case|catch|class|const|continue|debugger|default|delete|do|else|enum|export|extends|finally|for|from|function|get|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|set|static|super|switch|this|throw|try|typeof|undefined|var|void|while|with|yield)(?![$\w\xA0-\uFFFF]))(?:[_$A-Za-z\xA0-\uFFFF][$\w\xA0-\uFFFF]*\s*)\(\s*|\]\s*\(\s*)(?!\s)(?:[^()]|\([^()]*\))+?(?=\s*\)\s*\{)/, | ||
pattern: /((?:\b|\s|^)(?!(?:as|async|await|break|case|catch|class|const|continue|debugger|default|delete|do|else|enum|export|extends|finally|for|from|function|get|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|set|static|super|switch|this|throw|try|typeof|undefined|var|void|while|with|yield)(?![$\w\xA0-\uFFFF]))(?:(?!\s)[_$a-zA-Z\xA0-\uFFFF](?:(?!\s)[$\w\xA0-\uFFFF])*\s*)\(\s*|\]\s*\(\s*)(?!\s)(?:[^()\s]|\s+(?![\s)])|\([^()]*\))+(?=\s*\)\s*\{)/, | ||
lookbehind: true, | ||
@@ -1905,2 +1944,7 @@ inside: Prism.languages.javascript | ||
// https://developer.mozilla.org/en-US/docs/Web/API/Element/matches#Polyfill | ||
if (!Element.prototype.matches) { | ||
Element.prototype.matches = Element.prototype.msMatchesSelector || Element.prototype.webkitMatchesSelector; | ||
} | ||
var Prism = window.Prism; | ||
@@ -2043,7 +2087,7 @@ | ||
}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) | ||
}).call(this)}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) | ||
},{}],6:[function(require,module,exports){ | ||
module.exports={ | ||
"name": "magicpen-prism", | ||
"version": "4.1.1", | ||
"version": "5.0.0", | ||
"description": "Add syntax highlighting support to magicpen via prism.js", | ||
@@ -2057,8 +2101,8 @@ "repository": { | ||
"devDependencies": { | ||
"browserify": "^16.2.3", | ||
"browserify": "^17.0.0", | ||
"bundle-collapser": "^1.3.0", | ||
"coveralls": "^3.0.3", | ||
"eslint": "^7.0.0", | ||
"eslint-config-prettier": "^6.9.0", | ||
"eslint-config-standard": "^14.1.0", | ||
"eslint-config-prettier": "^7.0.0", | ||
"eslint-config-standard": "^16.0.0", | ||
"eslint-plugin-import": "^2.16.0", | ||
@@ -2068,8 +2112,8 @@ "eslint-plugin-mocha": "^8.0.0", | ||
"eslint-plugin-promise": "^4.0.1", | ||
"eslint-plugin-standard": "^4.0.0", | ||
"eslint-plugin-standard": "^5.0.0", | ||
"magicpen": "^6.2.1", | ||
"mocha": "^7.0.0", | ||
"mocha": "^8.3.0", | ||
"nyc": "^15.0.0", | ||
"prettier": "~2.0.1", | ||
"unexpected": "^11.12.1" | ||
"prettier": "~2.2.0", | ||
"unexpected": "^12.0.0" | ||
}, | ||
@@ -2076,0 +2120,0 @@ "files": [ |
{ | ||
"name": "magicpen-prism", | ||
"version": "4.1.1", | ||
"version": "5.0.0", | ||
"description": "Add syntax highlighting support to magicpen via prism.js", | ||
@@ -12,8 +12,8 @@ "repository": { | ||
"devDependencies": { | ||
"browserify": "^16.2.3", | ||
"browserify": "^17.0.0", | ||
"bundle-collapser": "^1.3.0", | ||
"coveralls": "^3.0.3", | ||
"eslint": "^7.0.0", | ||
"eslint-config-prettier": "^6.9.0", | ||
"eslint-config-standard": "^14.1.0", | ||
"eslint-config-prettier": "^7.0.0", | ||
"eslint-config-standard": "^16.0.0", | ||
"eslint-plugin-import": "^2.16.0", | ||
@@ -23,8 +23,8 @@ "eslint-plugin-mocha": "^8.0.0", | ||
"eslint-plugin-promise": "^4.0.1", | ||
"eslint-plugin-standard": "^4.0.0", | ||
"eslint-plugin-standard": "^5.0.0", | ||
"magicpen": "^6.2.1", | ||
"mocha": "^7.0.0", | ||
"mocha": "^8.3.0", | ||
"nyc": "^15.0.0", | ||
"prettier": "~2.0.1", | ||
"unexpected": "^11.12.1" | ||
"prettier": "~2.2.0", | ||
"unexpected": "^12.0.0" | ||
}, | ||
@@ -31,0 +31,0 @@ "files": [ |
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
68900
1999
0