aboutsummaryrefslogtreecommitdiffstats
path: root/public/prism/prism-jsx.min.js
diff options
context:
space:
mode:
authorArmand Philippot <git@armandphilippot.com>2023-10-13 19:32:56 +0200
committerArmand Philippot <git@armandphilippot.com>2023-11-11 18:14:41 +0100
commit006b15b467a5cd835a6eab1b49023100bdc8f2e6 (patch)
tree949c7295c2e206f42357f135bab4696ddf6576ec /public/prism/prism-jsx.min.js
parent00f147a7a687d5772bcc538bc606cfff972178cd (diff)
refactor(components): rewrite Code component and usePrism hook
* move Prism styles to Sass placeholders to avoid repeats * let usePrism consumer define its plugins (remove default ones) * remove `plugins` prop from Code component * add new props to Code component to let consumer configure plugins (and handle plugin list from the given options) However there are some problems with Prism plugins: line-highlight and treeview does not seems to be loaded. I don't want to use Babel instead of SWC so I have no solution for now.
Diffstat (limited to 'public/prism/prism-jsx.min.js')
-rw-r--r--public/prism/prism-jsx.min.js108
1 files changed, 54 insertions, 54 deletions
diff --git a/public/prism/prism-jsx.min.js b/public/prism/prism-jsx.min.js
index 121a56f..8e359ee 100644
--- a/public/prism/prism-jsx.min.js
+++ b/public/prism/prism-jsx.min.js
@@ -1,7 +1,7 @@
-!(function (o) {
- var t = o.util.clone(o.languages.javascript),
+!(function (t) {
+ var n = t.util.clone(t.languages.javascript),
e = '(?:\\{<S>*\\.{3}(?:[^{}]|<BRACES>)*\\})';
- function n(t, n) {
+ function a(t, n) {
return (
(t = t
.replace(/<S>/g, function () {
@@ -16,88 +16,88 @@
RegExp(t, n)
);
}
- (e = n(e).source),
- (o.languages.jsx = o.languages.extend('markup', t)),
- (o.languages.jsx.tag.pattern = n(
+ (e = a(e).source),
+ (t.languages.jsx = t.languages.extend('markup', n)),
+ (t.languages.jsx.tag.pattern = a(
'</?(?:[\\w.:-]+(?:<S>+(?:[\\w.:$-]+(?:=(?:"(?:\\\\[^]|[^\\\\"])*"|\'(?:\\\\[^]|[^\\\\\'])*\'|[^\\s{\'"/>=]+|<BRACES>))?|<SPREAD>))*<S>*/?)?>'
)),
- (o.languages.jsx.tag.inside.tag.pattern = /^<\/?[^\s>\/]*/),
- (o.languages.jsx.tag.inside['attr-value'].pattern =
+ (t.languages.jsx.tag.inside.tag.pattern = /^<\/?[^\s>\/]*/),
+ (t.languages.jsx.tag.inside['attr-value'].pattern =
/=(?!\{)(?:"(?:\\[\s\S]|[^\\"])*"|'(?:\\[\s\S]|[^\\'])*'|[^\s'">]+)/),
- (o.languages.jsx.tag.inside.tag.inside['class-name'] =
+ (t.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(
+ (t.languages.jsx.tag.inside.comment = n.comment),
+ t.languages.insertBefore(
'inside',
'attr-name',
- { spread: { pattern: n('<SPREAD>'), inside: o.languages.jsx } },
- o.languages.jsx.tag
+ { spread: { pattern: a('<SPREAD>'), inside: t.languages.jsx } },
+ t.languages.jsx.tag
),
- o.languages.insertBefore(
+ t.languages.insertBefore(
'inside',
'special-attr',
{
script: {
- pattern: n('=<BRACES>'),
+ pattern: a('=<BRACES>'),
alias: 'language-javascript',
inside: {
'script-punctuation': { pattern: /^=(?=\{)/, alias: 'punctuation' },
- rest: o.languages.jsx,
+ rest: t.languages.jsx,
},
},
},
- o.languages.jsx.tag
+ t.languages.jsx.tag
);
- var i = function (t) {
+ var s = function (t) {
return t
? 'string' == typeof t
? t
: 'string' == typeof t.content
? t.content
- : t.content.map(i).join('')
+ : t.content.map(s).join('')
: '';
},
- r = function (t) {
- for (var n = [], e = 0; e < t.length; e++) {
- var a = t[e],
- s = !1;
+ g = function (n) {
+ for (var e = [], a = 0; a < n.length; a++) {
+ var o = n[a],
+ i = !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]),
+ ('string' != typeof o &&
+ ('tag' === o.type && o.content[0] && 'tag' === o.content[0].type
+ ? '</' === o.content[0].content[0].content
+ ? e.length > 0 &&
+ e[e.length - 1].tagName === s(o.content[0].content[1]) &&
+ e.pop()
+ : '/>' === o.content[o.content.length - 1].content ||
+ e.push({
+ tagName: s(o.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)
+ : e.length > 0 && 'punctuation' === o.type && '{' === o.content
+ ? e[e.length - 1].openedBraces++
+ : e.length > 0 &&
+ e[e.length - 1].openedBraces > 0 &&
+ 'punctuation' === o.type &&
+ '}' === o.content
+ ? e[e.length - 1].openedBraces--
+ : (i = !0)),
+ (i || 'string' == typeof o) &&
+ e.length > 0 &&
+ 0 === e[e.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));
+ var r = s(o);
+ a < n.length - 1 &&
+ ('string' == typeof n[a + 1] || 'plain-text' === n[a + 1].type) &&
+ ((r += s(n[a + 1])), n.splice(a + 1, 1)),
+ a > 0 &&
+ ('string' == typeof n[a - 1] || 'plain-text' === n[a - 1].type) &&
+ ((r = s(n[a - 1]) + r), n.splice(a - 1, 1), a--),
+ (n[a] = new t.Token('plain-text', r, null, r));
}
- a.content && 'string' != typeof a.content && r(a.content);
+ o.content && 'string' != typeof o.content && g(o.content);
}
};
- o.hooks.add('after-tokenize', function (t) {
- ('jsx' !== t.language && 'tsx' !== t.language) || r(t.tokens);
+ t.hooks.add('after-tokenize', function (t) {
+ ('jsx' !== t.language && 'tsx' !== t.language) || g(t.tokens);
});
})(Prism);