@ryusei/light
Version:
<div align="center"> <a href="https://light.ryuseijs.com"> <img alt="RyuseiLight" src="https://light.ryuseijs.com/images/svg/logo.svg" width="70"> </a>
2 lines (1 loc) • 3.1 kB
JavaScript
!function(e,n){if("function"==typeof define&&define.amd)define([],n);else if("undefined"!=typeof exports)n();else{n(),e.unknown={}}}("undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:this,(function(){var e="keyword",n="comment",a="string",t="class",i="operator",r="bracket",s="delimiter",o="space",u=/[+-]?(\d+\.?\d*|\d*\.?\d+)([eE][+-]?\d+)?/,f=/\b(?:true|false)\b/,d=/[[\]{}()]/,c=/[ \t]+/,l=/'(?:\\'|.)*?'/,g=/"(?:\\"|.)*?"/,p=/\/\*[\s\S]*?(\*\/|$)/,b=/\/\/.*/,m=/\b(?:break|catch|class|continue|do|else|extends|finally|for|function|if|implements|in|instanceof|interface|new|null|return|throw|try|while)\b/;function k(e){return null!==e&&"object"==typeof e}function w(e){return void 0===e}function y(e,n){if(e)for(var a=Object.keys(e),t=0;t<a.length;t++)n(e[a[t]],a[t])}function F(e){for(var n=arguments.length,a=new Array(n>1?n-1:0),t=1;t<n;t++)a[t-1]=arguments[t];return a.forEach((function(n){k(n)&&y(n,(function(a,t){w(n[t])||(e[t]=n[t])}))})),e}function h(){return{id:"javascript",name:"JavaScript",alias:["js"],source:{func:/[_$a-z\xA0-\uFFFF][_$a-z0-9\xA0-\uFFFF]*/},grammar:{main:[[a,l],[a,g],["#backtick",/`/,"@rest"],[n,p],[n,b],["regexp",/\/(\[.*?]|\\\/|.)+?\/[gimsuy]*/],[e,m],[e,/\b(?:as|async|await|case|catch|const|debugger|default|delete|enum|export|from|import|let|package|private|protected|public|super|switch|static|this|typeof|undefined|var|void|with|yield)\b/],[e,/\b((get|set)(?=\s+%func))/i],[t,/\b[A-Z][\w$]*\b/],["function",/%func(?=\s*\()/i],["boolean",f],["decorator",/@[^\s(@]+/],["identifier",/\b[a-z_$][\w$]*\b/],["number",u],[i,/=>/],[i,/\+[+=]?|-[-=]?|\*\*?=?|[/%^]=?|&&?=?|\|\|?=?|\?\??=?|<<?=?|>>>=?|>>?=?|[!=]=?=?|[~:^]/],[r,d],[s,/[;.,]+/],[o,c]],backtick:[[a,/^`/],[a,/(\$[^{]|\\[$`]|[^`$])+/],["#expression",/\${/,"@rest"],[a,/`/,"@break"]],expression:[[s,/^\${/],[s,/}/,"@break"],["#main"]]}}}"undefined"!=typeof window&&window.RyuseiLight&&window.RyuseiLight.register(function(e){void 0===e&&(e={});var n,a,i,u=F((e.base||h)(),{id:"jsx",name:"JSX",alias:["react"]}),f=u.grammar;return n=f.main,a=[["#findPairedTag"],["#findSelfClosedTag"]],(i=function(e,n){for(var a=0;a<e.length;a++)if(e[a][0]===n)return a;return-1}(n,t))>-1?n.splice.apply(n,[i,0].concat(a)):n.push.apply(n,a),F(f,{findPairedTag:[["#pairedTag",/(?:<[\t-\r \xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF]*?([0-9A-Z_a-z]+)[\s\S]*?>[\s\S]*?<\/\1>)|<[\t-\r \xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF]*?>[\s\S]*?<\/>/,"@rest"]],findSelfClosedTag:[["#selfClosedTag",/<(?:\{[\s\S]*?\}|(["'])[\s\S]*?\1|(?:(?!>)[\s\S]))+?\/>/]],findBracket:[["#code",/{/,"@rest"]],pairedTag:[["#openTag",/^</,"@rest"],["#findBracket"],["#findPairedTag"],["#findSelfClosedTag"],["#tagName",/<\/([\w][^\s]*?)?>/,"@break"],[o,c]],code:[[r,/^{/],[r,/}/,"@break"],["#findBracket"],["#main"]],selfClosedTag:[["#openTag",/^</,"@rest"]],openTag:[["#tagName",/<\s*[^\s/>"'=]*/],["#findBracket"],["attr",/[^\s/>"'=]+/],["value",/(['"])(\\\1|.)*?\1/],[o,c],[s,/[/=]/],[r,/>/,"@break"]],tagName:[[r,/[<>]/],[o,c],[s,/\//],[t,/[A-Z][\w$-]*/],["tag",/[^\s/>"'=]+/]]}),u}())}));