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
@@ -56,18 +56,18 @@ module Rouge
56
56
 
57
57
  # The list of built-in symbols comes from a wolfram server and is created automatically by rake
58
58
  def self.builtins
59
- load Pathname.new(__FILE__).dirname.join('mathematica/builtins.rb')
59
+ load File.join(__dir__, 'mathematica/builtins.rb')
60
60
  self.builtins
61
61
  end
62
62
 
63
63
  state :root do
64
- rule /\s+/, Text::Whitespace
65
- rule /\(\*/, Comment, :comment
66
- rule /#{base}\^\^#{number_base}#{precision}?(\*\^[+-]?\d+)?/, Num # a number with a base
67
- rule /(?:#{number}#{precision}?(?:\*\^[+-]?\d+)?)/, Num # all other numbers
64
+ rule %r/\s+/, Text::Whitespace
65
+ rule %r/\(\*/, Comment, :comment
66
+ rule %r/#{base}\^\^#{number_base}#{precision}?(\*\^[+-]?\d+)?/, Num # a number with a base
67
+ rule %r/(?:#{number}#{precision}?(?:\*\^[+-]?\d+)?)/, Num # all other numbers
68
68
  rule message, Name::Tag
69
69
  rule in_out, Generic::Prompt
70
- rule /#{context_symbol}/m do |m|
70
+ rule %r/#{context_symbol}/m do |m|
71
71
  match = m[0]
72
72
  if self.class.keywords.include? match
73
73
  token Name::Builtin::Pseudo
@@ -85,11 +85,11 @@ module Rouge
85
85
 
86
86
  # Allow for nested comments and special treatment of ::Section:: or :Author: markup
87
87
  state :comment do
88
- rule /\(\*/, Comment, :comment
89
- rule /\*\)/, Comment, :pop!
90
- rule /::#{identifier}::/, Comment::Preproc
91
- rule /[ ]:(#{identifier}|[^\S])+:[ ]/, Comment::Preproc
92
- rule /./, Comment
88
+ rule %r/\(\*/, Comment, :comment
89
+ rule %r/\*\)/, Comment, :pop!
90
+ rule %r/::#{identifier}::/, Comment::Preproc
91
+ rule %r/[ ]:(#{identifier}|[^\S])+:[ ]/, Comment::Preproc
92
+ rule %r/./, Comment
93
93
  end
94
94
  end
95
95
  end
@@ -19,25 +19,25 @@ module Rouge
19
19
  end
20
20
 
21
21
  def self.builtins
22
- load Pathname.new(__FILE__).dirname.join('matlab/builtins.rb')
22
+ load File.join(__dir__, 'matlab/builtins.rb')
23
23
  self.builtins
24
24
  end
25
25
 
26
26
  state :root do
27
- rule /\s+/m, Text # Whitespace
27
+ rule %r/\s+/m, Text # Whitespace
28
28
  rule %r([{]%.*?%[}])m, Comment::Multiline
29
- rule /%.*$/, Comment::Single
30
- rule /([.][.][.])(.*?)$/ do
29
+ rule %r/%.*$/, Comment::Single
30
+ rule %r/([.][.][.])(.*?)$/ do
31
31
  groups(Keyword, Comment)
32
32
  end
33
33
 
34
- rule /^(!)(.*?)(?=%|$)/ do |m|
34
+ rule %r/^(!)(.*?)(?=%|$)/ do |m|
35
35
  token Keyword, m[1]
36
36
  delegate Shell, m[2]
37
37
  end
38
38
 
39
39
 
40
- rule /[a-zA-Z][_a-zA-Z0-9]*/m do |m|
40
+ rule %r/[a-zA-Z][_a-zA-Z0-9]*/m do |m|
41
41
  match = m[0]
42
42
  if self.class.keywords.include? match
43
43
  token Keyword
@@ -50,29 +50,29 @@ module Rouge
50
50
 
51
51
  rule %r{[(){};:,\/\\\]\[]}, Punctuation
52
52
 
53
- rule /~=|==|<<|>>|[-~+\/*%=<>&^|.@]/, Operator
53
+ rule %r/~=|==|<<|>>|[-~+\/*%=<>&^|.@]/, Operator
54
54
 
55
55
 
56
- rule /(\d+\.\d*|\d*\.\d+)(e[+-]?[0-9]+)?/i, Num::Float
57
- rule /\d+e[+-]?[0-9]+/i, Num::Float
58
- rule /\d+L/, Num::Integer::Long
59
- rule /\d+/, Num::Integer
56
+ rule %r/(\d+\.\d*|\d*\.\d+)(e[+-]?[0-9]+)?/i, Num::Float
57
+ rule %r/\d+e[+-]?[0-9]+/i, Num::Float
58
+ rule %r/\d+L/, Num::Integer::Long
59
+ rule %r/\d+/, Num::Integer
60
60
 
61
- rule /'(?=(.*'))/, Str::Single, :chararray
62
- rule /"(?=(.*"))/, Str::Double, :string
63
- rule /'/, Operator
61
+ rule %r/'(?=(.*'))/, Str::Single, :chararray
62
+ rule %r/"(?=(.*"))/, Str::Double, :string
63
+ rule %r/'/, Operator
64
64
  end
65
65
 
66
66
  state :chararray do
67
- rule /[^']+/, Str::Single
68
- rule /''/, Str::Escape
69
- rule /'/, Str::Single, :pop!
67
+ rule %r/[^']+/, Str::Single
68
+ rule %r/''/, Str::Escape
69
+ rule %r/'/, Str::Single, :pop!
70
70
  end
71
71
 
72
72
  state :string do
73
- rule /[^"]+/, Str::Double
74
- rule /""/, Str::Escape
75
- rule /"/, Str::Double, :pop!
73
+ rule %r/[^"]+/, Str::Double
74
+ rule %r/""/, Str::Escape
75
+ rule %r/"/, Str::Double, :pop!
76
76
  end
77
77
  end
78
78
  end
@@ -40,18 +40,18 @@ module Rouge
40
40
 
41
41
  state :root do
42
42
  rule %r(#!(.*?)$), Comment::Preproc # shebang
43
- rule //, Text, :main
43
+ rule %r//, Text, :main
44
44
  end
45
45
 
46
46
  state :base do
47
- ident = '(?:[\w_][\w\d_]*)'
47
+ ident = '(?:\w\w*)'
48
48
 
49
49
  rule %r((?i)(\d*\.\d+|\d+\.\d*)(e[+-]?\d+)?'), Num::Float
50
50
  rule %r((?i)\d+e[+-]?\d+), Num::Float
51
51
  rule %r((?i)0x[0-9a-f]*), Num::Hex
52
52
  rule %r(\d+), Num::Integer
53
53
  rule %r(@#{ident}*), Name::Variable::Instance
54
- rule %r([A-Z][\w\d_]*), Name::Class
54
+ rule %r([A-Z]\w*), Name::Class
55
55
  rule %r("?[^"]+":), Literal::String::Symbol
56
56
  rule %r(#{ident}:), Literal::String::Symbol
57
57
  rule %r(:#{ident}), Literal::String::Symbol
@@ -166,7 +166,7 @@ module Rouge
166
166
 
167
167
  state :whitespace do
168
168
  # Spaces
169
- rule /\s+/m, Text
169
+ rule %r/\s+/m, Text
170
170
  # ! Comments
171
171
  rule %r((!).*$\n?), Comment::Single
172
172
  # (! Comments !)
@@ -182,14 +182,14 @@ module Rouge
182
182
  # The escape sequences are not interpreted if they are contained in strings that are enclosed in single quotes.
183
183
 
184
184
  state :single_quotes do
185
- rule /'/, Str::Single, :pop!
186
- rule /[^']+/, Str::Single
185
+ rule %r/'/, Str::Single, :pop!
186
+ rule %r/[^']+/, Str::Single
187
187
  end
188
188
 
189
189
  state :double_quotes do
190
- rule /"/, Str::Double, :pop!
191
- rule /(\\"|\\[0-7]{1,3}\D|\\[abfnrtv]|\\\\)/, Str::Escape
192
- rule /[^"]/, Str::Double
190
+ rule %r/"/, Str::Double, :pop!
191
+ rule %r/(\\"|\\[0-7]{1,3}\D|\\[abfnrtv]|\\\\)/, Str::Escape
192
+ rule %r/[^"]/, Str::Double
193
193
  end
194
194
 
195
195
  state :base do
@@ -200,25 +200,25 @@ module Rouge
200
200
  rule %r{((0(x|X)[0-9a-fA-F]*)|(([0-9]+\.?[0-9]*)|(\.[0-9]+))((e|E)(\+|-)?[0-9]+)?)(L|l|UL|ul|u|U|F|f|ll|LL|ull|ULL)?}, Num
201
201
  rule %r{[~!@#\$%\^&\*\(\)\+`\-={}\[\]:;<>\?,\.\/\|\\]}, Punctuation
202
202
  # rule %r{'([^']|'')*'}, Str
203
- # rule /"(\\\\|\\"|[^"])*"/, Str
203
+ # rule %r/"(\\\\|\\"|[^"])*"/, Str
204
204
 
205
205
 
206
206
 
207
- rule /(true|false)\b/i, Name::Builtin
208
- rule /\b(#{core_keywords.join('|')})\b/i, Keyword
209
- rule /\b(#{core_functions.join('|')})\b/, Name::Builtin
207
+ rule %r/(true|false)\b/i, Name::Builtin
208
+ rule %r/\b(#{core_keywords.join('|')})\b/i, Keyword
209
+ rule %r/\b(#{core_functions.join('|')})\b/, Name::Builtin
210
210
 
211
211
 
212
212
 
213
- rule /\b(#{mmxprs_functions.join('|')})\b/, Name::Function
214
- rule /\b(#{mmxpres_constants.join('|')})\b/, Name::Constant
215
- rule /\b(#{mmxprs_parameters.join('|')})\b/i, Name::Property
213
+ rule %r/\b(#{mmxprs_functions.join('|')})\b/, Name::Function
214
+ rule %r/\b(#{mmxpres_constants.join('|')})\b/, Name::Constant
215
+ rule %r/\b(#{mmxprs_parameters.join('|')})\b/i, Name::Property
216
216
 
217
- rule /\b(#{mmsystem_functions.join('|')})\b/i, Name::Function
218
- rule /\b(#{mmsystem_parameters.join('|')})\b/, Name::Property
217
+ rule %r/\b(#{mmsystem_functions.join('|')})\b/i, Name::Function
218
+ rule %r/\b(#{mmsystem_parameters.join('|')})\b/, Name::Property
219
219
 
220
- rule /\b(#{mmjobs_functions.join('|')})\b/i, Name::Function
221
- rule /\b(#{mmjobs_parameters.join('|')})\b/, Name::Property
220
+ rule %r/\b(#{mmjobs_functions.join('|')})\b/i, Name::Function
221
+ rule %r/\b(#{mmjobs_parameters.join('|')})\b/, Name::Property
222
222
 
223
223
  rule id, Name
224
224
  end
@@ -11,56 +11,56 @@ module Rouge
11
11
  mimetypes 'application/xv+xml'
12
12
 
13
13
  state :root do
14
- rule /[^<&]+/, Text
15
- rule /&\S*?;/, Name::Entity
14
+ rule %r/[^<&]+/, Text
15
+ rule %r/&\S*?;/, Name::Entity
16
16
 
17
- rule /<!\[CDATA\[/m do
17
+ rule %r/<!\[CDATA\[/m do
18
18
  token Comment::Preproc
19
19
  push :actionscript_content
20
20
  end
21
21
 
22
- rule /<!--/, Comment, :comment
23
- rule /<\?.*?\?>/, Comment::Preproc
24
- rule /<![^>]*>/, Comment::Preproc
22
+ rule %r/<!--/, Comment, :comment
23
+ rule %r/<\?.*?\?>/, Comment::Preproc
24
+ rule %r/<![^>]*>/, Comment::Preproc
25
25
 
26
26
  rule %r(<\s*[\w:.-]+)m, Name::Tag, :tag # opening tags
27
27
  rule %r(<\s*/\s*[\w:.-]+\s*>)m, Name::Tag # closing tags
28
28
  end
29
29
 
30
30
  state :comment do
31
- rule /[^-]+/m, Comment
32
- rule /-->/, Comment, :pop!
33
- rule /-/, Comment
31
+ rule %r/[^-]+/m, Comment
32
+ rule %r/-->/, Comment, :pop!
33
+ rule %r/-/, Comment
34
34
  end
35
35
 
36
36
  state :tag do
37
- rule /\s+/m, Text
38
- rule /[\w.:-]+\s*=/m, Name::Attribute, :attribute
37
+ rule %r/\s+/m, Text
38
+ rule %r/[\w.:-]+\s*=/m, Name::Attribute, :attribute
39
39
  rule %r(/?\s*>), Name::Tag, :root
40
40
  end
41
41
 
42
42
  state :attribute do
43
- rule /\s+/m, Text
44
- rule /(")({|@{)/m do
43
+ rule %r/\s+/m, Text
44
+ rule %r/(")({|@{)/m do
45
45
  groups Str, Punctuation
46
46
  push :actionscript_attribute
47
47
  end
48
- rule /".*?"|'.*?'|[^\s>]+/, Str, :tag
48
+ rule %r/".*?"|'.*?'|[^\s>]+/, Str, :tag
49
49
  end
50
50
 
51
51
  state :actionscript_content do
52
- rule /\]\]\>/m, Comment::Preproc, :pop!
53
- rule /.*?(?=\]\]\>)/m do
52
+ rule %r/\]\]\>/m, Comment::Preproc, :pop!
53
+ rule %r/.*?(?=\]\]\>)/m do
54
54
  delegate Actionscript
55
55
  end
56
56
  end
57
57
 
58
58
  state :actionscript_attribute do
59
- rule /(})(")/m do
59
+ rule %r/(})(")/m do
60
60
  groups Punctuation, Str
61
61
  push :tag
62
62
  end
63
- rule /.*?(?=}")/m do
63
+ rule %r/.*?(?=}")/m do
64
64
  delegate Actionscript
65
65
  end
66
66
  end
@@ -11,7 +11,6 @@ module Rouge
11
11
  title "Nasm"
12
12
  desc "Netwide Assembler"
13
13
 
14
- ws = %r((?:\s|;.*?\n/)+)
15
14
  id = /[a-zA-Z_][a-zA-Z0-9_]*/
16
15
 
17
16
  #todo: pull more instructions from: http://www.nasm.us/doc/nasmdocb.html
@@ -119,57 +118,57 @@ module Rouge
119
118
  end
120
119
 
121
120
  state :inline_whitespace do
122
- rule /[ \t\r]+/, Text
121
+ rule %r/[ \t\r]+/, Text
123
122
  end
124
123
 
125
124
  state :whitespace do
126
- rule /\n+/m, Text, :expr_bol
125
+ rule %r/\n+/m, Text, :expr_bol
127
126
  rule %r(//(\\.|.)*?\n), Comment::Single, :expr_bol
128
127
  mixin :inline_whitespace
129
128
  end
130
129
 
131
130
  state :expr_whitespace do
132
- rule /\n+/m, Text, :expr_bol
131
+ rule %r/\n+/m, Text, :expr_bol
133
132
  mixin :whitespace
134
133
  end
135
134
 
136
135
  state :root do
137
136
  mixin :expr_whitespace
138
137
  rule(//) { push :statement }
139
- rule /^%[a-zA-Z0-9]+/, Comment::Preproc, :statement
138
+ rule %r/^%[a-zA-Z0-9]+/, Comment::Preproc, :statement
140
139
 
141
140
  rule(
142
141
  %r(&=|[*]=|/=|\\=|\^=|\+=|-=|<<=|>>=|<<|>>|:=|<=|>=|<>|[-&*/\\^+=<>.]),
143
142
  Operator
144
143
  )
145
- rule /;.*/, Comment, :statement
146
- rule /^[a-zA-Z]+[a-zA-Z0-9]*:/, Name::Function
147
- rule /;.*/, Comment
144
+ rule %r/;.*/, Comment, :statement
145
+ rule %r/^[a-zA-Z]+[a-zA-Z0-9]*:/, Name::Function
146
+ rule %r/;.*/, Comment
148
147
  end
149
148
 
150
149
  state :statement do
151
150
  mixin :expr_whitespace
152
151
  mixin :statements
153
- rule /;.*/, Comment
154
- rule /^%[a-zA-Z0-9]+/, Comment::Preproc
155
- rule /[a-zA-Z]+%[0-9]+:/, Name::Function
152
+ rule %r/;.*/, Comment
153
+ rule %r/^%[a-zA-Z0-9]+/, Comment::Preproc
154
+ rule %r/[a-zA-Z]+%[0-9]+:/, Name::Function
156
155
  end
157
156
 
158
157
  state :statements do
159
158
  mixin :whitespace
160
- rule /L?"/, Str, :string
161
- rule /[a-zA-Z]+%[0-9]+:/, Name::Function #labels/subroutines/functions
159
+ rule %r/L?"/, Str, :string
160
+ rule %r/[a-zA-Z]+%[0-9]+:/, Name::Function #labels/subroutines/functions
162
161
  rule %r(L?'(\\.|\\[0-7]{1,3}|\\x[a-f0-9]{1,2}|[^\\'\n])')i, Str::Char
163
- rule /0x[0-9a-f]+[lu]*/i, Num::Hex
164
- rule /\d+[lu]*/i, Num::Integer
162
+ rule %r/0x[0-9a-f]+[lu]*/i, Num::Hex
163
+ rule %r/\d+[lu]*/i, Num::Integer
165
164
  rule %r(\*/), Error
166
165
  rule %r([~&*+=\|?:<>/-]), Operator
167
- rule /[(),.]/, Punctuation
168
- rule /\[[a-zA-Z0-9]*\]/, Punctuation
169
- rule /%[0-9]+/, Keyword::Reserved
170
- rule /[a-zA-Z]+%[0-9]+/, Name::Function #labels/subroutines/functions
166
+ rule %r/[(),.]/, Punctuation
167
+ rule %r/\[[a-zA-Z0-9]*\]/, Punctuation
168
+ rule %r/%[0-9]+/, Keyword::Reserved
169
+ rule %r/[a-zA-Z]+%[0-9]+/, Name::Function #labels/subroutines/functions
171
170
 
172
- #rule /(?<!\.)#{id}/ do |m|
171
+ #rule %r/(?<!\.)#{id}/ do |m|
173
172
  rule id do |m|
174
173
  name = m[0]
175
174
 
@@ -188,11 +187,11 @@ module Rouge
188
187
  end
189
188
 
190
189
  state :string do
191
- rule /"/, Str, :pop!
192
- rule /\\([\\abfnrtv"']|x[a-fA-F0-9]{2,4}|[0-7]{1,3})/, Str::Escape
193
- rule /[^\\"\n]+/, Str
194
- rule /\\\n/, Str
195
- rule /\\/, Str # stray backslash
190
+ rule %r/"/, Str, :pop!
191
+ rule %r/\\([\\abfnrtv"']|x[a-fA-F0-9]{2,4}|[0-7]{1,3})/, Str::Escape
192
+ rule %r/[^\\"\n]+/, Str
193
+ rule %r/\\\n/, Str
194
+ rule %r/\\/, Str # stray backslash
196
195
  end
197
196
  end
198
197
  end
@@ -13,7 +13,7 @@ module Rouge
13
13
  id = /[^\s$;{}()#]+/
14
14
 
15
15
  state :root do
16
- rule /(include)(\s+)([^\s;]+)/ do
16
+ rule %r/(include)(\s+)([^\s;]+)/ do
17
17
  groups Keyword, Text, Name
18
18
  end
19
19
 
@@ -23,49 +23,49 @@ module Rouge
23
23
  end
24
24
 
25
25
  state :block do
26
- rule /}/, Punctuation, :pop!
26
+ rule %r/}/, Punctuation, :pop!
27
27
  rule id, Keyword::Namespace, :statement
28
28
  mixin :base
29
29
  end
30
30
 
31
31
  state :statement do
32
- rule /{/ do
32
+ rule %r/{/ do
33
33
  token Punctuation; pop!; push :block
34
34
  end
35
35
 
36
- rule /;/, Punctuation, :pop!
36
+ rule %r/;/, Punctuation, :pop!
37
37
 
38
38
  mixin :base
39
39
  end
40
40
 
41
41
  state :base do
42
- rule /\s+/, Text
42
+ rule %r/\s+/, Text
43
43
 
44
- rule /#.*?\n/, Comment::Single
45
- rule /(?:on|off)\b/, Name::Constant
46
- rule /[$][\w-]+/, Name::Variable
44
+ rule %r/#.*?\n/, Comment::Single
45
+ rule %r/(?:on|off)\b/, Name::Constant
46
+ rule %r/[$][\w-]+/, Name::Variable
47
47
 
48
48
  # host/port
49
- rule /([a-z0-9.-]+)(:)([0-9]+)/i do
49
+ rule %r/([a-z0-9.-]+)(:)([0-9]+)/i do
50
50
  groups Name::Function, Punctuation, Num::Integer
51
51
  end
52
52
 
53
53
  # mimetype
54
54
  rule %r([a-z-]+/[a-z-]+)i, Name::Class
55
55
 
56
- rule /[0-9]+[kmg]?\b/i, Num::Integer
57
- rule /(~)(\s*)([^\s{]+)/ do
56
+ rule %r/[0-9]+[kmg]?\b/i, Num::Integer
57
+ rule %r/(~)(\s*)([^\s{]+)/ do
58
58
  groups Punctuation, Text, Str::Regex
59
59
  end
60
60
 
61
- rule /[:=~]/, Punctuation
61
+ rule %r/[:=~]/, Punctuation
62
62
 
63
63
  # pathname
64
64
  rule %r(/#{id}?), Name
65
65
 
66
- rule /[^#\s;{}$\\]+/, Str # catchall
66
+ rule %r/[^#\s;{}$\\]+/, Str # catchall
67
67
 
68
- rule /[$;]/, Text
68
+ rule %r/[$;]/, Text
69
69
  end
70
70
  end
71
71
  end