magicpen-prism
Advanced tools
Comparing version 3.0.1 to 3.0.2
@@ -5,3 +5,3 @@ var oldPrismGlobal = global.Prism; | ||
require('prismjs/components/prism-csp.js'); | ||
global.Prism = oldPrismGlobal; | ||
global.Prism = oldPrismGlobal || prism; | ||
@@ -8,0 +8,0 @@ var defaultTheme = { |
@@ -7,3 +7,3 @@ (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){ | ||
require(2); | ||
global.Prism = oldPrismGlobal; | ||
global.Prism = oldPrismGlobal || prism; | ||
@@ -182,13 +182,21 @@ var defaultTheme = { | ||
}, | ||
'attr-name': /[a-z_]\w*(?=\s*:)/i, | ||
'keyword': [ | ||
{ | ||
pattern: /(fragment\s+(?!on)[a-z_]\w*\s+|\.{3}\s*)on\b/, | ||
lookbehind: true | ||
}, | ||
/\b(?:query|fragment|mutation)\b/ | ||
], | ||
'operator': /!|=|\.{3}/, | ||
'punctuation': /[!(){}\[\]:=,]/ | ||
'attr-name': { | ||
pattern: /[a-z_]\w*(?=\s*(?:\((?:[^()"]|"(?:\\.|[^\\"\r\n])*")*\))?:)/i, | ||
greedy: true | ||
}, | ||
'class-name': { | ||
pattern: /(\b(?:enum|implements|interface|on|scalar|type|union)\s+)[a-zA-Z_]\w*/, | ||
lookbehind: true | ||
}, | ||
'fragment': { | ||
pattern: /(\bfragment\s+|\.{3}\s*(?!on\b))[a-zA-Z_]\w*/, | ||
lookbehind: true, | ||
alias: 'function' | ||
}, | ||
'keyword': /\b(?:enum|fragment|implements|input|interface|mutation|on|query|scalar|schema|type|union)\b/, | ||
'operator': /[!=|]|\.{3}/, | ||
'punctuation': /[!(){}\[\]:=,]/, | ||
'constant': /\b(?!ID\b)[A-Z][A-Z_\d]*\b/ | ||
}; | ||
},{}],4:[function(require,module,exports){ | ||
@@ -215,3 +223,3 @@ (function (global){ | ||
var Prism = (function(){ | ||
var Prism = (function (_self){ | ||
@@ -222,3 +230,3 @@ // Private helper vars | ||
var _ = _self.Prism = { | ||
var _ = { | ||
manual: _self.Prism && _self.Prism.manual, | ||
@@ -230,3 +238,3 @@ disableWorkerMessageHandler: _self.Prism && _self.Prism.disableWorkerMessageHandler, | ||
return new Token(tokens.type, _.util.encode(tokens.content), tokens.alias); | ||
} else if (_.util.type(tokens) === 'Array') { | ||
} else if (Array.isArray(tokens)) { | ||
return tokens.map(_.util.encode); | ||
@@ -239,3 +247,3 @@ } else { | ||
type: function (o) { | ||
return Object.prototype.toString.call(o).match(/\[object (\w+)\]/)[1]; | ||
return Object.prototype.toString.call(o).slice(8, -1); | ||
}, | ||
@@ -251,4 +259,4 @@ | ||
// Deep clone a language definition (e.g. to extend it) | ||
clone: function (o, visited) { | ||
var type = _.util.type(o); | ||
clone: function deepClone(o, visited) { | ||
var clone, id, type = _.util.type(o); | ||
visited = visited || {}; | ||
@@ -258,11 +266,12 @@ | ||
case 'Object': | ||
if (visited[_.util.objId(o)]) { | ||
return visited[_.util.objId(o)]; | ||
id = _.util.objId(o); | ||
if (visited[id]) { | ||
return visited[id]; | ||
} | ||
var clone = {}; | ||
visited[_.util.objId(o)] = clone; | ||
clone = {}; | ||
visited[id] = clone; | ||
for (var key in o) { | ||
if (o.hasOwnProperty(key)) { | ||
clone[key] = _.util.clone(o[key], visited); | ||
clone[key] = deepClone(o[key], visited); | ||
} | ||
@@ -274,16 +283,18 @@ } | ||
case 'Array': | ||
if (visited[_.util.objId(o)]) { | ||
return visited[_.util.objId(o)]; | ||
id = _.util.objId(o); | ||
if (visited[id]) { | ||
return visited[id]; | ||
} | ||
var clone = []; | ||
visited[_.util.objId(o)] = clone; | ||
clone = []; | ||
visited[id] = clone; | ||
o.forEach(function (v, i) { | ||
clone[i] = _.util.clone(v, visited); | ||
clone[i] = deepClone(v, visited); | ||
}); | ||
return clone; | ||
default: | ||
return o; | ||
} | ||
return o; | ||
} | ||
@@ -306,5 +317,5 @@ }, | ||
* As this needs to recreate the object (we cannot actually insert before keys in object literals), | ||
* we cannot just provide an object, we need anobject and a key. | ||
* we cannot just provide an object, we need an object and a key. | ||
* @param inside The key (or language id) of the parent | ||
* @param before The key to insert before. If not provided, the function appends instead. | ||
* @param before The key to insert before. | ||
* @param insert Object with the key/value pairs to insert | ||
@@ -316,25 +327,9 @@ * @param root The object that contains `inside`. If equal to Prism.languages, it can be omitted. | ||
var grammar = root[inside]; | ||
if (arguments.length == 2) { | ||
insert = arguments[1]; | ||
for (var newToken in insert) { | ||
if (insert.hasOwnProperty(newToken)) { | ||
grammar[newToken] = insert[newToken]; | ||
} | ||
} | ||
return grammar; | ||
} | ||
var ret = {}; | ||
for (var token in grammar) { | ||
if (grammar.hasOwnProperty(token)) { | ||
if (token == before) { | ||
for (var newToken in insert) { | ||
if (insert.hasOwnProperty(newToken)) { | ||
@@ -346,9 +341,15 @@ ret[newToken] = insert[newToken]; | ||
ret[token] = grammar[token]; | ||
// Do not insert token which also occur in insert. See #1525 | ||
if (!insert.hasOwnProperty(token)) { | ||
ret[token] = grammar[token]; | ||
} | ||
} | ||
} | ||
var old = root[inside]; | ||
root[inside] = ret; | ||
// Update references in other language definitions | ||
_.languages.DFS(_.languages, function(key, value) { | ||
if (value === root[inside] && key != inside) { | ||
if (value === old && key != inside) { | ||
this[key] = ret; | ||
@@ -358,8 +359,11 @@ } | ||
return root[inside] = ret; | ||
return ret; | ||
}, | ||
// Traverse a language definition with Depth First Search | ||
DFS: function(o, callback, type, visited) { | ||
DFS: function DFS(o, callback, type, visited) { | ||
visited = visited || {}; | ||
var objId = _.util.objId; | ||
for (var i in o) { | ||
@@ -369,9 +373,12 @@ if (o.hasOwnProperty(i)) { | ||
if (_.util.type(o[i]) === 'Object' && !visited[_.util.objId(o[i])]) { | ||
visited[_.util.objId(o[i])] = true; | ||
_.languages.DFS(o[i], callback, null, visited); | ||
var property = o[i], | ||
propertyType = _.util.type(property); | ||
if (propertyType === 'Object' && !visited[objId(property)]) { | ||
visited[objId(property)] = true; | ||
DFS(property, callback, null, visited); | ||
} | ||
else if (_.util.type(o[i]) === 'Array' && !visited[_.util.objId(o[i])]) { | ||
visited[_.util.objId(o[i])] = true; | ||
_.languages.DFS(o[i], callback, i, visited); | ||
else if (propertyType === 'Array' && !visited[objId(property)]) { | ||
visited[objId(property)] = true; | ||
DFS(property, callback, i, visited); | ||
} | ||
@@ -437,10 +444,17 @@ } | ||
var insertHighlightedCode = function (highlightedCode) { | ||
env.highlightedCode = highlightedCode; | ||
_.hooks.run('before-insert', env); | ||
env.element.innerHTML = env.highlightedCode; | ||
_.hooks.run('after-highlight', env); | ||
_.hooks.run('complete', env); | ||
callback && callback.call(env.element); | ||
} | ||
_.hooks.run('before-sanity-check', env); | ||
if (!env.code || !env.grammar) { | ||
if (env.code) { | ||
_.hooks.run('before-highlight', env); | ||
env.element.textContent = env.code; | ||
_.hooks.run('after-highlight', env); | ||
} | ||
if (!env.code) { | ||
_.hooks.run('complete', env); | ||
@@ -452,2 +466,7 @@ return; | ||
if (!env.grammar) { | ||
insertHighlightedCode(_.util.encode(env.code)); | ||
return; | ||
} | ||
if (async && _self.Worker) { | ||
@@ -457,11 +476,3 @@ var worker = new Worker(_.filename); | ||
worker.onmessage = function(evt) { | ||
env.highlightedCode = evt.data; | ||
_.hooks.run('before-insert', env); | ||
env.element.innerHTML = env.highlightedCode; | ||
callback && callback.call(env.element); | ||
_.hooks.run('after-highlight', env); | ||
_.hooks.run('complete', env); | ||
insertHighlightedCode(evt.data); | ||
}; | ||
@@ -476,12 +487,3 @@ | ||
else { | ||
env.highlightedCode = _.highlight(env.code, env.grammar, env.language); | ||
_.hooks.run('before-insert', env); | ||
env.element.innerHTML = env.highlightedCode; | ||
callback && callback.call(element); | ||
_.hooks.run('after-highlight', env); | ||
_.hooks.run('complete', env); | ||
insertHighlightedCode(_.highlight(env.code, env.grammar, env.language)); | ||
} | ||
@@ -503,4 +505,2 @@ }, | ||
matchGrammar: function (text, strarr, grammar, index, startPos, oneshot, target) { | ||
var Token = _.Token; | ||
for (var token in grammar) { | ||
@@ -631,3 +631,3 @@ if(!grammar.hasOwnProperty(token) || !grammar[token]) { | ||
tokenize: function(text, grammar, language) { | ||
tokenize: function(text, grammar) { | ||
var strarr = [text]; | ||
@@ -672,6 +672,10 @@ | ||
} | ||
} | ||
}, | ||
Token: Token | ||
}; | ||
var Token = _.Token = function(type, content, alias, matchedStr, greedy) { | ||
_self.Prism = _; | ||
function Token(type, content, alias, matchedStr, greedy) { | ||
this.type = type; | ||
@@ -683,3 +687,3 @@ this.content = content; | ||
this.greedy = !!greedy; | ||
}; | ||
} | ||
@@ -691,3 +695,3 @@ Token.stringify = function(o, language, parent) { | ||
if (_.util.type(o) === 'Array') { | ||
if (Array.isArray(o)) { | ||
return o.map(function(element) { | ||
@@ -709,3 +713,3 @@ return Token.stringify(element, language, o); | ||
if (o.alias) { | ||
var aliases = _.util.type(o.alias) === 'Array' ? o.alias : [o.alias]; | ||
var aliases = Array.isArray(o.alias) ? o.alias : [o.alias]; | ||
Array.prototype.push.apply(env.classes, aliases); | ||
@@ -727,3 +731,3 @@ } | ||
// in Node.js | ||
return _self.Prism; | ||
return _; | ||
} | ||
@@ -746,3 +750,3 @@ | ||
return _self.Prism; | ||
return _; | ||
} | ||
@@ -770,5 +774,5 @@ | ||
return _self.Prism; | ||
return _; | ||
})(); | ||
})(_self); | ||
@@ -795,3 +799,3 @@ if (typeof module !== 'undefined' && module.exports) { | ||
'tag': { | ||
pattern: /<\/?(?!\d)[^\s>\/=$<%]+(?:\s+[^\s>\/=]+(?:=(?:("|')(?:\\[\s\S]|(?!\1)[^\\])*\1|[^\s'">=]+))?)*\s*\/?>/i, | ||
pattern: /<\/?(?!\d)[^\s>\/=$<%]+(?:\s(?:\s*[^\s>\/=]+(?:\s*=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+(?=[\s>]))|(?=[\s/>])))+)?\s*\/?>/i, | ||
greedy: true, | ||
@@ -807,3 +811,3 @@ inside: { | ||
'attr-value': { | ||
pattern: /=(?:("|')(?:\\[\s\S]|(?!\1)[^\\])*\1|[^\s'">=]+)/i, | ||
pattern: /=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+)/i, | ||
inside: { | ||
@@ -813,3 +817,3 @@ 'punctuation': [ | ||
{ | ||
pattern: /(^|[^\\])["']/, | ||
pattern: /^(\s*)["']|["']$/, | ||
lookbehind: true | ||
@@ -844,3 +848,47 @@ } | ||
Prism.languages.xml = Prism.languages.markup; | ||
Object.defineProperty(Prism.languages.markup.tag, 'addInlined', { | ||
/** | ||
* Adds an inlined language to markup. | ||
* | ||
* An example of an inlined language is CSS with `<style>` tags. | ||
* | ||
* @param {string} tagName The name of the tag that contains the inlined language. This name will be treated as | ||
* case insensitive. | ||
* @param {string} lang The language key. | ||
* @example | ||
* addInlined('style', 'css'); | ||
*/ | ||
value: function addInlined(tagName, lang) { | ||
var includedCdataInside = {}; | ||
includedCdataInside['language-' + lang] = { | ||
pattern: /(^<!\[CDATA\[)[\s\S]+?(?=\]\]>$)/i, | ||
lookbehind: true, | ||
inside: Prism.languages[lang] | ||
}; | ||
includedCdataInside['cdata'] = /^<!\[CDATA\[|\]\]>$/i; | ||
var inside = { | ||
'included-cdata': { | ||
pattern: /<!\[CDATA\[[\s\S]*?\]\]>/i, | ||
inside: includedCdataInside | ||
} | ||
}; | ||
inside['language-' + lang] = { | ||
pattern: /[\s\S]+/, | ||
inside: Prism.languages[lang] | ||
}; | ||
var def = {}; | ||
def[tagName] = { | ||
pattern: RegExp(/(<__[\s\S]*?>)(?:<!\[CDATA\[[\s\S]*?\]\]>\s*|[\s\S])*?(?=<\/__>)/.source.replace(/__/g, tagName), 'i'), | ||
lookbehind: true, | ||
greedy: true, | ||
inside: inside | ||
}; | ||
Prism.languages.insertBefore('markup', 'cdata', def); | ||
} | ||
}); | ||
Prism.languages.xml = Prism.languages.extend('markup', {}); | ||
Prism.languages.html = Prism.languages.markup; | ||
@@ -855,55 +903,55 @@ Prism.languages.mathml = Prism.languages.markup; | ||
Prism.languages.css = { | ||
'comment': /\/\*[\s\S]*?\*\//, | ||
'atrule': { | ||
pattern: /@[\w-]+?.*?(?:;|(?=\s*\{))/i, | ||
inside: { | ||
'rule': /@[\w-]+/ | ||
// See rest below | ||
} | ||
}, | ||
'url': /url\((?:(["'])(?:\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1|.*?)\)/i, | ||
'selector': /[^{}\s][^{};]*?(?=\s*\{)/, | ||
'string': { | ||
pattern: /("|')(?:\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1/, | ||
greedy: true | ||
}, | ||
'property': /[-_a-z\xA0-\uFFFF][-\w\xA0-\uFFFF]*(?=\s*:)/i, | ||
'important': /\B!important\b/i, | ||
'function': /[-a-z0-9]+(?=\()/i, | ||
'punctuation': /[(){};:]/ | ||
}; | ||
(function (Prism) { | ||
Prism.languages.css['atrule'].inside.rest = Prism.languages.css; | ||
var string = /("|')(?:\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1/; | ||
if (Prism.languages.markup) { | ||
Prism.languages.insertBefore('markup', 'tag', { | ||
'style': { | ||
pattern: /(<style[\s\S]*?>)[\s\S]*?(?=<\/style>)/i, | ||
lookbehind: true, | ||
inside: Prism.languages.css, | ||
alias: 'language-css', | ||
Prism.languages.css = { | ||
'comment': /\/\*[\s\S]*?\*\//, | ||
'atrule': { | ||
pattern: /@[\w-]+?[\s\S]*?(?:;|(?=\s*\{))/i, | ||
inside: { | ||
'rule': /@[\w-]+/ | ||
// See rest below | ||
} | ||
}, | ||
'url': RegExp('url\\((?:' + string.source + '|.*?)\\)', 'i'), | ||
'selector': RegExp('[^{}\\s](?:[^{};"\']|' + string.source + ')*?(?=\\s*\\{)'), | ||
'string': { | ||
pattern: string, | ||
greedy: true | ||
} | ||
}); | ||
}, | ||
'property': /[-_a-z\xA0-\uFFFF][-\w\xA0-\uFFFF]*(?=\s*:)/i, | ||
'important': /!important\b/i, | ||
'function': /[-a-z0-9]+(?=\()/i, | ||
'punctuation': /[(){};:,]/ | ||
}; | ||
Prism.languages.insertBefore('inside', 'attr-value', { | ||
'style-attr': { | ||
pattern: /\s*style=("|')(?:\\[\s\S]|(?!\1)[^\\])*\1/i, | ||
inside: { | ||
'attr-name': { | ||
pattern: /^\s*style/i, | ||
inside: Prism.languages.markup.tag.inside | ||
Prism.languages.css['atrule'].inside.rest = Prism.languages.css; | ||
var markup = Prism.languages.markup; | ||
if (markup) { | ||
markup.tag.addInlined('style', 'css'); | ||
Prism.languages.insertBefore('inside', 'attr-value', { | ||
'style-attr': { | ||
pattern: /\s*style=("|')(?:\\[\s\S]|(?!\1)[^\\])*\1/i, | ||
inside: { | ||
'attr-name': { | ||
pattern: /^\s*style/i, | ||
inside: markup.tag.inside | ||
}, | ||
'punctuation': /^\s*=\s*['"]|['"]\s*$/, | ||
'attr-value': { | ||
pattern: /.+/i, | ||
inside: Prism.languages.css | ||
} | ||
}, | ||
'punctuation': /^\s*=\s*['"]|['"]\s*$/, | ||
'attr-value': { | ||
pattern: /.+/i, | ||
inside: Prism.languages.css | ||
} | ||
}, | ||
alias: 'language-css' | ||
} | ||
}, Prism.languages.markup.tag); | ||
} | ||
alias: 'language-css' | ||
} | ||
}, markup.tag); | ||
} | ||
}(Prism)); | ||
/* ********************************************** | ||
@@ -938,3 +986,3 @@ Begin prism-clike.js | ||
'boolean': /\b(?:true|false)\b/, | ||
'function': /[a-z0-9_]+(?=\()/i, | ||
'function': /\w+(?=\()/, | ||
'number': /\b0x[\da-f]+\b|(?:\b\d+\.?\d*|\B\.\d+)(?:e[+-]?\d+)?/i, | ||
@@ -951,12 +999,30 @@ 'operator': /--?|\+\+?|!=?=?|<=?|>=?|==?=?|&&?|\|\|?|\?|\*|\/|~|\^|%/, | ||
Prism.languages.javascript = Prism.languages.extend('clike', { | ||
'keyword': /\b(?: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|var|void|while|with|yield)\b/, | ||
'number': /\b(?:0[xX][\dA-Fa-f]+|0[bB][01]+|0[oO][0-7]+|NaN|Infinity)\b|(?:\b\d+\.?\d*|\B\.\d+)(?:[Ee][+-]?\d+)?/, | ||
'class-name': [ | ||
Prism.languages.clike['class-name'], | ||
{ | ||
pattern: /(^|[^$\w\xA0-\uFFFF])[_$A-Z\xA0-\uFFFF][$\w\xA0-\uFFFF]*(?=\.(?:prototype|constructor))/, | ||
lookbehind: true | ||
} | ||
], | ||
'keyword': [ | ||
{ | ||
pattern: /((?:^|})\s*)(?:catch|finally)\b/, | ||
lookbehind: true | ||
}, | ||
{ | ||
pattern: /(^|[^.])\b(?:as|async(?=\s*(?:function\b|\(|[$\w\xA0-\uFFFF]|$))|await|break|case|class|const|continue|debugger|default|delete|do|else|enum|export|extends|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)\b/, | ||
lookbehind: true | ||
}, | ||
], | ||
'number': /\b(?:(?:0[xX][\dA-Fa-f]+|0[bB][01]+|0[oO][0-7]+)n?|\d+n|NaN|Infinity)\b|(?:\b\d+\.?\d*|\B\.\d+)(?:[Ee][+-]?\d+)?/, | ||
// Allow for all non-ASCII characters (See http://stackoverflow.com/a/2008444) | ||
'function': /[_$a-z\xA0-\uFFFF][$\w\xA0-\uFFFF]*(?=\s*\()/i, | ||
'function': /[_$a-zA-Z\xA0-\uFFFF][$\w\xA0-\uFFFF]*(?=\s*(?:\.\s*(?:apply|bind|call)\s*)?\()/, | ||
'operator': /-[-=]?|\+[+=]?|!=?=?|<<?=?|>>?>?=?|=(?:==?|>)?|&[&=]?|\|[|=]?|\*\*?=?|\/=?|~|\^=?|%=?|\?|\.{3}/ | ||
}); | ||
Prism.languages.javascript['class-name'][0].pattern = /(\b(?:class|interface|extends|implements|instanceof|new)\s+)[\w.\\]+/ | ||
Prism.languages.insertBefore('javascript', 'keyword', { | ||
'regex': { | ||
pattern: /((?:^|[^$\w\xA0-\uFFFF."'\])\s])\s*)\/(\[[^\]\r\n]+]|\\.|[^/\\\[\r\n])+\/[gimyu]{0,5}(?=\s*($|[\r\n,.;})\]]))/, | ||
pattern: /((?:^|[^$\w\xA0-\uFFFF."'\])\s])\s*)\/(\[(?:[^\]\\\r\n]|\\.)*]|\\.|[^/\\\[\r\n])+\/[gimyu]{0,5}(?=\s*($|[\r\n,.;})\]]))/, | ||
lookbehind: true, | ||
@@ -967,6 +1033,27 @@ greedy: true | ||
'function-variable': { | ||
pattern: /[_$a-z\xA0-\uFFFF][$\w\xA0-\uFFFF]*(?=\s*=\s*(?:function\b|(?:\([^()]*\)|[_$a-z\xA0-\uFFFF][$\w\xA0-\uFFFF]*)\s*=>))/i, | ||
pattern: /[_$a-zA-Z\xA0-\uFFFF][$\w\xA0-\uFFFF]*(?=\s*[=:]\s*(?:async\s*)?(?:\bfunction\b|(?:\((?:[^()]|\([^()]*\))*\)|[_$a-zA-Z\xA0-\uFFFF][$\w\xA0-\uFFFF]*)\s*=>))/, | ||
alias: 'function' | ||
}, | ||
'constant': /\b[A-Z][A-Z\d_]*\b/ | ||
'parameter': [ | ||
{ | ||
pattern: /(function(?:\s+[_$A-Za-z\xA0-\uFFFF][$\w\xA0-\uFFFF]*)?\s*\(\s*)(?!\s)(?:[^()]|\([^()]*\))+?(?=\s*\))/, | ||
lookbehind: true, | ||
inside: Prism.languages.javascript | ||
}, | ||
{ | ||
pattern: /[_$a-z\xA0-\uFFFF][$\w\xA0-\uFFFF]*(?=\s*=>)/i, | ||
inside: Prism.languages.javascript | ||
}, | ||
{ | ||
pattern: /(\(\s*)(?!\s)(?:[^()]|\([^()]*\))+?(?=\s*\)\s*=>)/, | ||
lookbehind: true, | ||
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*\{)/, | ||
lookbehind: true, | ||
inside: Prism.languages.javascript | ||
} | ||
], | ||
'constant': /\b[A-Z](?:[A-Z_]|\dx?)*\b/ | ||
}); | ||
@@ -986,3 +1073,3 @@ | ||
}, | ||
rest: null // See below | ||
rest: Prism.languages.javascript | ||
} | ||
@@ -994,14 +1081,5 @@ }, | ||
}); | ||
Prism.languages.javascript['template-string'].inside['interpolation'].inside.rest = Prism.languages.javascript; | ||
if (Prism.languages.markup) { | ||
Prism.languages.insertBefore('markup', 'tag', { | ||
'script': { | ||
pattern: /(<script[\s\S]*?>)[\s\S]*?(?=<\/script>)/i, | ||
lookbehind: true, | ||
inside: Prism.languages.javascript, | ||
alias: 'language-javascript', | ||
greedy: true | ||
} | ||
}); | ||
Prism.languages.markup.tag.addInlined('script', 'javascript'); | ||
} | ||
@@ -1021,3 +1099,7 @@ | ||
self.Prism.fileHighlight = function() { | ||
/** | ||
* @param {Element} [container=document] | ||
*/ | ||
self.Prism.fileHighlight = function(container) { | ||
container = container || document; | ||
@@ -1036,3 +1118,9 @@ var Extensions = { | ||
Array.prototype.slice.call(document.querySelectorAll('pre[data-src]')).forEach(function (pre) { | ||
Array.prototype.slice.call(container.querySelectorAll('pre[data-src]')).forEach(function (pre) { | ||
// ignore if already loaded | ||
if (pre.hasAttribute('data-src-loaded')) { | ||
return; | ||
} | ||
// load current | ||
var src = pre.getAttribute('data-src'); | ||
@@ -1075,2 +1163,4 @@ | ||
Prism.highlightElement(code); | ||
// mark as loaded | ||
pre.setAttribute('data-src-loaded', ''); | ||
} | ||
@@ -1106,5 +1196,9 @@ else if (xhr.status >= 400) { | ||
document.addEventListener('DOMContentLoaded', self.Prism.fileHighlight); | ||
document.addEventListener('DOMContentLoaded', function () { | ||
// execute inside handler, for dropping Event as argument | ||
self.Prism.fileHighlight(); | ||
}); | ||
})(); | ||
}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) | ||
@@ -1114,3 +1208,3 @@ },{}],5:[function(require,module,exports){ | ||
"name": "magicpen-prism", | ||
"version": "3.0.1", | ||
"version": "3.0.2", | ||
"description": "Add syntax highlighting support to magicpen via prism.js", | ||
@@ -1117,0 +1211,0 @@ "repository": { |
{ | ||
"name": "magicpen-prism", | ||
"version": "3.0.1", | ||
"version": "3.0.2", | ||
"description": "Add syntax highlighting support to magicpen via prism.js", | ||
@@ -5,0 +5,0 @@ "repository": { |
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
38164
1151
1