rouge 3.4.1 → 3.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (151) hide show
  1. checksums.yaml +4 -4
  2. data/lib/rouge.rb +3 -0
  3. data/lib/rouge/cli.rb +19 -2
  4. data/lib/rouge/demos/bpf +7 -0
  5. data/lib/rouge/demos/brainfuck +5 -0
  6. data/lib/rouge/demos/magik +6 -0
  7. data/lib/rouge/formatter.rb +2 -2
  8. data/lib/rouge/formatters/tex.rb +90 -0
  9. data/lib/rouge/guessers/glob_mapping.rb +1 -1
  10. data/lib/rouge/lexer.rb +22 -10
  11. data/lib/rouge/lexers/abap.rb +11 -11
  12. data/lib/rouge/lexers/actionscript.rb +34 -34
  13. data/lib/rouge/lexers/apache.rb +8 -8
  14. data/lib/rouge/lexers/apple_script.rb +15 -14
  15. data/lib/rouge/lexers/awk.rb +25 -25
  16. data/lib/rouge/lexers/biml.rb +4 -4
  17. data/lib/rouge/lexers/bpf.rb +104 -0
  18. data/lib/rouge/lexers/brainfuck.rb +53 -0
  19. data/lib/rouge/lexers/bsl.rb +12 -12
  20. data/lib/rouge/lexers/c.rb +30 -30
  21. data/lib/rouge/lexers/ceylon.rb +1 -29
  22. data/lib/rouge/lexers/cfscript.rb +26 -26
  23. data/lib/rouge/lexers/clojure.rb +14 -14
  24. data/lib/rouge/lexers/cmake.rb +14 -14
  25. data/lib/rouge/lexers/coffeescript.rb +30 -30
  26. data/lib/rouge/lexers/common_lisp.rb +36 -36
  27. data/lib/rouge/lexers/conf.rb +6 -6
  28. data/lib/rouge/lexers/coq.rb +18 -18
  29. data/lib/rouge/lexers/cpp.rb +8 -8
  30. data/lib/rouge/lexers/crystal.rb +70 -70
  31. data/lib/rouge/lexers/csharp.rb +28 -28
  32. data/lib/rouge/lexers/css.rb +23 -23
  33. data/lib/rouge/lexers/d.rb +59 -59
  34. data/lib/rouge/lexers/dart.rb +33 -33
  35. data/lib/rouge/lexers/digdag.rb +1 -1
  36. data/lib/rouge/lexers/docker.rb +10 -10
  37. data/lib/rouge/lexers/dot.rb +16 -16
  38. data/lib/rouge/lexers/eiffel.rb +20 -20
  39. data/lib/rouge/lexers/elixir.rb +29 -28
  40. data/lib/rouge/lexers/elm.rb +29 -29
  41. data/lib/rouge/lexers/erb.rb +4 -4
  42. data/lib/rouge/lexers/factor.rb +40 -40
  43. data/lib/rouge/lexers/fortran.rb +32 -32
  44. data/lib/rouge/lexers/fsharp.rb +26 -26
  45. data/lib/rouge/lexers/gherkin.rb +13 -13
  46. data/lib/rouge/lexers/glsl.rb +0 -4
  47. data/lib/rouge/lexers/go.rb +1 -1
  48. data/lib/rouge/lexers/graphql.rb +62 -62
  49. data/lib/rouge/lexers/groovy.rb +23 -25
  50. data/lib/rouge/lexers/hack.rb +1 -1
  51. data/lib/rouge/lexers/haml.rb +25 -29
  52. data/lib/rouge/lexers/handlebars.rb +18 -18
  53. data/lib/rouge/lexers/haskell.rb +66 -65
  54. data/lib/rouge/lexers/hcl.rb +25 -25
  55. data/lib/rouge/lexers/html.rb +31 -31
  56. data/lib/rouge/lexers/http.rb +4 -4
  57. data/lib/rouge/lexers/hylang.rb +14 -14
  58. data/lib/rouge/lexers/idlang.rb +32 -32
  59. data/lib/rouge/lexers/igorpro.rb +30 -30
  60. data/lib/rouge/lexers/ini.rb +12 -12
  61. data/lib/rouge/lexers/io.rb +7 -7
  62. data/lib/rouge/lexers/irb.rb +5 -5
  63. data/lib/rouge/lexers/java.rb +24 -24
  64. data/lib/rouge/lexers/javascript.rb +51 -51
  65. data/lib/rouge/lexers/jinja.rb +22 -22
  66. data/lib/rouge/lexers/json.rb +11 -10
  67. data/lib/rouge/lexers/json_doc.rb +2 -2
  68. data/lib/rouge/lexers/jsonnet.rb +18 -18
  69. data/lib/rouge/lexers/jsp.rb +28 -28
  70. data/lib/rouge/lexers/jsx.rb +16 -16
  71. data/lib/rouge/lexers/julia.rb +44 -44
  72. data/lib/rouge/lexers/kotlin.rb +3 -3
  73. data/lib/rouge/lexers/lasso.rb +50 -50
  74. data/lib/rouge/lexers/liquid.rb +53 -53
  75. data/lib/rouge/lexers/literate_coffeescript.rb +2 -2
  76. data/lib/rouge/lexers/literate_haskell.rb +5 -5
  77. data/lib/rouge/lexers/llvm.rb +23 -16
  78. data/lib/rouge/lexers/lua.rb +3 -3
  79. data/lib/rouge/lexers/m68k.rb +18 -19
  80. data/lib/rouge/lexers/magik.rb +126 -0
  81. data/lib/rouge/lexers/make.rb +22 -28
  82. data/lib/rouge/lexers/markdown.rb +37 -37
  83. data/lib/rouge/lexers/mathematica.rb +11 -11
  84. data/lib/rouge/lexers/matlab.rb +20 -20
  85. data/lib/rouge/lexers/moonscript.rb +3 -3
  86. data/lib/rouge/lexers/mosel.rb +17 -17
  87. data/lib/rouge/lexers/mxml.rb +18 -18
  88. data/lib/rouge/lexers/nasm.rb +24 -25
  89. data/lib/rouge/lexers/nginx.rb +14 -14
  90. data/lib/rouge/lexers/nim.rb +1 -1
  91. data/lib/rouge/lexers/nix.rb +42 -42
  92. data/lib/rouge/lexers/objective_c.rb +38 -38
  93. data/lib/rouge/lexers/ocaml.rb +29 -29
  94. data/lib/rouge/lexers/pascal.rb +4 -4
  95. data/lib/rouge/lexers/perl.rb +68 -68
  96. data/lib/rouge/lexers/php.rb +38 -38
  97. data/lib/rouge/lexers/plist.rb +14 -14
  98. data/lib/rouge/lexers/pony.rb +19 -19
  99. data/lib/rouge/lexers/powershell.rb +25 -25
  100. data/lib/rouge/lexers/praat.rb +75 -75
  101. data/lib/rouge/lexers/prolog.rb +26 -20
  102. data/lib/rouge/lexers/prometheus.rb +30 -30
  103. data/lib/rouge/lexers/properties.rb +12 -12
  104. data/lib/rouge/lexers/protobuf.rb +22 -22
  105. data/lib/rouge/lexers/puppet.rb +31 -31
  106. data/lib/rouge/lexers/python.rb +52 -52
  107. data/lib/rouge/lexers/q.rb +12 -12
  108. data/lib/rouge/lexers/qml.rb +12 -12
  109. data/lib/rouge/lexers/r.rb +12 -12
  110. data/lib/rouge/lexers/racket.rb +22 -22
  111. data/lib/rouge/lexers/ruby.rb +71 -69
  112. data/lib/rouge/lexers/rust.rb +30 -30
  113. data/lib/rouge/lexers/sass.rb +8 -8
  114. data/lib/rouge/lexers/sass/common.rb +40 -40
  115. data/lib/rouge/lexers/scala.rb +43 -43
  116. data/lib/rouge/lexers/scheme.rb +18 -18
  117. data/lib/rouge/lexers/scss.rb +3 -3
  118. data/lib/rouge/lexers/sed.rb +29 -29
  119. data/lib/rouge/lexers/shell.rb +61 -52
  120. data/lib/rouge/lexers/sieve.rb +8 -8
  121. data/lib/rouge/lexers/slim.rb +24 -24
  122. data/lib/rouge/lexers/smalltalk.rb +33 -33
  123. data/lib/rouge/lexers/smarty.rb +12 -12
  124. data/lib/rouge/lexers/sml.rb +67 -67
  125. data/lib/rouge/lexers/sqf.rb +1 -1
  126. data/lib/rouge/lexers/sql.rb +21 -21
  127. data/lib/rouge/lexers/supercollider.rb +19 -19
  128. data/lib/rouge/lexers/swift.rb +42 -39
  129. data/lib/rouge/lexers/tap.rb +20 -20
  130. data/lib/rouge/lexers/tcl.rb +27 -27
  131. data/lib/rouge/lexers/terraform.rb +13 -13
  132. data/lib/rouge/lexers/tex.rb +19 -19
  133. data/lib/rouge/lexers/toml.rb +18 -18
  134. data/lib/rouge/lexers/tulip.rb +36 -36
  135. data/lib/rouge/lexers/turtle.rb +35 -38
  136. data/lib/rouge/lexers/vala.rb +17 -17
  137. data/lib/rouge/lexers/vb.rb +27 -27
  138. data/lib/rouge/lexers/verilog.rb +25 -27
  139. data/lib/rouge/lexers/vhdl.rb +10 -10
  140. data/lib/rouge/lexers/viml.rb +14 -14
  141. data/lib/rouge/lexers/vue.rb +9 -9
  142. data/lib/rouge/lexers/wollok.rb +25 -25
  143. data/lib/rouge/lexers/xml.rb +17 -21
  144. data/lib/rouge/lexers/xojo.rb +15 -15
  145. data/lib/rouge/lexers/yaml.rb +61 -61
  146. data/lib/rouge/plugins/redcarpet.rb +1 -1
  147. data/lib/rouge/tex_theme_renderer.rb +128 -0
  148. data/lib/rouge/theme.rb +4 -0
  149. data/lib/rouge/themes/magritte.rb +78 -0
  150. data/lib/rouge/version.rb +1 -1
  151. metadata +11 -2
@@ -112,7 +112,7 @@ module Rouge
112
112
  Punctuation)
113
113
 
114
114
  # Strings
115
- rule(/(?:[\w]+)"/,Str, :rdqs)
115
+ rule(/(?:\w+)"/,Str, :rdqs)
116
116
  rule(/"""/, Str, :tdqs)
117
117
  rule(/"/, Str, :dqs)
118
118
 
@@ -11,34 +11,34 @@ module Rouge
11
11
  filenames '*.nix'
12
12
 
13
13
  state :whitespaces do
14
- rule /^\s*\n\s*$/m, Text
15
- rule /\s+/, Text
14
+ rule %r/^\s*\n\s*$/m, Text
15
+ rule %r/\s+/, Text
16
16
  end
17
17
 
18
18
  state :comment do
19
- rule /#.*$/, Comment
20
- rule /\/\*/, Comment, :multiline_comment
19
+ rule %r/#.*$/, Comment
20
+ rule %r(/\*), Comment, :multiline_comment
21
21
  end
22
22
 
23
23
  state :multiline_comment do
24
- rule /\*\//, Comment, :pop!
25
- rule /./, Comment
24
+ rule %r(\*/), Comment, :pop!
25
+ rule %r/./, Comment
26
26
  end
27
27
 
28
28
  state :number do
29
- rule /[0-9]/, Num::Integer
29
+ rule %r/[0-9]/, Num::Integer
30
30
  end
31
31
 
32
32
  state :null do
33
- rule /(null)/, Keyword::Constant
33
+ rule %r/(null)/, Keyword::Constant
34
34
  end
35
35
 
36
36
  state :boolean do
37
- rule /(true|false)/, Keyword::Constant
37
+ rule %r/(true|false)/, Keyword::Constant
38
38
  end
39
39
 
40
40
  state :binding do
41
- rule /[a-zA-Z_][a-zA-Z0-9-]*/, Name::Variable
41
+ rule %r/[a-zA-Z_][a-zA-Z0-9-]*/, Name::Variable
42
42
  end
43
43
 
44
44
  state :path do
@@ -49,86 +49,86 @@ module Rouge
49
49
  tilde = /~#{section}+/.source
50
50
  basic = /#{word}(\/#{word})+/.source
51
51
  url = /#{prefix}(\/?#{basic})/.source
52
- rule /(#{root}|#{tilde}|#{basic}|#{url})/, Str::Other
52
+ rule %r/(#{root}|#{tilde}|#{basic}|#{url})/, Str::Other
53
53
  end
54
54
 
55
55
  state :string do
56
- rule /"/, Str::Double, :double_quoted_string
57
- rule /''/, Str::Double, :indented_string
56
+ rule %r/"/, Str::Double, :double_quoted_string
57
+ rule %r/''/, Str::Double, :indented_string
58
58
  end
59
59
 
60
60
  state :string_content do
61
- rule /\\./, Str::Escape
62
- rule /\$\$/, Str::Escape
63
- rule /\${/, Str::Interpol, :string_interpolated_arg
61
+ rule %r/\\./, Str::Escape
62
+ rule %r/\$\$/, Str::Escape
63
+ rule %r/\${/, Str::Interpol, :string_interpolated_arg
64
64
  end
65
65
 
66
66
  state :indented_string_content do
67
- rule /'''/, Str::Escape
68
- rule /''\$/, Str::Escape
69
- rule /\$\$/, Str::Escape
70
- rule /''\\./, Str::Escape
71
- rule /\${/, Str::Interpol, :string_interpolated_arg
67
+ rule %r/'''/, Str::Escape
68
+ rule %r/''\$/, Str::Escape
69
+ rule %r/\$\$/, Str::Escape
70
+ rule %r/''\\./, Str::Escape
71
+ rule %r/\${/, Str::Interpol, :string_interpolated_arg
72
72
  end
73
73
 
74
74
  state :string_interpolated_arg do
75
75
  mixin :expression
76
- rule /}/, Str::Interpol, :pop!
76
+ rule %r/}/, Str::Interpol, :pop!
77
77
  end
78
78
 
79
79
  state :indented_string do
80
80
  mixin :indented_string_content
81
- rule /''/, Str::Double, :pop!
82
- rule /./, Str::Double
81
+ rule %r/''/, Str::Double, :pop!
82
+ rule %r/./, Str::Double
83
83
  end
84
84
 
85
85
  state :double_quoted_string do
86
86
  mixin :string_content
87
- rule /"/, Str::Double, :pop!
88
- rule /./, Str::Double
87
+ rule %r/"/, Str::Double, :pop!
88
+ rule %r/./, Str::Double
89
89
  end
90
90
 
91
91
  state :operator do
92
- rule /(\.|\?|\+\+|\+|!=|!|\/\/|\=\=|&&|\|\||->|\/|\*|-|<|>|<=|=>)/, Operator
92
+ rule %r/(\.|\?|\+\+|\+|!=|!|\/\/|\=\=|&&|\|\||->|\/|\*|-|<|>|<=|=>)/, Operator
93
93
  end
94
94
 
95
95
  state :assignment do
96
- rule /(=)/, Operator
97
- rule /(@)/, Operator
96
+ rule %r/(=)/, Operator
97
+ rule %r/(@)/, Operator
98
98
  end
99
99
 
100
100
  state :accessor do
101
- rule /(\$)/, Punctuation
101
+ rule %r/(\$)/, Punctuation
102
102
  end
103
103
 
104
104
  state :delimiter do
105
- rule /(;|,|:)/, Punctuation
105
+ rule %r/(;|,|:)/, Punctuation
106
106
  end
107
107
 
108
108
  state :atom_content do
109
109
  mixin :expression
110
- rule /\)/, Punctuation, :pop!
110
+ rule %r/\)/, Punctuation, :pop!
111
111
  end
112
112
 
113
113
  state :atom do
114
- rule /\(/, Punctuation, :atom_content
114
+ rule %r/\(/, Punctuation, :atom_content
115
115
  end
116
116
 
117
117
  state :list do
118
- rule /\[/, Punctuation, :list_content
118
+ rule %r/\[/, Punctuation, :list_content
119
119
  end
120
120
 
121
121
  state :list_content do
122
- rule /\]/, Punctuation, :pop!
122
+ rule %r/\]/, Punctuation, :pop!
123
123
  mixin :expression
124
124
  end
125
125
 
126
126
  state :set do
127
- rule /{/, Punctuation, :set_content
127
+ rule %r/{/, Punctuation, :set_content
128
128
  end
129
129
 
130
130
  state :set_content do
131
- rule /}/, Punctuation, :pop!
131
+ rule %r/}/, Punctuation, :pop!
132
132
  mixin :expression
133
133
  end
134
134
 
@@ -161,22 +161,22 @@ module Rouge
161
161
 
162
162
  state :keywords_namespace do
163
163
  keywords = %w(with in inherit)
164
- rule /(?:#{keywords.join('|')})\b/, Keyword::Namespace
164
+ rule %r/(?:#{keywords.join('|')})\b/, Keyword::Namespace
165
165
  end
166
166
 
167
167
  state :keywords_declaration do
168
168
  keywords = %w(let)
169
- rule /(?:#{keywords.join('|')})\b/, Keyword::Declaration
169
+ rule %r/(?:#{keywords.join('|')})\b/, Keyword::Declaration
170
170
  end
171
171
 
172
172
  state :keywords_conditional do
173
173
  keywords = %w(if then else)
174
- rule /(?:#{keywords.join('|')})\b/, Keyword
174
+ rule %r/(?:#{keywords.join('|')})\b/, Keyword
175
175
  end
176
176
 
177
177
  state :keywords_reserved do
178
178
  keywords = %w(rec assert map)
179
- rule /(?:#{keywords.join('|')})\b/, Keyword::Reserved
179
+ rule %r/(?:#{keywords.join('|')})\b/, Keyword::Reserved
180
180
  end
181
181
 
182
182
  state :keywords_builtin do
@@ -192,7 +192,7 @@ module Rouge
192
192
  throw
193
193
  toString
194
194
  )
195
- rule /(?:#{keywords.join('|')})\b/, Keyword::Reserved
195
+ rule %r/(?:#{keywords.join('|')})\b/, Keyword::Reserved
196
196
  end
197
197
 
198
198
  state :ignore do
@@ -33,21 +33,21 @@ module Rouge
33
33
  id = /[a-z$_][a-z0-9$_]*/i
34
34
 
35
35
  prepend :statements do
36
- rule /@"/, Str, :string
37
- rule /@'(\\[0-7]{1,3}|\\x[a-fA-F0-9]{1,2}|\\.|[^\\'\n]')/,
36
+ rule %r/@"/, Str, :string
37
+ rule %r/@'(\\[0-7]{1,3}|\\x[a-fA-F0-9]{1,2}|\\.|[^\\'\n]')/,
38
38
  Str::Char
39
- rule /@(\d+[.]\d*|[.]\d+|\d+)e[+-]?\d+l?/i,
39
+ rule %r/@(\d+[.]\d*|[.]\d+|\d+)e[+-]?\d+l?/i,
40
40
  Num::Float
41
- rule /@(\d+[.]\d*|[.]\d+|\d+f)f?/i, Num::Float
42
- rule /@0x\h+[lL]?/, Num::Hex
43
- rule /@0[0-7]+l?/i, Num::Oct
44
- rule /@\d+l?/, Num::Integer
45
- rule /\bin\b/, Keyword
41
+ rule %r/@(\d+[.]\d*|[.]\d+|\d+f)f?/i, Num::Float
42
+ rule %r/@0x\h+[lL]?/, Num::Hex
43
+ rule %r/@0[0-7]+l?/i, Num::Oct
44
+ rule %r/@\d+l?/, Num::Integer
45
+ rule %r/\bin\b/, Keyword
46
46
 
47
- rule /@(?:interface|implementation)\b/, Keyword, :classname
48
- rule /@(?:class|protocol)\b/, Keyword, :forward_classname
47
+ rule %r/@(?:interface|implementation)\b/, Keyword, :classname
48
+ rule %r/@(?:class|protocol)\b/, Keyword, :forward_classname
49
49
 
50
- rule /@([[:alnum:]]+)/ do |m|
50
+ rule %r/@([[:alnum:]]+)/ do |m|
51
51
  if self.class.at_keywords.include? m[1]
52
52
  token Keyword
53
53
  elsif self.class.at_builtins.include? m[1]
@@ -57,32 +57,32 @@ module Rouge
57
57
  end
58
58
  end
59
59
 
60
- rule /[?]/, Punctuation, :ternary
61
- rule /\[/, Punctuation, :message
62
- rule /@\[/, Punctuation, :array_literal
63
- rule /@\{/, Punctuation, :dictionary_literal
60
+ rule %r/[?]/, Punctuation, :ternary
61
+ rule %r/\[/, Punctuation, :message
62
+ rule %r/@\[/, Punctuation, :array_literal
63
+ rule %r/@\{/, Punctuation, :dictionary_literal
64
64
  end
65
65
 
66
66
  state :ternary do
67
- rule /:/, Punctuation, :pop!
67
+ rule %r/:/, Punctuation, :pop!
68
68
  mixin :statements
69
69
  end
70
70
 
71
71
  state :message_shared do
72
- rule /\]/, Punctuation, :pop!
73
- rule /\{/, Punctuation, :pop!
74
- rule /;/, Error
72
+ rule %r/\]/, Punctuation, :pop!
73
+ rule %r/\{/, Punctuation, :pop!
74
+ rule %r/;/, Error
75
75
 
76
76
  mixin :statements
77
77
  end
78
78
 
79
79
  state :message do
80
- rule /(#{id})(\s*)(:)/ do
80
+ rule %r/(#{id})(\s*)(:)/ do
81
81
  groups(Name::Function, Text, Punctuation)
82
82
  goto :message_with_args
83
83
  end
84
84
 
85
- rule /(#{id})(\s*)(\])/ do
85
+ rule %r/(#{id})(\s*)(\])/ do
86
86
  groups(Name::Function, Text, Punctuation)
87
87
  pop!
88
88
  end
@@ -91,8 +91,8 @@ module Rouge
91
91
  end
92
92
 
93
93
  state :message_with_args do
94
- rule /\{/, Punctuation, :function
95
- rule /(#{id})(\s*)(:)/ do
94
+ rule %r/\{/, Punctuation, :function
95
+ rule %r/(#{id})(\s*)(:)/ do
96
96
  groups(Name::Function, Text, Punctuation)
97
97
  pop!
98
98
  end
@@ -101,28 +101,28 @@ module Rouge
101
101
  end
102
102
 
103
103
  state :array_literal do
104
- rule /]/, Punctuation, :pop!
105
- rule /,/, Punctuation
104
+ rule %r/]/, Punctuation, :pop!
105
+ rule %r/,/, Punctuation
106
106
  mixin :statements
107
107
  end
108
108
 
109
109
  state :dictionary_literal do
110
- rule /}/, Punctuation, :pop!
111
- rule /,/, Punctuation
110
+ rule %r/}/, Punctuation, :pop!
111
+ rule %r/,/, Punctuation
112
112
  mixin :statements
113
113
  end
114
114
 
115
115
  state :classname do
116
116
  mixin :whitespace
117
117
 
118
- rule /(#{id})(\s*)(:)(\s*)(#{id})/ do
118
+ rule %r/(#{id})(\s*)(:)(\s*)(#{id})/ do
119
119
  groups(Name::Class, Text,
120
120
  Punctuation, Text,
121
121
  Name::Class)
122
122
  pop!
123
123
  end
124
124
 
125
- rule /(#{id})(\s*)([(])(\s*)(#{id})(\s*)([)])/ do
125
+ rule %r/(#{id})(\s*)([(])(\s*)(#{id})(\s*)([)])/ do
126
126
  groups(Name::Class, Text,
127
127
  Punctuation, Text,
128
128
  Name::Label, Text,
@@ -136,12 +136,12 @@ module Rouge
136
136
  state :forward_classname do
137
137
  mixin :whitespace
138
138
 
139
- rule /(#{id})(\s*)(,)(\s*)/ do
139
+ rule %r/(#{id})(\s*)(,)(\s*)/ do
140
140
  groups(Name::Class, Text, Punctuation, Text)
141
141
  push
142
142
  end
143
143
 
144
- rule /(#{id})(\s*)(;?)/ do
144
+ rule %r/(#{id})(\s*)(;?)/ do
145
145
  groups(Name::Class, Text, Punctuation)
146
146
  pop!
147
147
  end
@@ -162,26 +162,26 @@ module Rouge
162
162
  end
163
163
 
164
164
  state :method_definition do
165
- rule /,/, Punctuation
166
- rule /[.][.][.]/, Punctuation
167
- rule /([(].*?[)])(#{id})/ do |m|
165
+ rule %r/,/, Punctuation
166
+ rule %r/[.][.][.]/, Punctuation
167
+ rule %r/([(].*?[)])(#{id})/ do |m|
168
168
  recurse m[1]; token Name::Variable, m[2]
169
169
  end
170
170
 
171
- rule /(#{id})(\s*)(:)/m do
171
+ rule %r/(#{id})(\s*)(:)/m do
172
172
  groups(Name::Function, Text, Punctuation)
173
173
  end
174
174
 
175
- rule /;/, Punctuation, :pop!
175
+ rule %r/;/, Punctuation, :pop!
176
176
 
177
- rule /{/ do
177
+ rule %r/{/ do
178
178
  token Punctuation
179
179
  goto :function
180
180
  end
181
181
 
182
182
  mixin :inline_whitespace
183
183
  rule %r(//.*?\n), Comment::Single
184
- rule /\s+/m, Text
184
+ rule %r/\s+/m, Text
185
185
 
186
186
  rule(//) { pop! }
187
187
  end
@@ -33,12 +33,12 @@ module Rouge
33
33
  upper_id = /[A-Z][\w']*/
34
34
 
35
35
  state :root do
36
- rule /\s+/m, Text
37
- rule /false|true|[(][)]|\[\]/, Name::Builtin::Pseudo
38
- rule /#{upper_id}(?=\s*[.])/, Name::Namespace, :dotted
39
- rule /`#{id}/, Name::Tag
36
+ rule %r/\s+/m, Text
37
+ rule %r/false|true|[(][)]|\[\]/, Name::Builtin::Pseudo
38
+ rule %r/#{upper_id}(?=\s*[.])/, Name::Namespace, :dotted
39
+ rule %r/`#{id}/, Name::Tag
40
40
  rule upper_id, Name::Class
41
- rule /[(][*](?![)])/, Comment, :comment
41
+ rule %r/[(][*](?![)])/, Comment, :comment
42
42
  rule id do |m|
43
43
  match = m[0]
44
44
  if self.class.keywords.include? match
@@ -52,49 +52,49 @@ module Rouge
52
52
  end
53
53
  end
54
54
 
55
- rule /[(){}\[\];]+/, Punctuation
55
+ rule %r/[(){}\[\];]+/, Punctuation
56
56
  rule operator, Operator
57
57
 
58
- rule /-?\d[\d_]*(.[\d_]*)?(e[+-]?\d[\d_]*)/i, Num::Float
59
- rule /0x\h[\h_]*/i, Num::Hex
60
- rule /0o[0-7][0-7_]*/i, Num::Oct
61
- rule /0b[01][01_]*/i, Num::Bin
62
- rule /\d[\d_]*/, Num::Integer
58
+ rule %r/-?\d[\d_]*(.[\d_]*)?(e[+-]?\d[\d_]*)/i, Num::Float
59
+ rule %r/0x\h[\h_]*/i, Num::Hex
60
+ rule %r/0o[0-7][0-7_]*/i, Num::Oct
61
+ rule %r/0b[01][01_]*/i, Num::Bin
62
+ rule %r/\d[\d_]*/, Num::Integer
63
63
 
64
- rule /'(?:(\\[\\"'ntbr ])|(\\[0-9]{3})|(\\x\h{2}))'/, Str::Char
65
- rule /'[.]'/, Str::Char
66
- rule /'/, Keyword
67
- rule /"/, Str::Double, :string
68
- rule /[~?]#{id}/, Name::Variable
64
+ rule %r/'(?:(\\[\\"'ntbr ])|(\\[0-9]{3})|(\\x\h{2}))'/, Str::Char
65
+ rule %r/'[.]'/, Str::Char
66
+ rule %r/'/, Keyword
67
+ rule %r/"/, Str::Double, :string
68
+ rule %r/[~?]#{id}/, Name::Variable
69
69
  end
70
70
 
71
71
  state :comment do
72
- rule /[^(*)]+/, Comment
72
+ rule %r/[^(*)]+/, Comment
73
73
  rule(/[(][*]/) { token Comment; push }
74
- rule /[*][)]/, Comment, :pop!
75
- rule /[(*)]/, Comment
74
+ rule %r/[*][)]/, Comment, :pop!
75
+ rule %r/[(*)]/, Comment
76
76
  end
77
77
 
78
78
  state :string do
79
- rule /[^\\"]+/, Str::Double
79
+ rule %r/[^\\"]+/, Str::Double
80
80
  mixin :escape_sequence
81
- rule /\\\n/, Str::Double
82
- rule /"/, Str::Double, :pop!
81
+ rule %r/\\\n/, Str::Double
82
+ rule %r/"/, Str::Double, :pop!
83
83
  end
84
84
 
85
85
  state :escape_sequence do
86
- rule /\\[\\"'ntbr]/, Str::Escape
87
- rule /\\\d{3}/, Str::Escape
88
- rule /\\x\h{2}/, Str::Escape
86
+ rule %r/\\[\\"'ntbr]/, Str::Escape
87
+ rule %r/\\\d{3}/, Str::Escape
88
+ rule %r/\\x\h{2}/, Str::Escape
89
89
  end
90
90
 
91
91
  state :dotted do
92
- rule /\s+/m, Text
93
- rule /[.]/, Punctuation
94
- rule /#{upper_id}(?=\s*[.])/, Name::Namespace
92
+ rule %r/\s+/m, Text
93
+ rule %r/[.]/, Punctuation
94
+ rule %r/#{upper_id}(?=\s*[.])/, Name::Namespace
95
95
  rule upper_id, Name::Class, :pop!
96
96
  rule id, Name, :pop!
97
- rule /[({\[]/, Punctuation, :pop!
97
+ rule %r/[({\[]/, Punctuation, :pop!
98
98
  end
99
99
  end
100
100
  end