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
@@ -9,21 +9,22 @@ module Rouge
9
9
  tag 'json'
10
10
  filenames '*.json'
11
11
  mimetypes 'application/json', 'application/vnd.api+json',
12
- 'application/hal+json'
12
+ 'application/hal+json', 'application/problem+json',
13
+ 'application/schema+json'
13
14
 
14
15
  state :root do
15
- rule /\s+/m, Text::Whitespace
16
- rule /"/, Str::Double, :string
17
- rule /(?:true|false|null)\b/, Keyword::Constant
18
- rule /[{},:\[\]]/, Punctuation
19
- rule /-?(?:0|[1-9]\d*)\.\d+(?:e[+-]?\d+)?/i, Num::Float
20
- rule /-?(?:0|[1-9]\d*)(?:e[+-]?\d+)?/i, Num::Integer
16
+ rule %r/\s+/m, Text::Whitespace
17
+ rule %r/"/, Str::Double, :string
18
+ rule %r/(?:true|false|null)\b/, Keyword::Constant
19
+ rule %r/[{},:\[\]]/, Punctuation
20
+ rule %r/-?(?:0|[1-9]\d*)\.\d+(?:e[+-]?\d+)?/i, Num::Float
21
+ rule %r/-?(?:0|[1-9]\d*)(?:e[+-]?\d+)?/i, Num::Integer
21
22
  end
22
23
 
23
24
  state :string do
24
- rule /[^\\"]+/, Str::Double
25
- rule /\\./, Str::Escape
26
- rule /"/, Str::Double, :pop!
25
+ rule %r/[^\\"]+/, Str::Double
26
+ rule %r/\\./, Str::Escape
27
+ rule %r/"/, Str::Double, :pop!
27
28
  end
28
29
  end
29
30
  end
@@ -10,14 +10,14 @@ module Rouge
10
10
  tag 'json-doc'
11
11
 
12
12
  prepend :root do
13
- rule /([$\w]+)(\s*)(:)/ do
13
+ rule %r/([$\w]+)(\s*)(:)/ do
14
14
  groups Name::Attribute, Text, Punctuation
15
15
  end
16
16
 
17
17
  rule %r(/[*].*?[*]/), Comment
18
18
 
19
19
  rule %r(//.*?$), Comment::Single
20
- rule /(\.\.\.)/, Comment::Single
20
+ rule %r/(\.\.\.)/, Comment::Single
21
21
  end
22
22
  end
23
23
  end
@@ -7,7 +7,7 @@ module Rouge
7
7
  title 'Jsonnet'
8
8
  desc 'An elegant, formally-specified config language for JSON'
9
9
  tag 'jsonnet'
10
- filenames '*.jsonnet'
10
+ filenames '*.jsonnet', '*.libsonnet'
11
11
  mimetypes 'text/x-jsonnet'
12
12
 
13
13
  def self.keywords
@@ -93,21 +93,21 @@ module Rouge
93
93
  identifier = /[a-zA-Z_][a-zA-Z0-9_]*/
94
94
 
95
95
  state :root do
96
- rule /\s+/, Text
96
+ rule %r/\s+/, Text
97
97
  rule %r(//.*?$), Comment::Single
98
98
  rule %r(#.*?$), Comment::Single
99
99
  rule %r(/\*.*?\*/)m, Comment::Multiline
100
100
 
101
- rule /-?(?:0|[1-9]\d*)\.\d+(?:e[+-]\d+)?/i, Num::Float
102
- rule /-?(?:0|[1-9]\d*)(?:e[+-]\d+)?/i, Num::Integer
101
+ rule %r/-?(?:0|[1-9]\d*)\.\d+(?:e[+-]\d+)?/i, Num::Float
102
+ rule %r/-?(?:0|[1-9]\d*)(?:e[+-]\d+)?/i, Num::Integer
103
103
 
104
- rule /[{}:\.,;+\[\]=%\(\)]/, Punctuation
104
+ rule %r/[{}:\.,;+\[\]=%\(\)]/, Punctuation
105
105
 
106
- rule /"/, Str, :string_double
107
- rule /'/, Str, :string_single
108
- rule /\|\|\|/, Str, :string_block
106
+ rule %r/"/, Str, :string_double
107
+ rule %r/'/, Str, :string_single
108
+ rule %r/\|\|\|/, Str, :string_block
109
109
 
110
- rule /\$/, Keyword
110
+ rule %r/\$/, Keyword
111
111
 
112
112
  rule identifier do |m|
113
113
  if self.class.keywords.include? m[0]
@@ -125,27 +125,27 @@ module Rouge
125
125
  end
126
126
 
127
127
  state :string do
128
- rule /\\([\\\/bfnrt]|(u[0-9a-fA-F]{4}))/, Str::Escape
128
+ rule %r/\\([\\\/bfnrt]|(u[0-9a-fA-F]{4}))/, Str::Escape
129
129
  end
130
130
 
131
131
  state :string_double do
132
132
  mixin :string
133
- rule /\\"/, Str::Escape
134
- rule /"/, Str, :pop!
135
- rule /[^\\"]+/, Str
133
+ rule %r/\\"/, Str::Escape
134
+ rule %r/"/, Str, :pop!
135
+ rule %r/[^\\"]+/, Str
136
136
  end
137
137
 
138
138
  state :string_single do
139
139
  mixin :string
140
- rule /\\'/, Str::Escape
141
- rule /'/, Str, :pop!
142
- rule /[^\\']+/, Str
140
+ rule %r/\\'/, Str::Escape
141
+ rule %r/'/, Str, :pop!
142
+ rule %r/[^\\']+/, Str
143
143
  end
144
144
 
145
145
  state :string_block do
146
146
  mixin :string
147
- rule /\|\|\|/, Str, :pop!
148
- rule /.*/, Str
147
+ rule %r/\|\|\|/, Str, :pop!
148
+ rule %r/.*/, Str
149
149
  end
150
150
  end
151
151
  end
@@ -19,21 +19,21 @@ module Rouge
19
19
 
20
20
  state :root do
21
21
 
22
- rule /<%--/, Comment, :jsp_comment
22
+ rule %r/<%--/, Comment, :jsp_comment
23
23
 
24
- rule /<%@\s*(#{directives.join('|')})\s*/, Name::Tag, :jsp_directive
24
+ rule %r/<%@\s*(#{directives.join('|')})\s*/, Name::Tag, :jsp_directive
25
25
 
26
- rule /<jsp:directive\.(#{directives.join('|')})/, Name::Tag, :jsp_directive2
26
+ rule %r/<jsp:directive\.(#{directives.join('|')})/, Name::Tag, :jsp_directive2
27
27
 
28
- rule /<jsp:(#{actions.join('|')})>/, Name::Tag, :jsp_expression
28
+ rule %r/<jsp:(#{actions.join('|')})>/, Name::Tag, :jsp_expression
29
29
 
30
30
  # start of tag, e.g. <c:if>
31
- rule /<[a-zA-Z]*:[a-zA-Z]*\s*/, Name::Tag, :jsp_tag
31
+ rule %r/<[a-zA-Z]*:[a-zA-Z]*\s*/, Name::Tag, :jsp_tag
32
32
 
33
33
  # end of tag, e.g. </c:if>
34
- rule /<\/[a-zA-Z]*:[a-zA-Z]*>/, Name::Tag
34
+ rule %r(</[a-zA-Z]*:[a-zA-Z]*>), Name::Tag
35
35
 
36
- rule /<%[!=]?/, Name::Tag, :jsp_expression2
36
+ rule %r/<%[!=]?/, Name::Tag, :jsp_expression2
37
37
 
38
38
  # fallback to HTML
39
39
  rule(/(.+?)(?=(<%|<\/?[a-zA-Z]*:))/m) { delegate parent }
@@ -41,78 +41,78 @@ module Rouge
41
41
  end
42
42
 
43
43
  state :jsp_comment do
44
- rule /(--%>)/, Comment, :pop!
45
- rule /./m, Comment
44
+ rule %r/(--%>)/, Comment, :pop!
45
+ rule %r/./m, Comment
46
46
  end
47
47
 
48
48
  state :jsp_directive do
49
- rule /(%>)/, Name::Tag, :pop!
49
+ rule %r/(%>)/, Name::Tag, :pop!
50
50
  mixin :attributes
51
51
  rule(/(.+?)(?=%>)/m) { delegate parent }
52
52
  end
53
53
 
54
54
  state :jsp_directive2 do
55
- rule /(\/>)/, Name::Tag, :pop!
55
+ rule %r!(/>)!, Name::Tag, :pop!
56
56
  mixin :attributes
57
57
  rule(/(.+?)(?=\/>)/m) { delegate parent }
58
58
  end
59
59
 
60
60
  state :jsp_expression do
61
- rule /<\/jsp:(#{actions.join('|')})>/, Name::Tag, :pop!
61
+ rule %r/<\/jsp:(#{actions.join('|')})>/, Name::Tag, :pop!
62
62
  mixin :attributes
63
63
  rule(/[^<\/]+/) { delegate @java }
64
64
  end
65
65
 
66
66
  state :jsp_expression2 do
67
- rule /%>/, Name::Tag, :pop!
67
+ rule %r/%>/, Name::Tag, :pop!
68
68
  rule(/[^%>]+/) { delegate @java }
69
69
  end
70
70
 
71
71
  state :jsp_tag do
72
- rule /\/?>/, Name::Tag, :pop!
72
+ rule %r/\/?>/, Name::Tag, :pop!
73
73
  mixin :attributes
74
74
  rule(/(.+?)(?=\/?>)/m) { delegate parent }
75
75
  end
76
76
 
77
77
  state :attributes do
78
- rule /\s*[a-zA-Z0-9_:-]+\s*=\s*/m, Name::Attribute, :attr
78
+ rule %r/\s*[a-zA-Z0-9_:-]+\s*=\s*/m, Name::Attribute, :attr
79
79
  end
80
80
 
81
81
  state :attr do
82
- rule /"/ do
82
+ rule %r/"/ do
83
83
  token Str
84
84
  goto :double_quotes
85
85
  end
86
86
 
87
- rule /'/ do
87
+ rule %r/'/ do
88
88
  token Str
89
89
  goto :single_quotes
90
90
  end
91
91
 
92
- rule /[^\s>]+/, Str, :pop!
92
+ rule %r/[^\s>]+/, Str, :pop!
93
93
  end
94
94
 
95
95
  state :double_quotes do
96
- rule /"/, Str, :pop!
97
- rule /\$\{/, Str::Interpol, :jsp_interp
98
- rule /[^"]+/, Str
96
+ rule %r/"/, Str, :pop!
97
+ rule %r/\$\{/, Str::Interpol, :jsp_interp
98
+ rule %r/[^"]+/, Str
99
99
  end
100
100
 
101
101
  state :single_quotes do
102
- rule /'/, Str, :pop!
103
- rule /\$\{/, Str::Interpol, :jsp_interp
104
- rule /[^']+/, Str
102
+ rule %r/'/, Str, :pop!
103
+ rule %r/\$\{/, Str::Interpol, :jsp_interp
104
+ rule %r/[^']+/, Str
105
105
  end
106
106
 
107
107
  state :jsp_interp do
108
- rule /\}/, Str::Interpol, :pop!
109
- rule /'/, Literal, :jsp_interp_literal_start
108
+ rule %r/\}/, Str::Interpol, :pop!
109
+ rule %r/'/, Literal, :jsp_interp_literal_start
110
110
  rule(/[^'\}]+/) { delegate @java }
111
111
  end
112
112
 
113
113
  state :jsp_interp_literal_start do
114
- rule /'/, Literal, :pop!
115
- rule /[^']*/, Literal
114
+ rule %r/'/, Literal, :pop!
115
+ rule %r/[^']*/, Literal
116
116
  end
117
117
 
118
118
  end
@@ -29,7 +29,7 @@ module Rouge
29
29
  start { @html = HTML.new(options) }
30
30
 
31
31
  state :jsx_tags do
32
- rule /</, Punctuation, :jsx_element
32
+ rule %r/</, Punctuation, :jsx_element
33
33
  end
34
34
 
35
35
  state :jsx_internal do
@@ -38,12 +38,12 @@ module Rouge
38
38
  goto :jsx_end_tag
39
39
  end
40
40
 
41
- rule /{/ do
41
+ rule %r/{/ do
42
42
  token Str::Interpol
43
43
  start_embed!
44
44
  end
45
45
 
46
- rule /[^<>{]+/ do
46
+ rule %r/[^<>{]+/ do
47
47
  delegate @html
48
48
  end
49
49
 
@@ -56,29 +56,29 @@ module Rouge
56
56
 
57
57
  state :jsx_tag do
58
58
  mixin :comments_and_whitespace
59
- rule /#{id}/ do |m|
59
+ rule %r/#{id}/ do |m|
60
60
  token tag_token(m[0])
61
61
  end
62
62
 
63
- rule /[.]/, Punctuation
63
+ rule %r/[.]/, Punctuation
64
64
  end
65
65
 
66
66
  state :jsx_end_tag do
67
67
  mixin :jsx_tag
68
- rule />/, Punctuation, :pop!
68
+ rule %r/>/, Punctuation, :pop!
69
69
  end
70
70
 
71
71
  state :jsx_element do
72
- rule /#{id}=/, Name::Attribute, :jsx_attribute
72
+ rule %r/#{id}=/, Name::Attribute, :jsx_attribute
73
73
  mixin :jsx_tag
74
- rule />/ do token Punctuation; goto :jsx_internal end
74
+ rule %r/>/ do token Punctuation; goto :jsx_internal end
75
75
  rule %r(/>), Punctuation, :pop!
76
76
  end
77
77
 
78
78
  state :jsx_attribute do
79
- rule /"(\\[\\"]|[^"])*"/, Str::Double, :pop!
80
- rule /'(\\[\\']|[^'])*'/, Str::Single, :pop!
81
- rule /{/ do
79
+ rule %r/"(\\[\\"]|[^"])*"/, Str::Double, :pop!
80
+ rule %r/'(\\[\\']|[^'])*'/, Str::Single, :pop!
81
+ rule %r/{/ do
82
82
  token Str::Interpol
83
83
  pop!
84
84
  start_embed!
@@ -86,15 +86,15 @@ module Rouge
86
86
  end
87
87
 
88
88
  state :jsx_embed_root do
89
- rule /[.][.][.]/, Punctuation
90
- rule /}/, Str::Interpol, :pop!
89
+ rule %r/[.][.][.]/, Punctuation
90
+ rule %r/}/, Str::Interpol, :pop!
91
91
  mixin :jsx_embed
92
92
  end
93
93
 
94
94
  state :jsx_embed do
95
- rule /{/ do delegate @embed; push :jsx_embed end
96
- rule /}/ do delegate @embed; pop! end
97
- rule /[^{}]+/ do
95
+ rule %r/{/ do delegate @embed; push :jsx_embed end
96
+ rule %r/}/ do delegate @embed; pop! end
97
+ rule %r/[^{}]+/ do
98
98
  delegate @embed
99
99
  end
100
100
  end
@@ -179,34 +179,34 @@ module Rouge
179
179
  | !== | =>
180
180
  /x
181
181
 
182
- PUNCTUATION = / [ \[ \] { } \( \) , ; ] /x
182
+ PUNCTUATION = /[\[\]{}\(\),;]/
183
183
 
184
184
 
185
185
  state :root do
186
- rule /\n/, Text
187
- rule /[^\S\n]+/, Text
188
- rule /#=/, Comment::Multiline, :blockcomment
189
- rule /#.*$/, Comment
186
+ rule %r/\n/, Text
187
+ rule %r/[^\S\n]+/, Text
188
+ rule %r/#=/, Comment::Multiline, :blockcomment
189
+ rule %r/#.*$/, Comment
190
190
  rule OPERATORS, Operator
191
- rule /\\\n/, Text
192
- rule /\\/, Text
191
+ rule %r/\\\n/, Text
192
+ rule %r/\\/, Text
193
193
 
194
194
 
195
195
  # functions and macros
196
- rule /(function|macro)((?:\s|\\\s)+)/ do
196
+ rule %r/(function|macro)((?:\s|\\\s)+)/ do
197
197
  groups Keyword, Name::Function
198
198
  push :funcname
199
199
  end
200
200
 
201
201
  # types
202
- rule /((mutable )?struct|(abstract|primitive) type)((?:\s|\\\s)+)/ do
202
+ rule %r/((mutable )?struct|(abstract|primitive) type)((?:\s|\\\s)+)/ do
203
203
  groups Keyword, Name::Class
204
204
  push :typename
205
205
  end
206
206
  rule TYPES, Keyword::Type
207
207
 
208
208
  # keywords
209
- rule /(local|global|const)\b/, Keyword::Declaration
209
+ rule %r/(local|global|const)\b/, Keyword::Declaration
210
210
  rule KEYWORDS, Keyword
211
211
 
212
212
  # TODO: end is a builtin when inside of an indexing expression
@@ -215,75 +215,75 @@ module Rouge
215
215
  # TODO: symbols
216
216
 
217
217
  # backticks
218
- rule /`.*?`/, Literal::String::Backtick
218
+ rule %r/`.*?`/, Literal::String::Backtick
219
219
 
220
220
  # chars
221
- rule /'(\\.|\\[0-7]{1,3}|\\x[a-fA-F0-9]{1,3}|\\u[a-fA-F0-9]{1,4}|\\U[a-fA-F0-9]{1,6}|[^\\\'\n])'/, Literal::String::Char
221
+ rule %r/'(\\.|\\[0-7]{1,3}|\\x[a-fA-F0-9]{1,3}|\\u[a-fA-F0-9]{1,4}|\\U[a-fA-F0-9]{1,6}|[^\\\'\n])'/, Literal::String::Char
222
222
 
223
223
  # try to match trailing transpose
224
- rule /(?<=[.\w)\]])\'+/, Operator
224
+ rule %r/(?<=[.\w)\]])\'+/, Operator
225
225
 
226
226
  # strings
227
227
  # TODO: triple quoted string literals
228
228
  # TODO: Detect string interpolation
229
- rule /(?:[IL])"/, Literal::String, :string
230
- rule /[E]?"/, Literal::String, :string
229
+ rule %r/(?:[IL])"/, Literal::String, :string
230
+ rule %r/[E]?"/, Literal::String, :string
231
231
 
232
232
  # names
233
- rule /@[\w.]+/, Name::Decorator
234
- rule /(?:[a-zA-Z_\u00A1-\uffff]|[\u1000-\u10ff])(?:[a-zA-Z_0-9\u00A1-\uffff]|[\u1000-\u10ff])*!*/, Name
233
+ rule %r/@[\w.]+/, Name::Decorator
234
+ rule %r/(?:[a-zA-Z_\u00A1-\uffff]|[\u1000-\u10ff])(?:[a-zA-Z_0-9\u00A1-\uffff]|[\u1000-\u10ff])*!*/, Name
235
235
 
236
236
  rule PUNCTUATION, Other
237
237
 
238
238
  # numbers
239
- rule /(\d+(_\d+)+\.\d*|\d*\.\d+(_\d+)+)([eEf][+-]?[0-9]+)?/, Literal::Number::Float
240
- rule /(\d+\.\d*|\d*\.\d+)([eEf][+-]?[0-9]+)?/, Literal::Number::Float
241
- rule /\d+(_\d+)+[eEf][+-]?[0-9]+/, Literal::Number::Float
242
- rule /\d+[eEf][+-]?[0-9]+/, Literal::Number::Float
243
- rule /0b[01]+(_[01]+)+/, Literal::Number::Bin
244
- rule /0b[01]+/, Literal::Number::Bin
245
- rule /0o[0-7]+(_[0-7]+)+/, Literal::Number::Oct
246
- rule /0o[0-7]+/, Literal::Number::Oct
247
- rule /0x[a-fA-F0-9]+(_[a-fA-F0-9]+)+/, Literal::Number::Hex
248
- rule /0x[a-fA-F0-9]+/, Literal::Number::Hex
249
- rule /\d+(_\d+)+/, Literal::Number::Integer
250
- rule /\d+/, Literal::Number::Integer
239
+ rule %r/(\d+(_\d+)+\.\d*|\d*\.\d+(_\d+)+)([eEf][+-]?[0-9]+)?/, Literal::Number::Float
240
+ rule %r/(\d+\.\d*|\d*\.\d+)([eEf][+-]?[0-9]+)?/, Literal::Number::Float
241
+ rule %r/\d+(_\d+)+[eEf][+-]?[0-9]+/, Literal::Number::Float
242
+ rule %r/\d+[eEf][+-]?[0-9]+/, Literal::Number::Float
243
+ rule %r/0b[01]+(_[01]+)+/, Literal::Number::Bin
244
+ rule %r/0b[01]+/, Literal::Number::Bin
245
+ rule %r/0o[0-7]+(_[0-7]+)+/, Literal::Number::Oct
246
+ rule %r/0o[0-7]+/, Literal::Number::Oct
247
+ rule %r/0x[a-fA-F0-9]+(_[a-fA-F0-9]+)+/, Literal::Number::Hex
248
+ rule %r/0x[a-fA-F0-9]+/, Literal::Number::Hex
249
+ rule %r/\d+(_\d+)+/, Literal::Number::Integer
250
+ rule %r/\d+/, Literal::Number::Integer
251
251
  end
252
252
 
253
253
 
254
254
  state :funcname do
255
- rule /[a-zA-Z_]\w*/, Name::Function, :pop!
256
- rule /\([^\s\w{]{1,2}\)/, Operator, :pop!
257
- rule /[^\s\w{]{1,2}/, Operator, :pop!
255
+ rule %r/[a-zA-Z_]\w*/, Name::Function, :pop!
256
+ rule %r/\([^\s\w{]{1,2}\)/, Operator, :pop!
257
+ rule %r/[^\s\w{]{1,2}/, Operator, :pop!
258
258
  end
259
259
 
260
260
  state :typename do
261
- rule /[a-zA-Z_]\w*/, Name::Class, :pop!
261
+ rule %r/[a-zA-Z_]\w*/, Name::Class, :pop!
262
262
  end
263
263
 
264
264
  state :stringescape do
265
- rule /\\([\\abfnrtv"\']|\n|N\{.*?\}|u[a-fA-F0-9]{4}|U[a-fA-F0-9]{8}|x[a-fA-F0-9]{2}|[0-7]{1,3})/,
265
+ rule %r/\\([\\abfnrtv"\']|\n|N\{.*?\}|u[a-fA-F0-9]{4}|U[a-fA-F0-9]{8}|x[a-fA-F0-9]{2}|[0-7]{1,3})/,
266
266
  Literal::String::Escape
267
267
  end
268
268
 
269
269
  state :blockcomment do
270
- rule /[^=#]/, Comment::Multiline
271
- rule /#=/, Comment::Multiline, :blockcomment
272
- rule /\=#/, Comment::Multiline, :pop!
273
- rule /[=#]/, Comment::Multiline
270
+ rule %r/[^=#]/, Comment::Multiline
271
+ rule %r/#=/, Comment::Multiline, :blockcomment
272
+ rule %r/\=#/, Comment::Multiline, :pop!
273
+ rule %r/[=#]/, Comment::Multiline
274
274
  end
275
275
 
276
276
  state :string do
277
277
  mixin :stringescape
278
278
 
279
- rule /"/, Literal::String, :pop!
280
- rule /\\\\|\\"|\\\n/, Literal::String::Escape # included here for raw strings
281
- rule /\$(\(\w+\))?[-#0 +]*([0-9]+|[*])?(\.([0-9]+|[*]))?/, Literal::String::Interpol
282
- rule /[^\\"$]+/, Literal::String
279
+ rule %r/"/, Literal::String, :pop!
280
+ rule %r/\\\\|\\"|\\\n/, Literal::String::Escape # included here for raw strings
281
+ rule %r/\$(\(\w+\))?[-#0 +]*([0-9]+|[*])?(\.([0-9]+|[*]))?/, Literal::String::Interpol
282
+ rule %r/[^\\"$]+/, Literal::String
283
283
  # quotes, dollar signs, and backslashes must be parsed one at a time
284
- rule /["\\]/, Literal::String
284
+ rule %r/["\\]/, Literal::String
285
285
  # unhandled string formatting sign
286
- rule /\$/, Literal::String
286
+ rule %r/\$/, Literal::String
287
287
  end
288
288
  end
289
289
  end