gitlab-rouge 1.9.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (185) hide show
  1. checksums.yaml +7 -0
  2. data/Gemfile +23 -0
  3. data/LICENSE +186 -0
  4. data/bin/rougify +16 -0
  5. data/gitlab-rouge.gemspec +17 -0
  6. data/lib/rouge.rb +57 -0
  7. data/lib/rouge/cli.rb +363 -0
  8. data/lib/rouge/demos/apache +21 -0
  9. data/lib/rouge/demos/applescript +2 -0
  10. data/lib/rouge/demos/c +8 -0
  11. data/lib/rouge/demos/clojure +5 -0
  12. data/lib/rouge/demos/coffeescript +5 -0
  13. data/lib/rouge/demos/common_lisp +1 -0
  14. data/lib/rouge/demos/conf +4 -0
  15. data/lib/rouge/demos/cpp +8 -0
  16. data/lib/rouge/demos/csharp +5 -0
  17. data/lib/rouge/demos/css +4 -0
  18. data/lib/rouge/demos/dart +6 -0
  19. data/lib/rouge/demos/diff +7 -0
  20. data/lib/rouge/demos/elixir +1 -0
  21. data/lib/rouge/demos/erb +1 -0
  22. data/lib/rouge/demos/erlang +7 -0
  23. data/lib/rouge/demos/factor +5 -0
  24. data/lib/rouge/demos/gherkin +17 -0
  25. data/lib/rouge/demos/glsl +14 -0
  26. data/lib/rouge/demos/go +7 -0
  27. data/lib/rouge/demos/groovy +9 -0
  28. data/lib/rouge/demos/haml +5 -0
  29. data/lib/rouge/demos/handlebars +7 -0
  30. data/lib/rouge/demos/haskell +6 -0
  31. data/lib/rouge/demos/html +8 -0
  32. data/lib/rouge/demos/http +14 -0
  33. data/lib/rouge/demos/ini +4 -0
  34. data/lib/rouge/demos/io +11 -0
  35. data/lib/rouge/demos/java +5 -0
  36. data/lib/rouge/demos/javascript +1 -0
  37. data/lib/rouge/demos/json +1 -0
  38. data/lib/rouge/demos/json-doc +1 -0
  39. data/lib/rouge/demos/liquid +11 -0
  40. data/lib/rouge/demos/literate_coffeescript +3 -0
  41. data/lib/rouge/demos/literate_haskell +7 -0
  42. data/lib/rouge/demos/llvm +20 -0
  43. data/lib/rouge/demos/lua +12 -0
  44. data/lib/rouge/demos/make +6 -0
  45. data/lib/rouge/demos/markdown +4 -0
  46. data/lib/rouge/demos/matlab +6 -0
  47. data/lib/rouge/demos/moonscript +16 -0
  48. data/lib/rouge/demos/nginx +5 -0
  49. data/lib/rouge/demos/nim +27 -0
  50. data/lib/rouge/demos/objective_c +14 -0
  51. data/lib/rouge/demos/ocaml +12 -0
  52. data/lib/rouge/demos/perl +5 -0
  53. data/lib/rouge/demos/php +3 -0
  54. data/lib/rouge/demos/plaintext +1 -0
  55. data/lib/rouge/demos/powershell +49 -0
  56. data/lib/rouge/demos/prolog +9 -0
  57. data/lib/rouge/demos/properties +7 -0
  58. data/lib/rouge/demos/puppet +6 -0
  59. data/lib/rouge/demos/python +6 -0
  60. data/lib/rouge/demos/qml +9 -0
  61. data/lib/rouge/demos/r +8 -0
  62. data/lib/rouge/demos/racket +24 -0
  63. data/lib/rouge/demos/ruby +9 -0
  64. data/lib/rouge/demos/rust +12 -0
  65. data/lib/rouge/demos/sass +3 -0
  66. data/lib/rouge/demos/scala +3 -0
  67. data/lib/rouge/demos/scheme +4 -0
  68. data/lib/rouge/demos/scss +5 -0
  69. data/lib/rouge/demos/sed +4 -0
  70. data/lib/rouge/demos/shell +2 -0
  71. data/lib/rouge/demos/slim +17 -0
  72. data/lib/rouge/demos/smalltalk +6 -0
  73. data/lib/rouge/demos/sml +4 -0
  74. data/lib/rouge/demos/sql +1 -0
  75. data/lib/rouge/demos/swift +5 -0
  76. data/lib/rouge/demos/tcl +1 -0
  77. data/lib/rouge/demos/tex +1 -0
  78. data/lib/rouge/demos/toml +9 -0
  79. data/lib/rouge/demos/tulip +14 -0
  80. data/lib/rouge/demos/vb +4 -0
  81. data/lib/rouge/demos/viml +5 -0
  82. data/lib/rouge/demos/xml +2 -0
  83. data/lib/rouge/demos/yaml +4 -0
  84. data/lib/rouge/formatter.rb +50 -0
  85. data/lib/rouge/formatters/html.rb +117 -0
  86. data/lib/rouge/formatters/null.rb +19 -0
  87. data/lib/rouge/formatters/terminal256.rb +176 -0
  88. data/lib/rouge/lexer.rb +443 -0
  89. data/lib/rouge/lexers/apache.rb +68 -0
  90. data/lib/rouge/lexers/apache/keywords.yml +453 -0
  91. data/lib/rouge/lexers/apple_script.rb +367 -0
  92. data/lib/rouge/lexers/c.rb +212 -0
  93. data/lib/rouge/lexers/clojure.rb +112 -0
  94. data/lib/rouge/lexers/coffeescript.rb +174 -0
  95. data/lib/rouge/lexers/common_lisp.rb +345 -0
  96. data/lib/rouge/lexers/conf.rb +24 -0
  97. data/lib/rouge/lexers/cpp.rb +66 -0
  98. data/lib/rouge/lexers/csharp.rb +88 -0
  99. data/lib/rouge/lexers/css.rb +271 -0
  100. data/lib/rouge/lexers/dart.rb +104 -0
  101. data/lib/rouge/lexers/diff.rb +31 -0
  102. data/lib/rouge/lexers/elixir.rb +108 -0
  103. data/lib/rouge/lexers/erb.rb +56 -0
  104. data/lib/rouge/lexers/erlang.rb +118 -0
  105. data/lib/rouge/lexers/factor.rb +302 -0
  106. data/lib/rouge/lexers/gherkin.rb +137 -0
  107. data/lib/rouge/lexers/gherkin/keywords.rb +14 -0
  108. data/lib/rouge/lexers/glsl.rb +135 -0
  109. data/lib/rouge/lexers/go.rb +178 -0
  110. data/lib/rouge/lexers/groovy.rb +104 -0
  111. data/lib/rouge/lexers/haml.rb +228 -0
  112. data/lib/rouge/lexers/handlebars.rb +79 -0
  113. data/lib/rouge/lexers/haskell.rb +183 -0
  114. data/lib/rouge/lexers/html.rb +94 -0
  115. data/lib/rouge/lexers/http.rb +80 -0
  116. data/lib/rouge/lexers/ini.rb +57 -0
  117. data/lib/rouge/lexers/io.rb +68 -0
  118. data/lib/rouge/lexers/java.rb +76 -0
  119. data/lib/rouge/lexers/javascript.rb +297 -0
  120. data/lib/rouge/lexers/liquid.rb +287 -0
  121. data/lib/rouge/lexers/literate_coffeescript.rb +33 -0
  122. data/lib/rouge/lexers/literate_haskell.rb +36 -0
  123. data/lib/rouge/lexers/llvm.rb +84 -0
  124. data/lib/rouge/lexers/lua.rb +122 -0
  125. data/lib/rouge/lexers/lua/builtins.rb +22 -0
  126. data/lib/rouge/lexers/make.rb +116 -0
  127. data/lib/rouge/lexers/markdown.rb +154 -0
  128. data/lib/rouge/lexers/matlab.rb +74 -0
  129. data/lib/rouge/lexers/matlab/builtins.rb +11 -0
  130. data/lib/rouge/lexers/moonscript.rb +110 -0
  131. data/lib/rouge/lexers/nginx.rb +71 -0
  132. data/lib/rouge/lexers/nim.rb +152 -0
  133. data/lib/rouge/lexers/objective_c.rb +197 -0
  134. data/lib/rouge/lexers/ocaml.rb +111 -0
  135. data/lib/rouge/lexers/perl.rb +197 -0
  136. data/lib/rouge/lexers/php.rb +173 -0
  137. data/lib/rouge/lexers/php/builtins.rb +204 -0
  138. data/lib/rouge/lexers/plain_text.rb +25 -0
  139. data/lib/rouge/lexers/powershell.rb +96 -0
  140. data/lib/rouge/lexers/prolog.rb +64 -0
  141. data/lib/rouge/lexers/properties.rb +55 -0
  142. data/lib/rouge/lexers/puppet.rb +128 -0
  143. data/lib/rouge/lexers/python.rb +228 -0
  144. data/lib/rouge/lexers/qml.rb +72 -0
  145. data/lib/rouge/lexers/r.rb +56 -0
  146. data/lib/rouge/lexers/racket.rb +542 -0
  147. data/lib/rouge/lexers/ruby.rb +415 -0
  148. data/lib/rouge/lexers/rust.rb +191 -0
  149. data/lib/rouge/lexers/sass.rb +74 -0
  150. data/lib/rouge/lexers/sass/common.rb +180 -0
  151. data/lib/rouge/lexers/scala.rb +142 -0
  152. data/lib/rouge/lexers/scheme.rb +112 -0
  153. data/lib/rouge/lexers/scss.rb +34 -0
  154. data/lib/rouge/lexers/sed.rb +170 -0
  155. data/lib/rouge/lexers/shell.rb +152 -0
  156. data/lib/rouge/lexers/slim.rb +228 -0
  157. data/lib/rouge/lexers/smalltalk.rb +116 -0
  158. data/lib/rouge/lexers/sml.rb +347 -0
  159. data/lib/rouge/lexers/sql.rb +140 -0
  160. data/lib/rouge/lexers/swift.rb +144 -0
  161. data/lib/rouge/lexers/tcl.rb +192 -0
  162. data/lib/rouge/lexers/tex.rb +72 -0
  163. data/lib/rouge/lexers/toml.rb +71 -0
  164. data/lib/rouge/lexers/tulip.rb +75 -0
  165. data/lib/rouge/lexers/vb.rb +164 -0
  166. data/lib/rouge/lexers/viml.rb +101 -0
  167. data/lib/rouge/lexers/viml/keywords.rb +12 -0
  168. data/lib/rouge/lexers/xml.rb +59 -0
  169. data/lib/rouge/lexers/yaml.rb +364 -0
  170. data/lib/rouge/plugins/redcarpet.rb +30 -0
  171. data/lib/rouge/regex_lexer.rb +439 -0
  172. data/lib/rouge/template_lexer.rb +22 -0
  173. data/lib/rouge/text_analyzer.rb +48 -0
  174. data/lib/rouge/theme.rb +195 -0
  175. data/lib/rouge/themes/base16.rb +130 -0
  176. data/lib/rouge/themes/colorful.rb +67 -0
  177. data/lib/rouge/themes/github.rb +71 -0
  178. data/lib/rouge/themes/molokai.rb +82 -0
  179. data/lib/rouge/themes/monokai.rb +92 -0
  180. data/lib/rouge/themes/monokai_sublime.rb +90 -0
  181. data/lib/rouge/themes/thankful_eyes.rb +71 -0
  182. data/lib/rouge/token.rb +182 -0
  183. data/lib/rouge/util.rb +101 -0
  184. data/lib/rouge/version.rb +7 -0
  185. metadata +231 -0
@@ -0,0 +1,24 @@
1
+ # -*- coding: utf-8 -*- #
2
+
3
+ module Rouge
4
+ module Lexers
5
+ class Conf < RegexLexer
6
+ tag 'conf'
7
+ aliases 'config', 'configuration'
8
+
9
+ title "Config File"
10
+ desc 'A generic lexer for configuration files'
11
+ filenames '*.conf', '*.config'
12
+
13
+ # short and sweet
14
+ state :root do
15
+ rule /#.*?\n/, Comment
16
+ rule /".*?"/, Str::Double
17
+ rule /'.*?'/, Str::Single
18
+ rule /[a-z]\w*/i, Name
19
+ rule /\d+/, Num
20
+ rule /[^\d\w#"']+/, Text
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,66 @@
1
+ # -*- coding: utf-8 -*- #
2
+
3
+ module Rouge
4
+ module Lexers
5
+ load_const :C, 'c.rb'
6
+
7
+ class Cpp < C
8
+ title "C++"
9
+ desc "The C++ programming language"
10
+
11
+ tag 'cpp'
12
+ aliases 'c++'
13
+ # the many varied filenames of c++ source files...
14
+ filenames '*.cpp', '*.hpp',
15
+ '*.c++', '*.h++',
16
+ '*.cc', '*.hh',
17
+ '*.cxx', '*.hxx',
18
+ '*.pde', '*.ino'
19
+ mimetypes 'text/x-c++hdr', 'text/x-c++src'
20
+
21
+ def self.keywords
22
+ @keywords ||= super + Set.new(%w(
23
+ asm catch const_cast delete dynamic_cast explicit export
24
+ friend mutable namespace new operator private protected public
25
+ reinterpret_cast restrict static_cast template this throw
26
+ throws typeid typename using virtual
27
+ ))
28
+ end
29
+
30
+ def self.reserved
31
+ @reserved ||= super + Set.new(%w(
32
+ __virtual_inheritance __uuidof __super __single_inheritance
33
+ __multiple_inheritance __interface __event
34
+ ))
35
+ end
36
+
37
+ id = /[a-zA-Z_][a-zA-Z0-9]*/
38
+
39
+ prepend :root do
40
+ # Offload C++ extensions, http://offload.codeplay.com/
41
+ rule /(?:__offload|__blockingoffload|__outer)\b/, Keyword::Pseudo
42
+ end
43
+
44
+ # digits with optional inner quotes
45
+ # see www.open-std.org/jtc1/sc22/wg21/docs/papers/2013/n3781.pdf
46
+ dq = /\d('?\d)*/
47
+
48
+ prepend :statements do
49
+ rule /class\b/, Keyword, :classname
50
+ rule %r((#{dq}[.]#{dq}?|[.]#{dq})(e[+-]?#{dq}[lu]*)?)i, Num::Float
51
+ rule %r(#{dq}e[+-]?#{dq}[lu]*)i, Num::Float
52
+ rule /0x\h('?\h)*[lu]*/i, Num::Hex
53
+ rule /0[0-7]('?[0-7])*[lu]*/i, Num::Oct
54
+ rule /#{dq}[lu]*/i, Num::Integer
55
+ end
56
+
57
+ state :classname do
58
+ rule id, Name::Class, :pop!
59
+
60
+ # template specification
61
+ rule /\s*(?=>)/m, Text, :pop!
62
+ mixin :whitespace
63
+ end
64
+ end
65
+ end
66
+ end
@@ -0,0 +1,88 @@
1
+ # -*- coding: utf-8 -*- #
2
+
3
+ module Rouge
4
+ module Lexers
5
+ class CSharp < RegexLexer
6
+ tag 'csharp'
7
+ aliases 'c#', 'cs'
8
+ filenames '*.cs'
9
+ mimetypes 'text/x-csharp'
10
+
11
+ title "C#"
12
+ desc 'a multi-paradigm language targeting .NET'
13
+
14
+ # TODO: support more of unicode
15
+ id = /@?[_a-z]\w*/i
16
+
17
+ keywords = %w(
18
+ abstract alias as base break case catch checked const continue
19
+ default delegate do else enum event explicit extern false
20
+ finally fixed for foreach global goto if implicit in interface
21
+ internal is lock new null operator out override params private
22
+ protected public readonly ref return sealed sizeof stackalloc
23
+ static switch this throw true try typeof unchecked unsafe
24
+ virtual void while get set new partial yield add remove value
25
+ )
26
+
27
+ keywords_type = %w(
28
+ bool byte char decimal double float int long object sbyte
29
+ short string uint ulong ushort
30
+ )
31
+
32
+ cpp_keywords = %w(
33
+ if endif else elif define undef line error warning region
34
+ endregion pragma
35
+ )
36
+
37
+ state :whitespace do
38
+ rule /\s+/m, Text
39
+ rule %r(//.*?\n), Comment::Single
40
+ rule %r(/[*].*?[*]/)m, Comment::Multiline
41
+ end
42
+
43
+ state :root do
44
+ mixin :whitespace
45
+
46
+ rule /^\s*\[.*?\]/, Name::Attribute
47
+ # rule /[$]\s*"/, Str, :splice_string
48
+ # rule /[$]\s*<#/, Str, :splice_recstring
49
+ # rule /<#/, Str, :recstring
50
+
51
+ rule /(<\[)\s*(#{id}:)?/, Keyword
52
+ rule /\]>/, Keyword
53
+
54
+ rule /[~!%^&*()+=|\[\]{}:;,.<>\/?-]/, Punctuation
55
+ rule /@"(\\.|.)*?"/, Str
56
+ rule /"(\\.|.)*?["\n]/, Str
57
+ rule /'(\\.|.)'/, Str::Char
58
+ rule /0x[0-9a-f]+[lu]?/i, Num
59
+ rule %r(
60
+ [0-9]
61
+ ([.][0-9]*)? # decimal
62
+ (e[+-][0-9]+)? # exponent
63
+ [fldu]? # type
64
+ )ix, Num
65
+ rule /^#[ \t]*(#{cpp_keywords.join('|')})\b.*?\n/,
66
+ Comment::Preproc
67
+ rule /\b(#{keywords.join('|')})\b/, Keyword
68
+ rule /\b(#{keywords_type.join('|')})\b/, Keyword::Type
69
+ rule /class|struct/, Keyword, :class
70
+ rule /namespace|using/, Keyword, :namespace
71
+ rule /#{id}(?=\s*[(])/, Name::Function
72
+ rule id, Name
73
+ end
74
+
75
+ state :class do
76
+ mixin :whitespace
77
+ rule id, Name::Class, :pop!
78
+ end
79
+
80
+ state :namespace do
81
+ mixin :whitespace
82
+ rule /(?=[(])/, Text, :pop!
83
+ rule /(#{id}|[.])+/, Name::Namespace, :pop!
84
+ end
85
+
86
+ end
87
+ end
88
+ end
@@ -0,0 +1,271 @@
1
+ # -*- coding: utf-8 -*- #
2
+
3
+ module Rouge
4
+ module Lexers
5
+ class CSS < RegexLexer
6
+ title "CSS"
7
+ desc "Cascading Style Sheets, used to style web pages"
8
+
9
+ tag 'css'
10
+ filenames '*.css'
11
+ mimetypes 'text/css'
12
+
13
+ identifier = /[a-zA-Z0-9_-]+/
14
+ number = /-?(?:[0-9]+(\.[0-9]+)?|\.[0-9]+)/
15
+
16
+ def self.attributes
17
+ @attributes ||= Set.new %w(
18
+ align-content align-items align-self alignment-adjust
19
+ alignment-baseline all anchor-point animation
20
+ animation-delay animation-direction animation-duration
21
+ animation-fill-mode animation-iteration-count animation-name
22
+ animation-play-state animation-timing-function appearance
23
+ azimuth backface-visibility background background-attachment
24
+ background-clip background-color background-image
25
+ background-origin background-position background-repeat
26
+ background-size baseline-shift binding bleed bookmark-label
27
+ bookmark-level bookmark-state bookmark-target border
28
+ border-bottom border-bottom-color border-bottom-left-radius
29
+ border-bottom-right-radius border-bottom-style
30
+ border-bottom-width border-collapse border-color
31
+ border-image border-image-outset border-image-repeat
32
+ border-image-slice border-image-source border-image-width
33
+ border-left border-left-color border-left-style
34
+ border-left-width border-radius border-right
35
+ border-right-color border-right-style border-right-width
36
+ border-spacing border-style border-top border-top-color
37
+ border-top-left-radius border-top-right-radius
38
+ border-top-style border-top-width border-width bottom
39
+ box-align box-decoration-break box-direction box-flex
40
+ box-flex-group box-lines box-ordinal-group box-orient
41
+ box-pack box-shadow box-sizing break-after break-before
42
+ break-inside caption-side clear clip clip-path
43
+ clip-rule color color-profile columns column-count
44
+ column-fill column-gap column-rule column-rule-color
45
+ column-rule-style column-rule-width column-span
46
+ column-width content counter-increment counter-reset
47
+ crop cue cue-after cue-before cursor direction display
48
+ dominant-baseline drop-initial-after-adjust
49
+ drop-initial-after-align drop-initial-before-adjust
50
+ drop-initial-before-align drop-initial-size
51
+ drop-initial-value elevation empty-cells filter fit
52
+ fit-position flex flex-basis flex-direction flex-flow
53
+ flex-grow flex-shrink flex-wrap float float-offset
54
+ font font-family font-feature-settings
55
+ font-kerning font-language-override font-size
56
+ font-size-adjust font-stretch font-style font-synthesis
57
+ font-variant font-variant-alternates font-variant-caps
58
+ font-variant-east-asian font-variant-ligatures
59
+ font-variant-numeric font-variant-position font-weight
60
+ grid-cell grid-column grid-column-align grid-column-sizing
61
+ grid-column-span grid-columns grid-flow grid-row
62
+ grid-row-align grid-row-sizing grid-row-span
63
+ grid-rows grid-template hanging-punctuation height
64
+ hyphenate-after hyphenate-before hyphenate-character
65
+ hyphenate-lines hyphenate-resource hyphens icon
66
+ image-orientation image-rendering image-resolution
67
+ ime-mode inline-box-align justify-content
68
+ left letter-spacing line-break line-height
69
+ line-stacking line-stacking-ruby line-stacking-shift
70
+ line-stacking-strategy list-style list-style-image
71
+ list-style-position list-style-type margin
72
+ margin-bottom margin-left margin-right margin-top
73
+ mark marker-offset marks mark-after mark-before
74
+ marquee-direction marquee-loop marquee-play-count
75
+ marquee-speed marquee-style mask max-height max-width
76
+ min-height min-width move-to nav-down
77
+ nav-index nav-left nav-right nav-up object-fit
78
+ object-position opacity order orphans outline
79
+ outline-color outline-offset outline-style
80
+ outline-width overflow overflow-style overflow-wrap
81
+ overflow-x overflow-y padding padding-bottom
82
+ padding-left padding-right padding-top
83
+ page page-break-after page-break-before
84
+ page-break-inside page-policy pause pause-after
85
+ pause-before perspective perspective-origin
86
+ phonemes pitch pitch-range play-during pointer-events
87
+ position presentation-level punctuation-trim quotes
88
+ rendering-intent resize rest rest-after rest-before
89
+ richness right rotation rotation-point ruby-align
90
+ ruby-overhang ruby-position ruby-span size speak
91
+ speak-as speak-header speak-numeral speak-punctuation
92
+ speech-rate src stress string-set
93
+ tab-size table-layout target target-name
94
+ target-new target-position text-align
95
+ text-align-last text-combine-horizontal
96
+ text-decoration text-decoration-color
97
+ text-decoration-line text-decoration-skip
98
+ text-decoration-style text-emphasis
99
+ text-emphasis-color text-emphasis-position
100
+ text-emphasis-style text-height text-indent
101
+ text-justify text-orientation text-outline
102
+ text-overflow text-rendering text-shadow
103
+ text-space-collapse text-transform
104
+ text-underline-position text-wrap top
105
+ transform transform-origin transform-style
106
+ transition transition-delay transition-duration
107
+ transition-property transition-timing-function
108
+ unicode-bidi vertical-align
109
+ visibility voice-balance voice-duration
110
+ voice-family voice-pitch voice-pitch-range
111
+ voice-range voice-rate voice-stress voice-volume
112
+ volume white-space widows width word-break
113
+ word-spacing word-wrap writing-mode z-index
114
+ )
115
+ end
116
+
117
+ def self.builtins
118
+ @builtins ||= Set.new %w(
119
+ above absolute always armenian aural auto avoid left bottom
120
+ baseline behind below bidi-override blink block bold bolder
121
+ both bottom capitalize center center-left center-right circle
122
+ cjk-ideographic close-quote collapse condensed continuous crop
123
+ cross crosshair cursive dashed decimal decimal-leading-zero
124
+ default digits disc dotted double e-resize embed expanded
125
+ extra-condensed extra-expanded fantasy far-left far-right fast
126
+ faster fixed georgian groove hebrew help hidden hide high higher
127
+ hiragana hiragana-iroha icon inherit inline inline-table inset
128
+ inside invert italic justify katakana katakana-iroha landscape
129
+ large larger left left-side leftwards level lighter line-through
130
+ list-item loud low lower lower-alpha lower-greek lower-roman
131
+ lowercase ltr medium message-box middle mix monospace n-resize
132
+ narrower ne-resize no-close-quote no-open-quote no-repeat none
133
+ normal nowrap nw-resize oblique once open-quote outset outside
134
+ overline pointer portrait px relative repeat repeat-x repeat-y
135
+ rgb ridge right right-side rightwards s-resize sans-serif scroll
136
+ se-resize semi-condensed semi-expanded separate serif show
137
+ silent slow slower small-caps small-caption smaller soft solid
138
+ spell-out square static status-bar super sw-resize table-caption
139
+ table-cell table-column table-column-group table-footer-group
140
+ table-header-group table-row table-row-group text text-bottom
141
+ text-top thick thin top transparent ultra-condensed
142
+ ultra-expanded underline upper-alpha upper-latin upper-roman
143
+ uppercase url visible w-resize wait wider x-fast x-high x-large
144
+ x-loud x-low x-small x-soft xx-large xx-small yes
145
+ )
146
+ end
147
+
148
+ def self.constants
149
+ @constants ||= Set.new %w(
150
+ indigo gold firebrick indianred yellow darkolivegreen
151
+ darkseagreen mediumvioletred mediumorchid chartreuse
152
+ mediumslateblue black springgreen crimson lightsalmon brown
153
+ turquoise olivedrab cyan silver skyblue gray darkturquoise
154
+ goldenrod darkgreen darkviolet darkgray lightpink teal
155
+ darkmagenta lightgoldenrodyellow lavender yellowgreen thistle
156
+ violet navy orchid blue ghostwhite honeydew cornflowerblue
157
+ darkblue darkkhaki mediumpurple cornsilk red bisque slategray
158
+ darkcyan khaki wheat deepskyblue darkred steelblue aliceblue
159
+ gainsboro mediumturquoise floralwhite coral purple lightgrey
160
+ lightcyan darksalmon beige azure lightsteelblue oldlace
161
+ greenyellow royalblue lightseagreen mistyrose sienna lightcoral
162
+ orangered navajowhite lime palegreen burlywood seashell
163
+ mediumspringgreen fuchsia papayawhip blanchedalmond peru
164
+ aquamarine white darkslategray ivory dodgerblue lemonchiffon
165
+ chocolate orange forestgreen slateblue olive mintcream
166
+ antiquewhite darkorange cadetblue moccasin limegreen saddlebrown
167
+ darkslateblue lightskyblue deeppink plum aqua darkgoldenrod
168
+ maroon sandybrown magenta tan rosybrown pink lightblue
169
+ palevioletred mediumseagreen dimgray powderblue seagreen snow
170
+ mediumblue midnightblue paleturquoise palegoldenrod whitesmoke
171
+ darkorchid salmon lightslategray lawngreen lightgreen tomato
172
+ hotpink lightyellow lavenderblush linen mediumaquamarine green
173
+ blueviolet peachpuff
174
+ )
175
+ end
176
+
177
+ # source: http://www.w3.org/TR/CSS21/syndata.html#vendor-keyword-history
178
+ def self.vendor_prefixes
179
+ @vendor_prefixes ||= Set.new %w(
180
+ -ah- -atsc- -hp- -khtml- -moz- -ms- -o- -rim- -ro- -tc- -wap-
181
+ -webkit- -xv- mso- prince-
182
+ )
183
+ end
184
+
185
+ state :root do
186
+ mixin :basics
187
+ rule /{/, Punctuation, :stanza
188
+ rule /:[:]?#{identifier}/, Name::Decorator
189
+ rule /\.#{identifier}/, Name::Class
190
+ rule /##{identifier}/, Name::Function
191
+ rule /@#{identifier}/, Keyword, :at_rule
192
+ rule identifier, Name::Tag
193
+ rule %r([~^*!%&\[\]()<>|+=@:;,./?-]), Operator
194
+ end
195
+
196
+ state :value do
197
+ mixin :basics
198
+ rule /url\(.*?\)/, Str::Other
199
+ rule /#[0-9a-f]{1,6}/i, Num # colors
200
+ rule /#{number}(?:%|(?:em|px|pt|pc|in|mm|cm|ex|rem|ch|vw|vh|vmin|vmax|dpi|dpcm|dppx|deg|grad|rad|turn|s|ms|Hz|kHz)\b)?/, Num
201
+ rule /[\[\]():\/.,]/, Punctuation
202
+ rule /"(\\\\|\\"|[^"])*"/, Str::Single
203
+ rule /'(\\\\|\\'|[^'])*'/, Str::Double
204
+ rule(identifier) do |m|
205
+ if self.class.constants.include? m[0]
206
+ token Name::Constant
207
+ elsif self.class.builtins.include? m[0]
208
+ token Name::Builtin
209
+ else
210
+ token Name
211
+ end
212
+ end
213
+ end
214
+
215
+ state :at_rule do
216
+ rule /{(?=\s*#{identifier}\s*:)/m, Punctuation, :at_stanza
217
+ rule /{/, Punctuation, :at_body
218
+ rule /;/, Punctuation, :pop!
219
+ mixin :value
220
+ end
221
+
222
+ state :at_body do
223
+ mixin :at_content
224
+ mixin :root
225
+ end
226
+
227
+ state :at_stanza do
228
+ mixin :at_content
229
+ mixin :stanza
230
+ end
231
+
232
+ state :at_content do
233
+ rule /}/ do
234
+ token Punctuation
235
+ pop! 2
236
+ end
237
+ end
238
+
239
+ state :basics do
240
+ rule /\s+/m, Text
241
+ rule %r(/\*(?:.*?)\*/)m, Comment
242
+ end
243
+
244
+ state :stanza do
245
+ mixin :basics
246
+ rule /}/, Punctuation, :pop!
247
+ rule /(#{identifier})(\s*)(:)/m do |m|
248
+ name_tok = if self.class.attributes.include? m[1]
249
+ Name::Label
250
+ elsif self.class.vendor_prefixes.any? { |p| m[1].start_with?(p) }
251
+ Name::Label
252
+ else
253
+ Name::Property
254
+ end
255
+
256
+ groups name_tok, Text, Punctuation
257
+
258
+ push :stanza_value
259
+ end
260
+ end
261
+
262
+ state :stanza_value do
263
+ rule /;/, Punctuation, :pop!
264
+ rule(/(?=})/) { pop! }
265
+ rule /!important\b/, Comment::Preproc
266
+ rule /^@.*?$/, Comment::Preproc
267
+ mixin :value
268
+ end
269
+ end
270
+ end
271
+ end