Warning, /frameworks/syntax-highlighting/autotests/input/test.mss is written in an unsupported language. File is not indexed.

0001 /* kate: hl CartoCSS
0002    This file contains some content coming from
0003    https://github.com/gravitystorm/openstreetmap-carto
0004    with CC0 license. This file is just for testing
0005    katepart highlighting engine.
0006    */
0007 
0008 /* This is
0009 a multiline comment. */
0010 
0011 // This is a single-line comment.
0012 
0013 #world {
0014     // various styles to define colors (all except the color function are rendered the same way):
0015     // Numbers are always treated as floating-point and highlighted. This syntax
0016     polygon-opacity: 50%;
0017     // is equivalent to
0018     polygon-opacity: 0.5;
0019     // This is a coma-separated list of numbers:
0020     line-dasharray: 6,3,2,3,2,3;
0021     // Also function calls are possible. Function calls like “url” get special highlighting:
0022     shield-file: url("myfile.svg");
0023     // Within function calls, strings can contains fields like [width] which get special highlighting:
0024     shield-file: url("symbols/shields/motorway_[width]x[height].svg");
0025     polygon-fill: white; // List of known colors
0026     polygon-fill: #ffffff; // Six-digit hex color
0027     polygon-fill: #fff; // Three-digit hex color
0028     polygon-fill: #ffff; // Invalid hex color
0029     polygon-fill: rgba(255,255,255,1); // define a color by a special function
0030     // everything else is simply interpreted as keyword:
0031     line-clip: false;
0032     line-clip: abcdef;
0033 }
0034 
0035 // You can define macros called “CartoCSS variables” with arbitrary values and types.
0036 // They do not behave much like variable, but more like macros.
0037 @myvariable: 15;
0038 @myvariable: #123456;
0039 @myvariable: white;
0040 @myothervariable: @myvariable; // this variable gets defined by the value of another variable
0041 @myvariable: darken(white, 5%); // A variable defined by the result of a function. The function “darken” gets special highlighting.
0042 // Variables can also contain strings:
0043 @myvariable: 'abc';
0044 
0045 // These variables can be used later as values
0046 #world {
0047     polygon-fill: @myvariable;
0048 }
0049 
0050 /* Typically, in MSS files you declare filters like “#world[zoom >= 17]”
0051 followed by curly braces with parameters like “size” for Mapnik symbolizers like “text”. */
0052 
0053 // Each Mapnik symbolizer parameter can be on its own line:
0054 #world[zoom >= 17] {
0055   text-wrap-width: 20;
0056   text-size: 11;
0057 }
0058 // Or you can put various of them into the same line:
0059 #world[zoom >= 19] { text-wrap-width: 20; text-size: 11; }
0060 
0061 // It is allowed to omit the final “;” for the last Mapnik symbolizer parameter within a block:
0062 #world[zoom >= 19] { text-wrap-width: 20; text-size: 11 }
0063 // Also after an omitted final “;” the following code is nevertheless highlighted correctly:
0064 #world[zoom >= 19] { text-wrap-width: 20; text-size: 11 ; }
0065 // “null” and “zoom” are special keywords within filters, and highlighted as such:
0066 ["name" != null]["ref" = null][zoom >= 19] { text-wrap-width: 20; }
0067 
0068 #admin-low-zoom[zoom < 11], // You can make coma-separated lists of various filters
0069 #admin-mid-zoom[zoom >= 11][zoom < 13], // like this one.
0070 #admin-high-zoom[zoom >= 13] {
0071   [zoom = 15] // “zoom” has special behaviour within filters and gets its own highlighting
0072   [admin_level = '2'], // data fields like “admin_level” can be referenced by their name and get highlighting as data fields
0073   ["admin_level" = '2'], // data fields like “admin_level” can be referenced by their name in quotes and get highlighting as data fields
0074   [admin_level = '3'] {
0075     [zoom >= 4] {
0076       // You can create additional “Named instances” of Mapnik symbolizers by adding a “myname/” before the symbolizer.
0077       // The name of the named instance gets special highlighting:
0078       background/line-color: white;
0079       line-color: @admin-boundaries;
0080     }
0081   }
0082 }
0083 
0084 #admin-mid-zoom[zoom >= 11][zoom < 13] {
0085   [admin_level = 'abc'] { // The string 'abc' is highlighted as a verbatim string, not as an expression string.
0086     [zoom >= 4] {
0087       text-name: [test]; // simplified reference to the value of the data field “test”
0088       text-name: "[test]"; // another reference to the data field “test”, this time within an expression string
0089       // A rather complex expression string that will do some math; @zoom is a special runtime value (in spite
0090       // of the @ it has nothing to do with ordinary variables):
0091       text-size: "([way_area]*pow(4,@zoom)/24505740000)";
0092       // Here the same thing as simple expression:
0093       // Note that @zoom now is highlighted in another color, because in this context it does not reference to a
0094       // runtime variable anymore, but to an ordinary CartoCSS variable:
0095       text-size: ([way_area]*pow(4,@zoom)/24505740000);
0096       text-name: "'Value: '[test]"; // A verbatim string 'Value: ' as part of an expression string.
0097       text-name: '"Value: "[test]'; // " and ' are interchangeable. The outer is always the expression string and the inner the verbatim string.
0098       text-name: "[field]\n"; // Expression strings however do not have escape sequences, so \n gets no special highlighting here. [field] however is highlighted as data field.
0099       text-name: "[field]+'\n'+[otherfield]"; // Inner strings, here the single-quoted string, are normal strings and highlight escape sequences like \n.
0100       text-name: "[field]+'[testfield]'+[otherfield]"; // Inner strings, here the single-quoted string, are normal strings and do not highlight any fields like [testfield].
0101       text-name: [name] + /* Comments are not allowed within expressions, so no special comment highlighting here. */ "\n" + [ref];
0102     }
0103   }
0104 }
0105 
0106 .nature { // .nature references a class, which is similar to a layer like #nature, so both are rendered the same way
0107     ::fill {
0108         /* The :: syntax defined “attachments” (a sort of sub-layer within normal layers), here “::fill”.
0109         Everything that is defined within an attachment is applied in the order of the first occurrence
0110         of the attachment, instead of following the normal appliance order. Therefore attachments are
0111         highlighted as dsControlFlow by default. */
0112         opacity: 0.05;
0113     }
0114 }