improve CSS mode

This commit is contained in:
Fabian Jakobs 2010-09-13 16:30:09 +02:00
commit 117e1ad7aa
2 changed files with 61 additions and 49 deletions

View file

@ -32,6 +32,15 @@
return copy; return copy;
}; };
this.arrayToMap = function(arr) {
var map = {};
for (var i=0; i<arr.length; i++) {
map[arr[i]] = 1;
}
return map;
};
this.escapeRegExp = function(str) { this.escapeRegExp = function(str) {
return str.replace(/([.*+?^${}()|[\]\/\\])/g, '\\$1'); return str.replace(/([.*+?^${}()|[\]\/\\])/g, '\\$1');
}; };

View file

@ -2,57 +2,60 @@ ace.provide("ace.mode.CssHighlightRules");
ace.mode.CssHighlightRules = function() { ace.mode.CssHighlightRules = function() {
var properties = { var properties = ace.arrayToMap(
"width": 1, ("azimuth|background-attachment|background-color|background-image|" +
"height": 1, "background-position|background-repeat|background|border-bottom-color|" +
"top": 1, "border-bottom-style|border-bottom-width|border-bottom|border-collapse|" +
"left": 1, "border-color|border-left-color|border-left-style|border-left-width|" +
"right": 1, "border-left|border-right-color|border-right-style|border-right-width|" +
"bottom": 1, "border-right|border-spacing|border-style|border-top-color|" +
"overflow": 1, "border-top-style|border-top-width|border-top|border-width|border|" +
"overflow-x": 1, "bottom|caption-side|clear|clip|color|content|counter-increment|" +
"overflow-y": 1, "counter-reset|cue-after|cue-before|cue|cursor|direction|display|" +
"background": 1, "elevation|empty-cells|float|font-family|font-size-adjust|font-size|" +
"font": 1, "font-stretch|font-style|font-variant|font-weight|font|height|left|" +
"font-style": 1, "letter-spacing|line-height|list-style-image|list-style-position|" +
"font-family": 1, "list-style-type|list-style|margin-bottom|margin-left|margin-right|" +
"font-size": 1, "margin-top|marker-offset|margin|marks|max-height|max-width|min-height|" +
"text-align": 1, "min-width|-moz-border-radius|opacity|orphans|outline-color|" +
"white-space": 1, "outline-style|outline-width|outline|overflow|overflow-x|overflow-y|padding-bottom|" +
"color": 1, "padding-left|padding-right|padding-top|padding|page-break-after|" +
"z-index": 1, "page-break-before|page-break-inside|page|pause-after|pause-before|" +
"position": 1, "pause|pitch-range|pitch|play-during|position|quotes|richness|right|" +
"cursor": 1, "size|speak-header|speak-numeral|speak-punctuation|speech-rate|speak|" +
"box-sizing": 1, "stress|table-layout|text-align|text-decoration|text-indent|" +
"-webkit-box-sizing": 1, "text-shadow|text-transform|top|unicode-bidi|vertical-align|" +
"-moz-box-sizing": 1, "visibility|voice-family|volume|white-space|widows|width|word-spacing|" +
"margin": 1, "z-index").split("|")
"padding": 1, );
"padding-top": 1,
"padding-right": 1,
"padding-bottom": 1,
"padding-left": 1,
"border": 1,
"border-top": 1,
"border-right": 1,
"border-left": 1,
"border-bottom": 1
};
var functions = { var functions = ace.arrayToMap(
"rgb": 1, ("rgb|rgba|url|attr|counter|counters").split("|")
"rgba": 1 );
};
var constants = { var constants = ace.arrayToMap(
"absolute": 1, ("absolute|all-scroll|always|armenian|auto|baseline|below|bidi-override|" +
"relative": 1, "block|bold|bolder|both|bottom|break-all|break-word|capitalize|center|" +
"fixed": 1, "char|circle|cjk-ideographic|col-resize|collapse|crosshair|dashed|" +
"solid": 1, "decimal-leading-zero|decimal|default|disabled|disc|" +
"hidden": 1, "distribute-all-lines|distribute-letter|distribute-space|" +
"scroll": 1, "distribute|dotted|double|e-resize|ellipsis|fixed|georgian|groove|" +
"no-wrap": 1 "hand|hebrew|help|hidden|hiragana-iroha|hiragana|horizontal|" +
}; "ideograph-alpha|ideograph-numeric|ideograph-parenthesis|" +
"ideograph-space|inactive|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|" +
"medium|middle|move|n-resize|ne-resize|newspaper|no-drop|no-repeat|" +
"nw-resize|none|normal|not-allowed|nowrap|oblique|outset|outside|" +
"overline|pointer|progress|relative|repeat-x|repeat-y|repeat|right|" +
"ridge|row-resize|rtl|s-resize|scroll|se-resize|separate|small-caps|" +
"solid|square|static|strict|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|vertical-text|visible|w-resize|wait|whitespace|" +
"zero").split("|")
);
// regexp must not have capturing parentheses. Use (?:) instead. // regexp must not have capturing parentheses. Use (?:) instead.
// regexps are ordered -> the first match is used // regexps are ordered -> the first match is used