diff options
| author | Armand Philippot <git@armandphilippot.com> | 2023-10-13 19:32:56 +0200 |
|---|---|---|
| committer | Armand Philippot <git@armandphilippot.com> | 2023-11-11 18:14:41 +0100 |
| commit | 006b15b467a5cd835a6eab1b49023100bdc8f2e6 (patch) | |
| tree | 949c7295c2e206f42357f135bab4696ddf6576ec /public/prism/prism-qsharp.min.js | |
| parent | 00f147a7a687d5772bcc538bc606cfff972178cd (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-qsharp.min.js')
| -rw-r--r-- | public/prism/prism-qsharp.min.js | 38 |
1 files changed, 17 insertions, 21 deletions
diff --git a/public/prism/prism-qsharp.min.js b/public/prism/prism-qsharp.min.js index c17fd61..8d66577 100644 --- a/public/prism/prism-qsharp.min.js +++ b/public/prism/prism-qsharp.min.js @@ -1,44 +1,40 @@ !(function (e) { - function a(e, r) { - return e.replace(/<<(\d+)>>/g, function (e, n) { - return '(?:' + r[+n] + ')'; + function n(e, n) { + return e.replace(/<<(\d+)>>/g, function (e, r) { + return '(?:' + n[+r] + ')'; }); } - function n(e, n, r) { - return RegExp(a(e, n), r || ''); + function r(e, r, a) { + return RegExp(n(e, r), a || ''); } - var r = RegExp( + var a = RegExp( '\\b(?:' + - ( - 'Adj BigInt Bool Ctl Double false Int One Pauli PauliI PauliX PauliY PauliZ Qubit Range Result String true Unit Zero' + - ' ' + - 'Adjoint adjoint apply as auto body borrow borrowing Controlled controlled distribute elif else fail fixup for function if in internal intrinsic invert is let mutable namespace new newtype open operation repeat return self set until use using while within' - ) + 'Adj BigInt Bool Ctl Double false Int One Pauli PauliI PauliX PauliY PauliZ Qubit Range Result String true Unit Zero Adjoint adjoint apply as auto body borrow borrowing Controlled controlled distribute elif else fail fixup for function if in internal intrinsic invert is let mutable namespace new newtype open operation repeat return self set until use using while within' .trim() .replace(/ /g, '|') + ')\\b' ), - t = a('<<0>>(?:\\s*\\.\\s*<<0>>)*', ['\\b[A-Za-z_]\\w*\\b']), - i = { keyword: r, punctuation: /[<>()?,.:[\]]/ }, + t = n('<<0>>(?:\\s*\\.\\s*<<0>>)*', ['\\b[A-Za-z_]\\w*\\b']), + i = { keyword: a, punctuation: /[<>()?,.:[\]]/ }, s = '"(?:\\\\.|[^\\\\"])*"'; (e.languages.qsharp = e.languages.extend('clike', { comment: /\/\/.*/, string: [ - { pattern: n('(^|[^$\\\\])<<0>>', [s]), lookbehind: !0, greedy: !0 }, + { pattern: r('(^|[^$\\\\])<<0>>', [s]), lookbehind: !0, greedy: !0 }, ], 'class-name': [ { - pattern: n('(\\b(?:as|open)\\s+)<<0>>(?=\\s*(?:;|as\\b))', [t]), + pattern: r('(\\b(?:as|open)\\s+)<<0>>(?=\\s*(?:;|as\\b))', [t]), lookbehind: !0, inside: i, }, { - pattern: n('(\\bnamespace\\s+)<<0>>(?=\\s*\\{)', [t]), + pattern: r('(\\bnamespace\\s+)<<0>>(?=\\s*\\{)', [t]), lookbehind: !0, inside: i, }, ], - keyword: r, + keyword: a, number: /(?:\b0(?:x[\da-f]+|b[01]+|o[0-7]+)|(?:\B\.\d+|\b\d+(?:\.\d*)?)(?:e[-+]?\d+)?)l?\b/i, operator: @@ -49,19 +45,19 @@ range: { pattern: /\.\./, alias: 'operator' }, }); var o = (function (e, n) { - for (var r = 0; r < n; r++) + for (var r = 0; r < 2; r++) e = e.replace(/<<self>>/g, function () { return '(?:' + e + ')'; }); return e.replace(/<<self>>/g, '[^\\s\\S]'); - })(a('\\{(?:[^"{}]|<<0>>|<<self>>)*\\}', [s]), 2); + })(n('\\{(?:[^"{}]|<<0>>|<<self>>)*\\}', [s])); e.languages.insertBefore('qsharp', 'string', { 'interpolation-string': { - pattern: n('\\$"(?:\\\\.|<<0>>|[^\\\\"{])*"', [o]), + pattern: r('\\$"(?:\\\\.|<<0>>|[^\\\\"{])*"', [o]), greedy: !0, inside: { interpolation: { - pattern: n('((?:^|[^\\\\])(?:\\\\\\\\)*)<<0>>', [o]), + pattern: r('((?:^|[^\\\\])(?:\\\\\\\\)*)<<0>>', [o]), lookbehind: !0, inside: { punctuation: /^\{|\}$/, |
