From 006b15b467a5cd835a6eab1b49023100bdc8f2e6 Mon Sep 17 00:00:00 2001 From: Armand Philippot Date: Fri, 13 Oct 2023 19:32:56 +0200 Subject: 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. --- public/prism/prism-scheme.min.js | 153 ++++++++++++++++++++------------------- 1 file changed, 79 insertions(+), 74 deletions(-) (limited to 'public/prism/prism-scheme.min.js') diff --git a/public/prism/prism-scheme.min.js b/public/prism/prism-scheme.min.js index 2bdd0fc..a74a1e8 100644 --- a/public/prism/prism-scheme.min.js +++ b/public/prism/prism-scheme.min.js @@ -1,77 +1,82 @@ -Prism.languages.scheme = { - comment: - /;.*|#;\s*(?:\((?:[^()]|\([^()]*\))*\)|\[(?:[^\[\]]|\[[^\[\]]*\])*\])|#\|(?:[^#|]|#(?!\|)|\|(?!#)|#\|(?:[^#|]|#(?!\|)|\|(?!#))*\|#)*\|#/, - string: { pattern: /"(?:[^"\\]|\\.)*"/, greedy: !0 }, - symbol: { pattern: /'[^()\[\]#'\s]+/, greedy: !0 }, - char: { - pattern: - /#\\(?:[ux][a-fA-F\d]+\b|[-a-zA-Z]+\b|[\uD800-\uDBFF][\uDC00-\uDFFF]|\S)/, - greedy: !0, - }, - 'lambda-parameter': [ - { +!(function (e) { + e.languages.scheme = { + comment: + /;.*|#;\s*(?:\((?:[^()]|\([^()]*\))*\)|\[(?:[^\[\]]|\[[^\[\]]*\])*\])|#\|(?:[^#|]|#(?!\|)|\|(?!#)|#\|(?:[^#|]|#(?!\|)|\|(?!#))*\|#)*\|#/, + string: { pattern: /"(?:[^"\\]|\\.)*"/, greedy: !0 }, + symbol: { pattern: /'[^()\[\]#'\s]+/, greedy: !0 }, + char: { pattern: - /((?:^|[^'`#])[(\[]lambda\s+)(?:[^|()\[\]'\s]+|\|(?:[^\\|]|\\.)*\|)/, + /#\\(?:[ux][a-fA-F\d]+\b|[-a-zA-Z]+\b|[\uD800-\uDBFF][\uDC00-\uDFFF]|\S)/, + greedy: !0, + }, + 'lambda-parameter': [ + { + pattern: + /((?:^|[^'`#])[(\[]lambda\s+)(?:[^|()\[\]'\s]+|\|(?:[^\\|]|\\.)*\|)/, + lookbehind: !0, + }, + { + pattern: /((?:^|[^'`#])[(\[]lambda\s+[(\[])[^()\[\]']+/, + lookbehind: !0, + }, + ], + keyword: { + pattern: + /((?:^|[^'`#])[(\[])(?:begin|case(?:-lambda)?|cond(?:-expand)?|define(?:-library|-macro|-record-type|-syntax|-values)?|defmacro|delay(?:-force)?|do|else|except|export|guard|if|import|include(?:-ci|-library-declarations)?|lambda|let(?:rec)?(?:-syntax|-values|\*)?|let\*-values|only|parameterize|prefix|(?:quasi-?)?quote|rename|set!|syntax-(?:case|rules)|unless|unquote(?:-splicing)?|when)(?=[()\[\]\s]|$)/, + lookbehind: !0, + }, + builtin: { + pattern: + /((?:^|[^'`#])[(\[])(?:abs|and|append|apply|assoc|ass[qv]|binary-port\?|boolean=?\?|bytevector(?:-append|-copy|-copy!|-length|-u8-ref|-u8-set!|\?)?|caar|cadr|call-with-(?:current-continuation|port|values)|call\/cc|car|cdar|cddr|cdr|ceiling|char(?:->integer|-ready\?|\?|<\?|<=\?|=\?|>\?|>=\?)|close-(?:input-port|output-port|port)|complex\?|cons|current-(?:error|input|output)-port|denominator|dynamic-wind|eof-object\??|eq\?|equal\?|eqv\?|error|error-object(?:-irritants|-message|\?)|eval|even\?|exact(?:-integer-sqrt|-integer\?|\?)?|expt|features|file-error\?|floor(?:-quotient|-remainder|\/)?|flush-output-port|for-each|gcd|get-output-(?:bytevector|string)|inexact\??|input-port(?:-open\?|\?)|integer(?:->char|\?)|lcm|length|list(?:->string|->vector|-copy|-ref|-set!|-tail|\?)?|make-(?:bytevector|list|parameter|string|vector)|map|max|member|memq|memv|min|modulo|negative\?|newline|not|null\?|number(?:->string|\?)|numerator|odd\?|open-(?:input|output)-(?:bytevector|string)|or|output-port(?:-open\?|\?)|pair\?|peek-char|peek-u8|port\?|positive\?|procedure\?|quotient|raise|raise-continuable|rational\?|rationalize|read-(?:bytevector|bytevector!|char|error\?|line|string|u8)|real\?|remainder|reverse|round|set-c[ad]r!|square|string(?:->list|->number|->symbol|->utf8|->vector|-append|-copy|-copy!|-fill!|-for-each|-length|-map|-ref|-set!|\?|<\?|<=\?|=\?|>\?|>=\?)?|substring|symbol(?:->string|\?|=\?)|syntax-error|textual-port\?|truncate(?:-quotient|-remainder|\/)?|u8-ready\?|utf8->string|values|vector(?:->list|->string|-append|-copy|-copy!|-fill!|-for-each|-length|-map|-ref|-set!|\?)?|with-exception-handler|write-(?:bytevector|char|string|u8)|zero\?)(?=[()\[\]\s]|$)/, + lookbehind: !0, + }, + operator: { + pattern: /((?:^|[^'`#])[(\[])(?:[-+*%/]|[<>]=?|=>?)(?=[()\[\]\s]|$)/, + lookbehind: !0, + }, + number: { + pattern: RegExp( + (function (e) { + for (var r in e) + e[r] = e[r].replace(/<[\w\s]+>/g, function (r) { + return '(?:' + e[r].trim() + ')'; + }); + return e[r]; + })({ + '': + '\\d+(?:/\\d+)|(?:\\d+(?:\\.\\d*)?|\\.\\d+)(?:[esfdl][+-]?\\d+)?', + '': '[+-]?|[+-](?:inf|nan)\\.0', + '': '[+-](?:|(?:inf|nan)\\.0)?i', + '': + '(?:@|)?|', + '': '(?:#d(?:#[ei])?|#[ei](?:#d)?)?', + '': '[0-9a-f]+(?:/[0-9a-f]+)?', + '': '[+-]?|[+-](?:inf|nan)\\.0', + '': '[+-](?:|(?:inf|nan)\\.0)?i', + '': + '(?:@|)?|', + '': '#[box](?:#[ei])?|(?:#[ei])?#[box]', + '': + '(^|[()\\[\\]\\s])(?:|)(?=[()\\[\\]\\s]|$)', + }), + 'i' + ), + lookbehind: !0, + }, + boolean: { + pattern: /(^|[()\[\]\s])#(?:[ft]|false|true)(?=[()\[\]\s]|$)/, + lookbehind: !0, + }, + function: { + pattern: + /((?:^|[^'`#])[(\[])(?:[^|()\[\]'\s]+|\|(?:[^\\|]|\\.)*\|)(?=[()\[\]\s]|$)/, + lookbehind: !0, + }, + identifier: { + pattern: /(^|[()\[\]\s])\|(?:[^\\|]|\\.)*\|(?=[()\[\]\s]|$)/, lookbehind: !0, + greedy: !0, }, - { pattern: /((?:^|[^'`#])[(\[]lambda\s+[(\[])[^()\[\]']+/, lookbehind: !0 }, - ], - keyword: { - pattern: - /((?:^|[^'`#])[(\[])(?:begin|case(?:-lambda)?|cond(?:-expand)?|define(?:-library|-macro|-record-type|-syntax|-values)?|defmacro|delay(?:-force)?|do|else|except|export|guard|if|import|include(?:-ci|-library-declarations)?|lambda|let(?:rec)?(?:-syntax|-values|\*)?|let\*-values|only|parameterize|prefix|(?:quasi-?)?quote|rename|set!|syntax-(?:case|rules)|unless|unquote(?:-splicing)?|when)(?=[()\[\]\s]|$)/, - lookbehind: !0, - }, - builtin: { - pattern: - /((?:^|[^'`#])[(\[])(?:abs|and|append|apply|assoc|ass[qv]|binary-port\?|boolean=?\?|bytevector(?:-append|-copy|-copy!|-length|-u8-ref|-u8-set!|\?)?|caar|cadr|call-with-(?:current-continuation|port|values)|call\/cc|car|cdar|cddr|cdr|ceiling|char(?:->integer|-ready\?|\?|<\?|<=\?|=\?|>\?|>=\?)|close-(?:input-port|output-port|port)|complex\?|cons|current-(?:error|input|output)-port|denominator|dynamic-wind|eof-object\??|eq\?|equal\?|eqv\?|error|error-object(?:-irritants|-message|\?)|eval|even\?|exact(?:-integer-sqrt|-integer\?|\?)?|expt|features|file-error\?|floor(?:-quotient|-remainder|\/)?|flush-output-port|for-each|gcd|get-output-(?:bytevector|string)|inexact\??|input-port(?:-open\?|\?)|integer(?:->char|\?)|lcm|length|list(?:->string|->vector|-copy|-ref|-set!|-tail|\?)?|make-(?:bytevector|list|parameter|string|vector)|map|max|member|memq|memv|min|modulo|negative\?|newline|not|null\?|number(?:->string|\?)|numerator|odd\?|open-(?:input|output)-(?:bytevector|string)|or|output-port(?:-open\?|\?)|pair\?|peek-char|peek-u8|port\?|positive\?|procedure\?|quotient|raise|raise-continuable|rational\?|rationalize|read-(?:bytevector|bytevector!|char|error\?|line|string|u8)|real\?|remainder|reverse|round|set-c[ad]r!|square|string(?:->list|->number|->symbol|->utf8|->vector|-append|-copy|-copy!|-fill!|-for-each|-length|-map|-ref|-set!|\?|<\?|<=\?|=\?|>\?|>=\?)?|substring|symbol(?:->string|\?|=\?)|syntax-error|textual-port\?|truncate(?:-quotient|-remainder|\/)?|u8-ready\?|utf8->string|values|vector(?:->list|->string|-append|-copy|-copy!|-fill!|-for-each|-length|-map|-ref|-set!|\?)?|with-exception-handler|write-(?:bytevector|char|string|u8)|zero\?)(?=[()\[\]\s]|$)/, - lookbehind: !0, - }, - operator: { - pattern: /((?:^|[^'`#])[(\[])(?:[-+*%/]|[<>]=?|=>?)(?=[()\[\]\s]|$)/, - lookbehind: !0, - }, - number: { - pattern: RegExp( - (function (r) { - for (var e in r) - r[e] = r[e].replace(/<[\w\s]+>/g, function (e) { - return '(?:' + r[e].trim() + ')'; - }); - return r[e]; - })({ - '': - '\\d+(?:/\\d+)|(?:\\d+(?:\\.\\d*)?|\\.\\d+)(?:[esfdl][+-]?\\d+)?', - '': '[+-]?|[+-](?:inf|nan)\\.0', - '': '[+-](?:|(?:inf|nan)\\.0)?i', - '': - '(?:@|)?|', - '': '(?:#d(?:#[ei])?|#[ei](?:#d)?)?', - '': '[0-9a-f]+(?:/[0-9a-f]+)?', - '': '[+-]?|[+-](?:inf|nan)\\.0', - '': '[+-](?:|(?:inf|nan)\\.0)?i', - '': - '(?:@|)?|', - '': '#[box](?:#[ei])?|(?:#[ei])?#[box]', - '': - '(^|[()\\[\\]\\s])(?:|)(?=[()\\[\\]\\s]|$)', - }), - 'i' - ), - lookbehind: !0, - }, - boolean: { - pattern: /(^|[()\[\]\s])#(?:[ft]|false|true)(?=[()\[\]\s]|$)/, - lookbehind: !0, - }, - function: { - pattern: - /((?:^|[^'`#])[(\[])(?:[^|()\[\]'\s]+|\|(?:[^\\|]|\\.)*\|)(?=[()\[\]\s]|$)/, - lookbehind: !0, - }, - identifier: { - pattern: /(^|[()\[\]\s])\|(?:[^\\|]|\\.)*\|(?=[()\[\]\s]|$)/, - lookbehind: !0, - greedy: !0, - }, - punctuation: /[()\[\]']/, -}; + punctuation: /[()\[\]']/, + }; +})(Prism); -- cgit v1.2.3