stylus/dist/codemirror/edit.js

2 lines
52 KiB
JavaScript
Raw Normal View History

2021-12-12 15:21:42 +00:00
!function(){"use strict";let e={};var t;t=function(e){e.defineMode("stylus",(function(e){for(var f,g,b,v,k=e.indentUnit,y="",w=m(t),x=/^(a|b|i|s|col|em)$/i,C=m(r),z=m(a),M=m(c),O=m(l),A=m(n),T=p(n),S=m(o),L=m(i),N=m(s),E=/^\s*([.]{2,3}|&&|\|\||\*\*|[?!=:]?=|[-+*\/%<>]=?|\?:|\~)/,H=p(d),P=m(u),F=new RegExp(/^\-(moz|ms|o|webkit)-/i),j=m(h),q="",R={};y.length<k;)y+=" ";function B(e,t){if(q=e.string.match(/(^[\w-]+\s*=\s*$)|(^\s*[\w-]+\s*=\s*[\w-])|(^\s*(\.|#|@|\$|\&|\[|\d|\+|::?|\{|\>|~|\/)?\s*[\w-]*([a-z0-9-]|\*|\/\*)(\(|,)?)/),t.context.line.firstWord=q?q[0].replace(/^\s*/,""):"",t.context.line.indent=e.indentation(),f=e.peek(),e.match("//"))return e.skipToEnd(),["comment","comment"];if(e.match("/*"))return t.tokenize=I,I(e,t);if('"'==f||"'"==f)return e.next(),t.tokenize=$(f),t.tokenize(e,t);if("@"==f)return e.next(),e.eatWhile(/[\w\\-]/),["def",e.current()];if("#"==f){if(e.next(),e.match(/^[0-9a-f]{3}([0-9a-f]([0-9a-f]{2}){0,2})?\b(?!-)/i))return["atom","atom"];if(e.match(/^[a-z][\w-]*/i))return["builtin","hash"]}return e.match(F)?["meta","vendor-prefixes"]:e.match(/^-?[0-9]?\.?[0-9]/)?(e.eatWhile(/[a-z%]/i),["number","unit"]):"!"==f?(e.next(),[e.match(/^(important|optional)/i)?"keyword":"operator","important"]):"."==f&&e.match(/^\.[a-z][\w-]*/i)?["qualifier","qualifier"]:e.match(T)?("("==e.peek()&&(t.tokenize=W),["property","word"]):e.match(/^[a-z][\w-]*\(/i)?(e.backUp(1),["keyword","mixin"]):e.match(/^(\+|-)[a-z][\w-]*\(/i)?(e.backUp(1),["keyword","block-mixin"]):e.string.match(/^\s*&/)&&e.match(/^[-_]+[a-z][\w-]*/)?["qualifier","qualifier"]:e.match(/^(\/|&)(-|_|:|\.|#|[a-z])/)?(e.backUp(1),["variable-3","reference"]):e.match(/^&{1}\s*$/)?["variable-3","reference"]:e.match(H)?["operator","operator"]:e.match(/^\$?[-_]*[a-z0-9]+[\w-]*/i)?e.match(/^(\.|\[)[\w-\'\"\]]+/i,!1)&&!G(e.current())?(e.match("."),["variable-2","variable-name"]):["variable-2","word"]:e.match(E)?["operator",e.current()]:/[:;,{}\[\]\(\)]/.test(f)?(e.next(),[null,f]):(e.next(),[null,null])}function I(e,t){for(var n,i=!1;null!=(n=e.next());){if(i&&"/"==n){t.tokenize=null;break}i="*"==n}return["comment","comment"]}function $(e){return function(t,n){for(var i,o=!1;null!=(i=t.next());){if(i==e&&!o){")"==e&&t.backUp(1);break}o=!o&&"\\"==i}return(i==e||!o&&")"!=e)&&(n.tokenize=null),["string","string"]}}function W(e,t){return e.next(),e.match(/\s*[\"\')]/,!1)?t.tokenize=null:t.tokenize=$(")"),[null,"("]}function _(e,t,n,i){this.type=e,this.indent=t,this.prev=n,this.line=i||{firstWord:"",indent:0}}function D(e,t,n,i){return i=i>=0?i:k,e.context=new _(n,t.indentation()+i,e.context),n}function U(e,t){var n=e.context.indent-k;return t=t||!1,e.context=e.context.prev,t&&(e.context.indent=n),e.context.type}function K(e,t,n,i){for(var o=i||1;o>0;o--)n.context=n.context.prev;return function(e,t,n){return R[n.context.type](e,t,n)}(e,t,n)}function G(e){return e.toLowerCase()in w}function Y(e){return(e=e.toLowerCase())in C||e in N}function V(e){return e.toLowerCase()in P}function X(e){return e.toLowerCase().match(F)}function Z(e){var t=e.toLowerCase(),n="variable-2";return G(e)?n="tag":V(e)?n="block-keyword":Y(e)?n="property":t in M||t in j?n="atom":"return"==t||t in O?n="keyword":e.match(/^[A-Z]/)&&(n="string"),n}function J(e,t){return ne(t)&&("{"==e||"]"==e||"hash"==e||"qualifier"==e)||"block-mixin"==e}function Q(e,t){return"{"==e&&t.match(/^\s*\$?[\w-]+/i,!1)}function ee(e,t){return":"==e&&t.match(/^[a-z-]+/,!1)}function te(e){return e.sol()||e.string.match(new RegExp("^\\s*"+e.current().replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&")))}function ne(e){return e.eol()||e.match(/^\s*$/,!1)}function ie(e){var t=/^\s*[-_]*[a-z0-9]+[\w-]*/i,n="string"==typeof e?e.match(t):e.string.match(t);return n?n[0].replace(/^\s*/,""):""}return R.block=function(e,t,n){if("comment"==e&&te(t)||","==e&&ne(t)||"mixin"==e)return D(n,t,"block",0);if(Q(e,t))return D(n,t,"interpolation");if(ne(t)&&"]"==e&&!/^\s*(\.|#|:|\[|\*|&)/.test(t.string)&&!G(ie(t)))return D(n,t,"block",0);if(J(e,t))return D(n,t,"block");if("}"==e&&ne(t))return D(n,t,"block",0);if("variable-name"==e)return t.string.match(/^\