diff options
Diffstat (limited to 'public/prism/prism-jsx.min.js')
| -rw-r--r-- | public/prism/prism-jsx.min.js | 103 |
1 files changed, 103 insertions, 0 deletions
diff --git a/public/prism/prism-jsx.min.js b/public/prism/prism-jsx.min.js new file mode 100644 index 0000000..121a56f --- /dev/null +++ b/public/prism/prism-jsx.min.js @@ -0,0 +1,103 @@ +!(function (o) { + var t = o.util.clone(o.languages.javascript), + e = '(?:\\{<S>*\\.{3}(?:[^{}]|<BRACES>)*\\})'; + function n(t, n) { + return ( + (t = t + .replace(/<S>/g, function () { + return '(?:\\s|//.*(?!.)|/\\*(?:[^*]|\\*(?!/))\\*/)'; + }) + .replace(/<BRACES>/g, function () { + return '(?:\\{(?:\\{(?:\\{[^{}]*\\}|[^{}])*\\}|[^{}])*\\})'; + }) + .replace(/<SPREAD>/g, function () { + return e; + })), + RegExp(t, n) + ); + } + (e = n(e).source), + (o.languages.jsx = o.languages.extend('markup', t)), + (o.languages.jsx.tag.pattern = n( + '</?(?:[\\w.:-]+(?:<S>+(?:[\\w.:$-]+(?:=(?:"(?:\\\\[^]|[^\\\\"])*"|\'(?:\\\\[^]|[^\\\\\'])*\'|[^\\s{\'"/>=]+|<BRACES>))?|<SPREAD>))*<S>*/?)?>' + )), + (o.languages.jsx.tag.inside.tag.pattern = /^<\/?[^\s>\/]*/), + (o.languages.jsx.tag.inside['attr-value'].pattern = + /=(?!\{)(?:"(?:\\[\s\S]|[^\\"])*"|'(?:\\[\s\S]|[^\\'])*'|[^\s'">]+)/), + (o.languages.jsx.tag.inside.tag.inside['class-name'] = + /^[A-Z]\w*(?:\.[A-Z]\w*)*$/), + (o.languages.jsx.tag.inside.comment = t.comment), + o.languages.insertBefore( + 'inside', + 'attr-name', + { spread: { pattern: n('<SPREAD>'), inside: o.languages.jsx } }, + o.languages.jsx.tag + ), + o.languages.insertBefore( + 'inside', + 'special-attr', + { + script: { + pattern: n('=<BRACES>'), + alias: 'language-javascript', + inside: { + 'script-punctuation': { pattern: /^=(?=\{)/, alias: 'punctuation' }, + rest: o.languages.jsx, + }, + }, + }, + o.languages.jsx.tag + ); + var i = function (t) { + return t + ? 'string' == typeof t + ? t + : 'string' == typeof t.content + ? t.content + : t.content.map(i).join('') + : ''; + }, + r = function (t) { + for (var n = [], e = 0; e < t.length; e++) { + var a = t[e], + s = !1; + if ( + ('string' != typeof a && + ('tag' === a.type && a.content[0] && 'tag' === a.content[0].type + ? '</' === a.content[0].content[0].content + ? 0 < n.length && + n[n.length - 1].tagName === i(a.content[0].content[1]) && + n.pop() + : '/>' === a.content[a.content.length - 1].content || + n.push({ + tagName: i(a.content[0].content[1]), + openedBraces: 0, + }) + : 0 < n.length && 'punctuation' === a.type && '{' === a.content + ? n[n.length - 1].openedBraces++ + : 0 < n.length && + 0 < n[n.length - 1].openedBraces && + 'punctuation' === a.type && + '}' === a.content + ? n[n.length - 1].openedBraces-- + : (s = !0)), + (s || 'string' == typeof a) && + 0 < n.length && + 0 === n[n.length - 1].openedBraces) + ) { + var g = i(a); + e < t.length - 1 && + ('string' == typeof t[e + 1] || 'plain-text' === t[e + 1].type) && + ((g += i(t[e + 1])), t.splice(e + 1, 1)), + 0 < e && + ('string' == typeof t[e - 1] || 'plain-text' === t[e - 1].type) && + ((g = i(t[e - 1]) + g), t.splice(e - 1, 1), e--), + (t[e] = new o.Token('plain-text', g, null, g)); + } + a.content && 'string' != typeof a.content && r(a.content); + } + }; + o.hooks.add('after-tokenize', function (t) { + ('jsx' !== t.language && 'tsx' !== t.language) || r(t.tokens); + }); +})(Prism); |
