You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
1 line
5.1 KiB
1 line
5.1 KiB
"use strict";(self.webpackChunkjupyter_web=self.webpackChunkjupyter_web||[]).push([[4334],{4334:(L,h,v)=>{function a(e){for(var i={},n=0,o=e.length;n<o;++n)i[e[n]]=!0;return i}v.r(h),v.d(h,{ruby:()=>W});var u,b=["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__"],z=a(b),_=a(["def","class","case","for","while","until","module","catch","loop","proc","begin"]),g=a(["end","until"]),x={"[":"]","{":"}","(":")"},y={"]":"[","}":"{",")":"("};function t(e,i,n){return n.tokenize.push(e),e(i,n)}function p(e,i){if(e.sol()&&e.match("=begin")&&e.eol())return i.tokenize.push(T),"comment";if(e.eatSpace())return null;var o,n=e.next();if("`"==n||"'"==n||'"'==n)return t(d(n,"string",'"'==n||"`"==n),e,i);if("/"==n)return function s(e){for(var o,i=e.pos,n=0,l=!1,r=!1;null!=(o=e.next());)if(r)r=!1;else{if("[{(".indexOf(o)>-1)n++;else if("]})".indexOf(o)>-1){if(--n<0)break}else if("/"==o&&0==n){l=!0;break}r="\\"==o}return e.backUp(e.pos-i),l}(e)?t(d(n,"string.special",!0),e,i):"operator";if("%"==n){var l="string",r=!0;e.eat("s")?l="atom":e.eat(/[WQ]/)?l="string":e.eat(/[r]/)?l="string.special":e.eat(/[wxq]/)&&(l="string",r=!1);var f=e.eat(/[^\w\s=]/);return f?(x.propertyIsEnumerable(f)&&(f=x[f]),t(d(f,l,r,!0),e,i)):"operator"}if("#"==n)return e.skipToEnd(),"comment";if("<"==n&&(o=e.match(/^<([-~])[\`\"\']?([a-zA-Z_?]\w*)[\`\"\']?(?:;|$)/)))return t(function E(e,i){return function(n,o){return i&&n.eatSpace(),n.match(e)?o.tokenize.pop():n.skipToEnd(),"string"}}(o[2],o[1]),e,i);if("0"==n)return e.eat("x")?e.eatWhile(/[\da-fA-F]/):e.eat("b")?e.eatWhile(/[01]/):e.eatWhile(/[0-7]/),"number";if(/\d/.test(n))return e.match(/^[\d_]*(?:\.[\d_]+)?(?:[eE][+\-]?[\d_]+)?/),"number";if("?"==n){for(;e.match(/^\\[CM]-/););return e.eat("\\")?e.eatWhile(/\w/):e.next(),"string"}if(":"==n)return e.eat("'")?t(d("'","atom",!1),e,i):e.eat('"')?t(d('"',"atom",!0),e,i):e.eat(/[\<\>]/)?(e.eat(/[\<\>]/),"atom"):e.eat(/[\+\-\*\/\&\|\:\!]/)?"atom":e.eat(/[a-zA-Z$@_\xa1-\uffff]/)?(e.eatWhile(/[\w$\xa1-\uffff]/),e.eat(/[\?\!\=]/),"atom"):"operator";if("@"==n&&e.match(/^@?[a-zA-Z_\xa1-\uffff]/))return e.eat("@"),e.eatWhile(/[\w\xa1-\uffff]/),"propertyName";if("$"==n)return e.eat(/[a-zA-Z_]/)?e.eatWhile(/[\w]/):e.eat(/\d/)?e.eat(/\d/):e.next(),"variableName.special";if(/[a-zA-Z_\xa1-\uffff]/.test(n))return e.eatWhile(/[\w\xa1-\uffff]/),e.eat(/[\?\!]/),e.eat(":")?"atom":"variable";if("|"==n&&(i.varList||"{"==i.lastTok||"do"==i.lastTok))return u="|",null;if(/[\(\)\[\]{}\\;]/.test(n))return u=n,null;if("-"==n&&e.eat(">"))return"operator";if(/[=+\-\/*:\.^%<>~|]/.test(n)){var c=e.eatWhile(/[=+\-\/*:\.^%<>~|]/);return"."==n&&!c&&(u="."),"operator"}return null}function k(e){return e||(e=1),function(i,n){if("}"==i.peek()){if(1==e)return n.tokenize.pop(),n.tokenize[n.tokenize.length-1](i,n);n.tokenize[n.tokenize.length-1]=k(e-1)}else"{"==i.peek()&&(n.tokenize[n.tokenize.length-1]=k(e+1));return p(i,n)}}function w(){var e=!1;return function(i,n){return e?(n.tokenize.pop(),n.tokenize[n.tokenize.length-1](i,n)):(e=!0,p(i,n))}}function d(e,i,n,o){return function(l,r){var c,f=!1;for("read-quoted-paused"===r.context.type&&(r.context=r.context.prev,l.eat("}"));null!=(c=l.next());){if(c==e&&(o||!f)){r.tokenize.pop();break}if(n&&"#"==c&&!f){if(l.eat("{")){"}"==e&&(r.context={prev:r.context,type:"read-quoted-paused"}),r.tokenize.push(k());break}if(/[@\$]/.test(l.peek())){r.tokenize.push(w());break}}f=!f&&"\\"==c}return i}}function T(e,i){return e.sol()&&e.match("=end")&&e.eol()&&i.tokenize.pop(),e.skipToEnd(),"comment"}const W={name:"ruby",startState:function(e){return{tokenize:[p],indented:0,context:{type:"top",indented:-e},continuedLine:!1,lastTok:null,varList:!1}},token:function(e,i){u=null,e.sol()&&(i.indented=e.indentation());var o,n=i.tokenize[i.tokenize.length-1](e,i),l=u;if("variable"==n){var r=e.current();"keyword"==(n="."==i.lastTok?"property":z.propertyIsEnumerable(e.current())?"keyword":/^[A-Z]/.test(r)?"tag":"def"==i.lastTok||"class"==i.lastTok||i.varList?"def":"variable")&&(l=r,_.propertyIsEnumerable(r)?o="indent":g.propertyIsEnumerable(r)?o="dedent":(("if"==r||"unless"==r)&&e.column()==e.indentation()||"do"==r&&i.context.indented<i.indented)&&(o="indent"))}return(u||n&&"comment"!=n)&&(i.lastTok=l),"|"==u&&(i.varList=!i.varList),"indent"==o||/[\(\[\{]/.test(u)?i.context={prev:i.context,type:u||n,indented:i.indented}:("dedent"==o||/[\)\]\}]/.test(u))&&i.context.prev&&(i.context=i.context.prev),e.eol()&&(i.continuedLine="\\"==u||"operator"==n),n},indent:function(e,i,n){if(e.tokenize[e.tokenize.length-1]!=p)return null;var o=i&&i.charAt(0),l=e.context,r=l.type==y[o]||"keyword"==l.type&&/^(?:end|until|else|elsif|when|rescue)\b/.test(i);return l.indented+(r?0:n.unit)+(e.continuedLine?n.unit:0)},languageData:{indentOnInput:/^\s*(?:end|rescue|elsif|else|\})$/,commentTokens:{line:"#"},autocomplete:b}}}}]); |