Files
ijmuv-blog-release/frontend/assets/ruby-UpDQg5ds.js
2026-05-08 13:39:01 +08:00

1 line
5.0 KiB
JavaScript

function e(e){for(var t={},n=0,r=e.length;n<r;++n)t[e[n]]=!0;return t}var t=`alias.and.BEGIN.begin.break.case.class.def.defined?.do.else.elsif.END.end.ensure.false.for.if.in.module.next.not.or.redo.rescue.retry.return.self.super.then.true.undef.unless.until.when.while.yield.nil.raise.throw.catch.fail.loop.callcc.caller.lambda.proc.public.protected.private.require.load.require_relative.extend.autoload.__END__.__FILE__.__LINE__.__dir__`.split(`.`),n=e(t),r=e([`def`,`class`,`case`,`for`,`while`,`until`,`module`,`catch`,`loop`,`proc`,`begin`]),i=e([`end`,`until`]),a={"[":`]`,"{":`}`,"(":`)`},o={"]":`[`,"}":`{`,")":`(`},s;function c(e,t,n){return n.tokenize.push(e),e(t,n)}function l(e,t){if(e.sol()&&e.match(`=begin`)&&e.eol())return t.tokenize.push(h),`comment`;if(e.eatSpace())return null;var n=e.next(),r;if(n=="`"||n==`'`||n==`"`)return c(p(n,`string`,n==`"`||n=="`"),e,t);if(n==`/`)return u(e)?c(p(n,`string.special`,!0),e,t):`operator`;if(n==`%`){var i=`string`,o=!0;e.eat(`s`)?i=`atom`:e.eat(/[WQ]/)?i=`string`:e.eat(/[r]/)?i=`string.special`:e.eat(/[wxq]/)&&(i=`string`,o=!1);var l=e.eat(/[^\w\s=]/);return l?(a.propertyIsEnumerable(l)&&(l=a[l]),c(p(l,i,o,!0),e,t)):`operator`}else if(n==`#`)return e.skipToEnd(),`comment`;else if(n==`<`&&(r=e.match(/^<([-~])[\`\"\']?([a-zA-Z_?]\w*)[\`\"\']?(?:;|$)/)))return c(m(r[2],r[1]),e,t);else if(n==`0`)return e.eat(`x`)?e.eatWhile(/[\da-fA-F]/):e.eat(`b`)?e.eatWhile(/[01]/):e.eatWhile(/[0-7]/),`number`;else if(/\d/.test(n))return e.match(/^[\d_]*(?:\.[\d_]+)?(?:[eE][+\-]?[\d_]+)?/),`number`;else if(n==`?`){for(;e.match(/^\\[CM]-/););return e.eat(`\\`)?e.eatWhile(/\w/):e.next(),`string`}else if(n==`:`)return e.eat(`'`)?c(p(`'`,`atom`,!1),e,t):e.eat(`"`)?c(p(`"`,`atom`,!0),e,t):e.eat(/[\<\>]/)?(e.eat(/[\<\>]/),`atom`):e.eat(/[\+\-\*\/\&\|\:\!]/)?`atom`:e.eat(/[a-zA-Z$@_\xa1-\uffff]/)?(e.eatWhile(/[\w$\xa1-\uffff]/),e.eat(/[\?\!\=]/),`atom`):`operator`;else if(n==`@`&&e.match(/^@?[a-zA-Z_\xa1-\uffff]/))return e.eat(`@`),e.eatWhile(/[\w\xa1-\uffff]/),`propertyName`;else if(n==`$`)return e.eat(/[a-zA-Z_]/)?e.eatWhile(/[\w]/):e.eat(/\d/)?e.eat(/\d/):e.next(),`variableName.special`;else if(/[a-zA-Z_\xa1-\uffff]/.test(n))return e.eatWhile(/[\w\xa1-\uffff]/),e.eat(/[\?\!]/),e.eat(`:`)?`atom`:`variable`;else if(n==`|`&&(t.varList||t.lastTok==`{`||t.lastTok==`do`))return s=`|`,null;else if(/[\(\)\[\]{}\\;]/.test(n))return s=n,null;else if(n==`-`&&e.eat(`>`))return`operator`;else if(/[=+\-\/*:\.^%<>~|]/.test(n)){var d=e.eatWhile(/[=+\-\/*:\.^%<>~|]/);return n==`.`&&!d&&(s=`.`),`operator`}else return null}function u(e){for(var t=e.pos,n=0,r,i=!1,a=!1;(r=e.next())!=null;)if(a)a=!1;else{if(`[{(`.indexOf(r)>-1)n++;else if(`]})`.indexOf(r)>-1){if(n--,n<0)break}else if(r==`/`&&n==0){i=!0;break}a=r==`\\`}return e.backUp(e.pos-t),i}function d(e){return e||=1,function(t,n){if(t.peek()==`}`){if(e==1)return n.tokenize.pop(),n.tokenize[n.tokenize.length-1](t,n);n.tokenize[n.tokenize.length-1]=d(e-1)}else t.peek()==`{`&&(n.tokenize[n.tokenize.length-1]=d(e+1));return l(t,n)}}function f(){var e=!1;return function(t,n){return e?(n.tokenize.pop(),n.tokenize[n.tokenize.length-1](t,n)):(e=!0,l(t,n))}}function p(e,t,n,r){return function(i,a){var o=!1,s;for(a.context.type===`read-quoted-paused`&&(a.context=a.context.prev,i.eat(`}`));(s=i.next())!=null;){if(s==e&&(r||!o)){a.tokenize.pop();break}if(n&&s==`#`&&!o){if(i.eat(`{`)){e==`}`&&(a.context={prev:a.context,type:`read-quoted-paused`}),a.tokenize.push(d());break}else if(/[@\$]/.test(i.peek())){a.tokenize.push(f());break}}o=!o&&s==`\\`}return t}}function m(e,t){return function(n,r){return t&&n.eatSpace(),n.match(e)?r.tokenize.pop():n.skipToEnd(),`string`}}function h(e,t){return e.sol()&&e.match(`=end`)&&e.eol()&&t.tokenize.pop(),e.skipToEnd(),`comment`}var g={name:`ruby`,startState:function(e){return{tokenize:[l],indented:0,context:{type:`top`,indented:-e},continuedLine:!1,lastTok:null,varList:!1}},token:function(e,t){s=null,e.sol()&&(t.indented=e.indentation());var a=t.tokenize[t.tokenize.length-1](e,t),o,c=s;if(a==`variable`){var l=e.current();a=t.lastTok==`.`?`property`:n.propertyIsEnumerable(e.current())?`keyword`:/^[A-Z]/.test(l)?`tag`:t.lastTok==`def`||t.lastTok==`class`||t.varList?`def`:`variable`,a==`keyword`&&(c=l,r.propertyIsEnumerable(l)?o=`indent`:i.propertyIsEnumerable(l)?o=`dedent`:((l==`if`||l==`unless`)&&e.column()==e.indentation()||l==`do`&&t.context.indented<t.indented)&&(o=`indent`))}return(s||a&&a!=`comment`)&&(t.lastTok=c),s==`|`&&(t.varList=!t.varList),o==`indent`||/[\(\[\{]/.test(s)?t.context={prev:t.context,type:s||a,indented:t.indented}:(o==`dedent`||/[\)\]\}]/.test(s))&&t.context.prev&&(t.context=t.context.prev),e.eol()&&(t.continuedLine=s==`\\`||a==`operator`),a},indent:function(e,t,n){if(e.tokenize[e.tokenize.length-1]!=l)return null;var r=t&&t.charAt(0),i=e.context,a=i.type==o[r]||i.type==`keyword`&&/^(?:end|until|else|elsif|when|rescue)\b/.test(t);return i.indented+(a?0:n.unit)+(e.continuedLine?n.unit:0)},languageData:{indentOnInput:/^\s*(?:end|rescue|elsif|else|\})$/,commentTokens:{line:`#`},autocomplete:t}};export{g as ruby};