From 8d177ccced0f2954006274032e647ce23b70127e Mon Sep 17 00:00:00 2001 From: hareeqi Date: Fri, 13 Oct 2017 16:00:25 +0300 Subject: [PATCH] add css2js highlighting --- grammars/javascript.cson | 370 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 370 insertions(+) diff --git a/grammars/javascript.cson b/grammars/javascript.cson index 8883c3e9..429fb777 100644 --- a/grammars/javascript.cson +++ b/grammars/javascript.cson @@ -1244,6 +1244,20 @@ 'match': '\\A#!.*$' 'name': 'comment.line.shebang.js' } + { + 'begin': 'css`' + 'end': '`' + 'patterns': [ + { + 'begin': '(?=\\{)' + 'end': '(?!\\G)' + 'patterns': [ + { 'include': '#rule-list' } + ] + } + { 'include': 'source.css' } + ] + } ] 'repository': 'numbers': @@ -2013,3 +2027,359 @@ ] } ] + 'property-values': + 'patterns': [ + { + 'begin': '(var)\\(' + 'end': '\\)' + 'captures': + '1': + 'name': 'support.function.misc.css' + 'patterns': [ + 'name': 'variable.argument.css' + 'match': '.' + ] + } + { + 'begin': '(calc|cubic-bezier|steps)\\(' + 'end': '\\)' + 'captures': + '1': + 'name': 'support.function.misc.css' + 'patterns': [ + 'include': '#property-values' + ] + } + { + 'match': '\\b(absolute|all(-scroll)?|alternate-reverse|alternate|always|armenian|auto|avoid|backwards|baseline|below|bidi-override|block|bold|bolder|border(-(box|top|right|bottom|left))?|both|bottom|break-all|break-word|capitalize|center|char|circle|cjk-ideographic|col-resize|column|column-reverse|collapse|content-box|crosshair|dashed|decimal-leading-zero|decimal|default|disabled|disc|distribute-all-lines|distribute-letter|distribute-space|distribute|dotted|double|ease-in-out|ease-in|ease-out|ease|e-resize|ellipsis|fixed|flex|flex-end|flex-start|forwards|geometricPrecision|georgian|groove|hand|hebrew|help|hidden|hiragana-iroha|hiragana|horizontal|ideograph-alpha|ideograph-numeric|ideograph-parenthesis|ideograph-space|inactive|infinite|inherit|inline-block|inline|inset|inside|inter-ideograph|inter-word|italic|justify|katakana-iroha|katakana|keep-all|left|lighter|line-edge|line-through|line|list-item|loose|lower-alpha|lower-greek|lower-latin|lower-roman|lowercase|lr-tb|ltr|main-size|margin(-(left|right|top|bottom))?|manipulation|medium|middle|move|n-resize|ne-resize|newspaper|no-drop|no-repeat|nw-resize|none|normal|not-allowed|nowrap|oblique|optimize(Legibility|Quality|Speed)|outset|outside|overline|padding-box|padding(-(left|right|top|bottom))?|pan-(x|y|left|right|up|down)|pointer|pre(-(wrap|line))?|preserve-3d|progress|relative|repeat-x|repeat-y|repeat|reverse|right|ridge|row-resize|row-severse|rtl|running|s-resize|scroll|se-resize|separate|small-caps|solid|space-around|space-between|square|start|static|step-end|step-start|stretch|strict|sub|super|sw-resize|table-footer-group|table-header-group|tb-rl|text-bottom|text-top|text|thick|thin|top|transparent|underline|upper-alpha|upper-latin|upper-roman|uppercase|vertical(-(ideographic|text))?|visible(Painted|Fill|Stroke)?|w-resize|wait|whitespace|wrap|wrap-reverse|zero|smaller|larger|((xx?-)?(small|large))|painted|paused|fill|end|stroke)\\b' + 'name': 'support.constant.property-value.css' + } + { + 'match': '(\\b(?i:arial|century|comic|courier|garamond|georgia|helvetica|impact|lucida|symbol|system|tahoma|times|trebuchet|utopia|verdana|webdings|sans-serif|serif|monospace)\\b)' + 'name': 'support.constant.font-name.css' + } + { + 'include': '#numeric-values' + } + { + 'include': '#color-values' + } + { + 'include': '#string-double' + } + { + 'include': '#string-single' + } + { + 'begin': '(rect)\\s*(\\()' + 'beginCaptures': + '1': + 'name': 'support.function.misc.css' + '2': + 'name': 'punctuation.section.function.css' + 'end': '(\\))' + 'endCaptures': + '1': + 'name': 'punctuation.section.function.css' + 'patterns': [ + { + 'include': '#numeric-values' + } + ] + } + { + 'begin': '(format|local|url|attr|counter|counters)\\s*(\\()' + 'beginCaptures': + '1': + 'name': 'support.function.misc.css' + '2': + 'name': 'punctuation.section.function.css' + 'end': '(\\))' + 'endCaptures': + '1': + 'name': 'punctuation.section.function.css' + 'patterns': [ + { + 'include': '#string-single' + } + { + 'include': '#string-double' + } + { + 'match': '[^\'") \\t]+' + 'name': 'variable.parameter.misc.css' + } + ] + } + { + 'match': '\\!\\s*important' + 'name': 'keyword.other.important.css' + } + ] + 'color-values': + 'patterns': [ + { + 'comment': 'http://www.w3.org/TR/CSS21/syndata.html#value-def-color' + 'match': '\\b(aqua|black|blue|fuchsia|gray|green|lime|maroon|navy|olive|orange|purple|red|silver|teal|white|yellow)\\b' + 'name': 'support.constant.color.w3c-standard-color-name.css' + } + { + 'comment': 'http://www.w3.org/TR/css3-color/#svg-color' + 'match': '\\b(aliceblue|antiquewhite|aquamarine|azure|beige|bisque|blanchedalmond|blueviolet|brown|burlywood|cadetblue|chartreuse|chocolate|coral|cornflowerblue|cornsilk|crimson|cyan|darkblue|darkcyan|darkgoldenrod|darkgray|darkgreen|darkgrey|darkkhaki|darkmagenta|darkolivegreen|darkorange|darkorchid|darkred|darksalmon|darkseagreen|darkslateblue|darkslategray|darkslategrey|darkturquoise|darkviolet|deeppink|deepskyblue|dimgray|dimgrey|dodgerblue|firebrick|floralwhite|forestgreen|gainsboro|ghostwhite|gold|goldenrod|greenyellow|grey|honeydew|hotpink|indianred|indigo|ivory|khaki|lavender|lavenderblush|lawngreen|lemonchiffon|lightblue|lightcoral|lightcyan|lightgoldenrodyellow|lightgray|lightgreen|lightgrey|lightpink|lightsalmon|lightseagreen|lightskyblue|lightslategray|lightslategrey|lightsteelblue|lightyellow|limegreen|linen|magenta|mediumaquamarine|mediumblue|mediumorchid|mediumpurple|mediumseagreen|mediumslateblue|mediumspringgreen|mediumturquoise|mediumvioletred|midnightblue|mintcream|mistyrose|moccasin|navajowhite|oldlace|olivedrab|orangered|orchid|palegoldenrod|palegreen|paleturquoise|palevioletred|papayawhip|peachpuff|peru|pink|plum|powderblue|rosybrown|royalblue|saddlebrown|salmon|sandybrown|seagreen|seashell|sienna|skyblue|slateblue|slategray|slategrey|snow|springgreen|steelblue|tan|thistle|tomato|turquoise|violet|wheat|whitesmoke|yellowgreen)\\b' + 'name': 'support.constant.color.w3c-extended-color-name.css' + } + { + 'comment': 'These colours are deprecated from CSS color module level 3 http://www.w3.org/TR/css3-color/#css2-system' + 'match': '\\b(ActiveBorder|ActiveCaption|AppWorkspace|Background|ButtonFace|ButtonHighlight|ButtonShadow|ButtonText|CaptionText|GrayText|Highlight|HighlightText|InactiveBorder|InactiveCaption|InactiveCaptionText|InfoBackground|InfoText|Menu|MenuText|Scrollbar|ThreeDDarkShadow|ThreeDFace|ThreeDHighlight|ThreeDLightShadow|ThreeDShadow|Window|WindowFrame|WindowText)\\b' + 'name': 'invalid.deprecated.color.system.css' + } + { + 'begin': '(hsla?|rgba?)\\s*(\\()' + 'beginCaptures': + '1': + 'name': 'support.function.misc.css' + '2': + 'name': 'punctuation.section.function.css' + 'end': '(\\))' + 'endCaptures': + '1': + 'name': 'punctuation.section.function.css' + 'patterns': [ + { + 'match': '(?x)\\b\n\t\t\t\t\t\t\t (0*((1?[0-9]{1,2})|(2([0-4][0-9]|5[0-5])))\\s*,\\s*){2}\n\t\t\t\t\t\t\t (0*((1?[0-9]{1,2})|(2([0-4][0-9]|5[0-5])))\\b)\n\t\t\t\t\t\t\t (\\s*,\\s*((0?\\.[0-9]+)|[0-1]))?\n\t\t\t\t\t\t\t' + 'name': 'constant.other.color.rgb-value.css' + } + { + 'match': '\\b([0-9]{1,2}|100)\\s*%,\\s*([0-9]{1,2}|100)\\s*%,\\s*([0-9]{1,2}|100)\\s*%' + 'name': 'constant.other.color.rgb-percentage.css' + } + { + 'include': '#numeric-values' + } + ] + } + ] + 'numeric-values': + 'patterns': [ + { + 'captures': + '1': + 'name': 'punctuation.definition.constant.css' + 'match': '(#)([0-9a-fA-F]{3}|[0-9a-fA-F]{6})\\b' + 'name': 'constant.other.color.rgb-value.css' + } + { + 'captures': + '1': + 'name': 'keyword.other.unit.css' + 'match': '(?x) + (?