Subversion-Projekte lars-tiefland.ci

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
875 lars 1
// Copyright (C) 2009 Google Inc.
2
//
3
// Licensed under the Apache License, Version 2.0 (the "License");
4
// you may not use this file except in compliance with the License.
5
// You may obtain a copy of the License at
6
//
7
//      http://www.apache.org/licenses/LICENSE-2.0
8
//
9
// Unless required by applicable law or agreed to in writing, software
10
// distributed under the License is distributed on an "AS IS" BASIS,
11
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
// See the License for the specific language governing permissions and
13
// limitations under the License.
14
 
15
 
16
 
17
/**
18
 * @fileoverview
19
 * Registers a language handler for CSS.
20
 *
21
 *
22
 * To use, include prettify.js and this file in your HTML page.
23
 * Then put your code in an HTML tag like
24
 *      <pre class="prettyprint lang-css"></pre>
25
 *
26
 *
27
 * http://www.w3.org/TR/CSS21/grammar.html Section G2 defines the lexical
28
 * grammar.  This scheme does not recognize keywords containing escapes.
29
 *
30
 * @author mikesamuel@gmail.com
31
 */
32
 
33
PR['registerLangHandler'](
34
    PR['createSimpleLexer'](
35
        [
36
         // The space production <s>
37
         [PR['PR_PLAIN'],       /^[ \t\r\n\f]+/, null, ' \t\r\n\f']
38
        ],
39
        [
40
         // Quoted strings.  <string1> and <string2>
41
         [PR['PR_STRING'],
42
          /^\"(?:[^\n\r\f\\\"]|\\(?:\r\n?|\n|\f)|\\[\s\S])*\"/, null],
43
         [PR['PR_STRING'],
44
          /^\'(?:[^\n\r\f\\\']|\\(?:\r\n?|\n|\f)|\\[\s\S])*\'/, null],
45
         ['lang-css-str', /^url\(([^\)\"\']*)\)/i],
46
         [PR['PR_KEYWORD'],
47
          /^(?:url|rgb|\!important|@import|@page|@media|@charset|inherit)(?=[^\-\w]|$)/i,
48
          null],
49
         // A property name -- an identifier followed by a colon.
50
         ['lang-css-kw', /^(-?(?:[_a-z]|(?:\\[0-9a-f]+ ?))(?:[_a-z0-9\-]|\\(?:\\[0-9a-f]+ ?))*)\s*:/i],
51
         // A C style block comment.  The <comment> production.
52
         [PR['PR_COMMENT'], /^\/\*[^*]*\*+(?:[^\/*][^*]*\*+)*\//],
53
         // Escaping text spans
54
         [PR['PR_COMMENT'], /^(?:<!--|-->)/],
55
         // A number possibly containing a suffix.
56
         [PR['PR_LITERAL'], /^(?:\d+|\d*\.\d+)(?:%|[a-z]+)?/i],
57
         // A hex color
58
         [PR['PR_LITERAL'], /^#(?:[0-9a-f]{3}){1,2}/i],
59
         // An identifier
60
         [PR['PR_PLAIN'],
61
          /^-?(?:[_a-z]|(?:\\[\da-f]+ ?))(?:[_a-z\d\-]|\\(?:\\[\da-f]+ ?))*/i],
62
         // A run of punctuation
63
         [PR['PR_PUNCTUATION'], /^[^\s\w\'\"]+/]
64
        ]),
65
    ['css']);
66
PR['registerLangHandler'](
67
    PR['createSimpleLexer']([],
68
        [
69
         [PR['PR_KEYWORD'],
70
          /^-?(?:[_a-z]|(?:\\[\da-f]+ ?))(?:[_a-z\d\-]|\\(?:\\[\da-f]+ ?))*/i]
71
        ]),
72
    ['css-kw']);
73
PR['registerLangHandler'](
74
    PR['createSimpleLexer']([],
75
        [
76
         [PR['PR_STRING'], /^[^\)\"\']+/]
77
        ]),
78
    ['css-str']);