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
@@ -88,21 +88,21 @@ module Rouge
88
88
  end
89
89
 
90
90
  state :root do
91
- rule /[\s\n]+/, Text::Whitespace
92
- rule /!.*$/, Comment::Single
93
- rule /^#.*$/, Comment::Preproc
91
+ rule %r/[\s]+/, Text::Whitespace
92
+ rule %r/!.*$/, Comment::Single
93
+ rule %r/^#.*$/, Comment::Preproc
94
94
 
95
- rule /::|[()\/;,:&\[\]]/, Punctuation
95
+ rule %r/::|[()\/;,:&\[\]]/, Punctuation
96
96
 
97
97
  # TODO: This does not take into account line continuation.
98
- rule /^(\s*)([0-9]+)\b/m do |m|
98
+ rule %r/^(\s*)([0-9]+)\b/m do |m|
99
99
  token Text::Whitespace, m[1]
100
100
  token Name::Label, m[2]
101
101
  end
102
102
 
103
103
  # Format statements are quite a strange beast.
104
104
  # Better process them in their own state.
105
- rule /\b(FORMAT)(\s*)(\()/mi do |m|
105
+ rule %r/\b(FORMAT)(\s*)(\()/mi do |m|
106
106
  token Keyword, m[1]
107
107
  token Text::Whitespace, m[2]
108
108
  token Punctuation, m[3]
@@ -118,25 +118,25 @@ module Rouge
118
118
  (_#{kind_param})? # kind parameter
119
119
  )xi, Num::Float
120
120
 
121
- rule /[+-]?\d+(_#{kind_param})?/i, Num::Integer
122
- rule /B'[01]+'|B"[01]+"/i, Num::Bin
123
- rule /O'[0-7]+'|O"[0-7]+"/i, Num::Oct
124
- rule /Z'[0-9A-F]+'|Z"[0-9A-F]+"/i, Num::Hex
125
- rule /(#{kind_param}_)?'/, Str::Single, :string_single
126
- rule /(#{kind_param}_)?"/, Str::Double, :string_double
127
- rule /[.](TRUE|FALSE)[.](_#{kind_param})?/i, Keyword::Constant
121
+ rule %r/[+-]?\d+(_#{kind_param})?/i, Num::Integer
122
+ rule %r/B'[01]+'|B"[01]+"/i, Num::Bin
123
+ rule %r/O'[0-7]+'|O"[0-7]+"/i, Num::Oct
124
+ rule %r/Z'[0-9A-F]+'|Z"[0-9A-F]+"/i, Num::Hex
125
+ rule %r/(#{kind_param}_)?'/, Str::Single, :string_single
126
+ rule %r/(#{kind_param}_)?"/, Str::Double, :string_double
127
+ rule %r/[.](TRUE|FALSE)[.](_#{kind_param})?/i, Keyword::Constant
128
128
 
129
129
  rule %r{\*\*|//|==|/=|<=|>=|=>|[-+*/<>=%]}, Operator
130
- rule /\.(?:EQ|NE|LT|LE|GT|GE|NOT|AND|OR|EQV|NEQV|[A-Z]+)\./i, Operator::Word
130
+ rule %r/\.(?:EQ|NE|LT|LE|GT|GE|NOT|AND|OR|EQV|NEQV|[A-Z]+)\./i, Operator::Word
131
131
 
132
132
  # Special rules for two-word keywords and types.
133
133
  # Note: "doubleprecision" is covered by the normal keyword rule.
134
- rule /double\s+precision\b/i, Keyword::Type
135
- rule /go\s+to\b/i, Keyword
136
- rule /sync\s+(all|images|memory)\b/i, Keyword
137
- rule /error\s+stop\b/i, Keyword
134
+ rule %r/double\s+precision\b/i, Keyword::Type
135
+ rule %r/go\s+to\b/i, Keyword
136
+ rule %r/sync\s+(all|images|memory)\b/i, Keyword
137
+ rule %r/error\s+stop\b/i, Keyword
138
138
 
139
- rule /#{name}/m do |m|
139
+ rule %r/#{name}/m do |m|
140
140
  match = m[0].downcase
141
141
  if self.class.keywords.include? match
142
142
  token Keyword
@@ -152,26 +152,26 @@ module Rouge
152
152
  end
153
153
 
154
154
  state :string_single do
155
- rule /[^']+/, Str::Single
156
- rule /''/, Str::Escape
157
- rule /'/, Str::Single, :pop!
155
+ rule %r/[^']+/, Str::Single
156
+ rule %r/''/, Str::Escape
157
+ rule %r/'/, Str::Single, :pop!
158
158
  end
159
159
 
160
160
  state :string_double do
161
- rule /[^"]+/, Str::Double
162
- rule /""/, Str::Escape
163
- rule /"/, Str::Double, :pop!
161
+ rule %r/[^"]+/, Str::Double
162
+ rule %r/""/, Str::Escape
163
+ rule %r/"/, Str::Double, :pop!
164
164
  end
165
165
 
166
166
  state :format_spec do
167
- rule /'/, Str::Single, :string_single
168
- rule /"/, Str::Double, :string_double
169
- rule /\(/, Punctuation, :format_spec
170
- rule /\)/, Punctuation, :pop!
171
- rule /,/, Punctuation
172
- rule /[\s\n]+/, Text::Whitespace
167
+ rule %r/'/, Str::Single, :string_single
168
+ rule %r/"/, Str::Double, :string_double
169
+ rule %r/\(/, Punctuation, :format_spec
170
+ rule %r/\)/, Punctuation, :pop!
171
+ rule %r/,/, Punctuation
172
+ rule %r/[\s]+/, Text::Whitespace
173
173
  # Edit descriptors could be seen as a kind of "format literal".
174
- rule /[^\s'"(),]+/, Literal
174
+ rule %r/[^\s'"(),]+/, Literal
175
175
  end
176
176
  end
177
177
  end
@@ -46,11 +46,11 @@ module Rouge
46
46
  upper_id = /[A-Z][\w']*/
47
47
 
48
48
  state :root do
49
- rule /\s+/m, Text
50
- rule /false|true|[(][)]|\[\]/, Name::Builtin::Pseudo
51
- rule /#{upper_id}(?=\s*[.])/, Name::Namespace, :dotted
49
+ rule %r/\s+/m, Text
50
+ rule %r/false|true|[(][)]|\[\]/, Name::Builtin::Pseudo
51
+ rule %r/#{upper_id}(?=\s*[.])/, Name::Namespace, :dotted
52
52
  rule upper_id, Name::Class
53
- rule /[(][*](?![)])/, Comment, :comment
53
+ rule %r/[(][*](?![)])/, Comment, :comment
54
54
  rule %r(//.*?$), Comment::Single
55
55
  rule id do |m|
56
56
  match = m[0]
@@ -74,43 +74,43 @@ module Rouge
74
74
  end
75
75
  end
76
76
 
77
- rule /-?\d[\d_]*(.[\d_]*)?(e[+-]?\d[\d_]*)/i, Num::Float
78
- rule /0x\h[\h_]*/i, Num::Hex
79
- rule /0o[0-7][0-7_]*/i, Num::Oct
80
- rule /0b[01][01_]*/i, Num::Bin
81
- rule /\d[\d_]*/, Num::Integer
77
+ rule %r/-?\d[\d_]*(.[\d_]*)?(e[+-]?\d[\d_]*)/i, Num::Float
78
+ rule %r/0x\h[\h_]*/i, Num::Hex
79
+ rule %r/0o[0-7][0-7_]*/i, Num::Oct
80
+ rule %r/0b[01][01_]*/i, Num::Bin
81
+ rule %r/\d[\d_]*/, Num::Integer
82
82
 
83
- rule /'(?:(\\[\\"'ntbr ])|(\\[0-9]{3})|(\\x\h{2}))'/, Str::Char
84
- rule /'[.]'/, Str::Char
85
- rule /'/, Keyword
86
- rule /"/, Str::Double, :string
87
- rule /[~?]#{id}/, Name::Variable
83
+ rule %r/'(?:(\\[\\"'ntbr ])|(\\[0-9]{3})|(\\x\h{2}))'/, Str::Char
84
+ rule %r/'[.]'/, Str::Char
85
+ rule %r/'/, Keyword
86
+ rule %r/"/, Str::Double, :string
87
+ rule %r/[~?]#{id}/, Name::Variable
88
88
  end
89
89
 
90
90
  state :comment do
91
- rule /[^(*)]+/, Comment
91
+ rule %r/[^(*)]+/, Comment
92
92
  rule(/[(][*]/) { token Comment; push }
93
- rule /[*][)]/, Comment, :pop!
94
- rule /[(*)]/, Comment
93
+ rule %r/[*][)]/, Comment, :pop!
94
+ rule %r/[(*)]/, Comment
95
95
  end
96
96
 
97
97
  state :string do
98
- rule /[^\\"]+/, Str::Double
98
+ rule %r/[^\\"]+/, Str::Double
99
99
  mixin :escape_sequence
100
- rule /\\\n/, Str::Double
101
- rule /"/, Str::Double, :pop!
100
+ rule %r/\\\n/, Str::Double
101
+ rule %r/"/, Str::Double, :pop!
102
102
  end
103
103
 
104
104
  state :escape_sequence do
105
- rule /\\[\\"'ntbr]/, Str::Escape
106
- rule /\\\d{3}/, Str::Escape
107
- rule /\\x\h{2}/, Str::Escape
105
+ rule %r/\\[\\"'ntbr]/, Str::Escape
106
+ rule %r/\\\d{3}/, Str::Escape
107
+ rule %r/\\x\h{2}/, Str::Escape
108
108
  end
109
109
 
110
110
  state :dotted do
111
- rule /\s+/m, Text
112
- rule /[.]/, Punctuation
113
- rule /#{upper_id}(?=\s*[.])/, Name::Namespace
111
+ rule %r/\s+/m, Text
112
+ rule %r/[.]/, Punctuation
113
+ rule %r/#{upper_id}(?=\s*[.])/, Name::Namespace
114
114
  rule upper_id, Name::Class, :pop!
115
115
  rule id, Name, :pop!
116
116
  end
@@ -19,7 +19,7 @@ module Rouge
19
19
 
20
20
  # self-modifying method that loads the keywords file
21
21
  def self.keywords
22
- load Pathname.new(__FILE__).dirname.join('gherkin/keywords.rb')
22
+ load File.join(__dir__, 'gherkin/keywords.rb')
23
23
  keywords
24
24
  end
25
25
 
@@ -41,7 +41,7 @@ module Rouge
41
41
 
42
42
  state :basic do
43
43
  rule %r(#.*$), Comment
44
- rule /[ \r\t]+/, Text
44
+ rule %r/[ \r\t]+/, Text
45
45
  end
46
46
 
47
47
  state :root do
@@ -85,8 +85,8 @@ module Rouge
85
85
  end
86
86
 
87
87
  state :table_header do
88
- rule /[^|\s]+/, Name::Variable
89
- rule /\n/ do
88
+ rule %r/[^|\s]+/, Name::Variable
89
+ rule %r/\n/ do
90
90
  token Text
91
91
  goto :table
92
92
  end
@@ -95,9 +95,9 @@ module Rouge
95
95
 
96
96
  state :table do
97
97
  mixin :basic
98
- rule /\n/, Text, :table_bol
99
- rule /[|]/, Punctuation
100
- rule /[^|\s]+/, Name
98
+ rule %r/\n/, Text, :table_bol
99
+ rule %r/[|]/, Punctuation
100
+ rule %r/[^|\s]+/, Name
101
101
  end
102
102
 
103
103
  state :table_bol do
@@ -108,29 +108,29 @@ module Rouge
108
108
  state :description do
109
109
  mixin :basic
110
110
  mixin :has_examples
111
- rule /\n/, Text
111
+ rule %r/\n/, Text
112
112
  rule rest_of_line, Text
113
113
  end
114
114
 
115
115
  state :feature_description do
116
116
  mixin :basic
117
117
  mixin :has_scenarios
118
- rule /\n/, Text
118
+ rule %r/\n/, Text
119
119
  rule rest_of_line, Text
120
120
  end
121
121
 
122
122
  state :example_description do
123
123
  mixin :basic
124
124
  mixin :has_table
125
- rule /\n/, Text
125
+ rule %r/\n/, Text
126
126
  rule rest_of_line, Text
127
127
  end
128
128
 
129
129
  state :step do
130
130
  mixin :basic
131
- rule /<.*?>/, Name::Variable
132
- rule /".*?"/, Str
133
- rule /\S+/, Text
131
+ rule %r/<.*?>/, Name::Variable
132
+ rule %r/".*?"/, Str
133
+ rule %r/\S+/, Text
134
134
  rule rest_of_line, Text, :pop!
135
135
  end
136
136
  end
@@ -17,10 +17,6 @@ module Rouge
17
17
  title "GLSL"
18
18
  desc "The GLSL shader language"
19
19
 
20
- # optional comment or whitespace
21
- ws = %r((?:\s|//.*?\n|/[*].*?[*]/)+)
22
- id = /[a-zA-Z_][a-zA-Z0-9_]*/
23
-
24
20
  def self.keywords
25
21
  @keywords ||= Set.new %w(
26
22
  attribute const uniform varying
@@ -14,7 +14,7 @@ module Rouge
14
14
 
15
15
  # Characters
16
16
 
17
- WHITE_SPACE = /[\s\t\r\n]+/
17
+ WHITE_SPACE = /\s+/
18
18
 
19
19
  NEWLINE = /\n/
20
20
  UNICODE_CHAR = /[^\n]/
@@ -12,24 +12,24 @@ module Rouge
12
12
  name = /[_A-Za-z][_0-9A-Za-z]*/
13
13
 
14
14
  state :root do
15
- rule /\b(?:query|mutation|subscription)\b/, Keyword, :query_definition
16
- rule /\{/ do
15
+ rule %r/\b(?:query|mutation|subscription)\b/, Keyword, :query_definition
16
+ rule %r/\{/ do
17
17
  token Punctuation
18
18
  push :query_definition
19
19
  push :selection_set
20
20
  end
21
21
 
22
- rule /\bfragment\b/, Keyword, :fragment_definition
22
+ rule %r/\bfragment\b/, Keyword, :fragment_definition
23
23
 
24
- rule /\b(?:type|interface|enum)\b/, Keyword, :type_definition
25
- rule /\b(?:input|schema)\b/, Keyword, :type_definition
24
+ rule %r/\b(?:type|interface|enum)\b/, Keyword, :type_definition
25
+ rule %r/\b(?:input|schema)\b/, Keyword, :type_definition
26
26
 
27
- rule /\bunion\b/, Keyword, :union_definition
27
+ rule %r/\bunion\b/, Keyword, :union_definition
28
28
 
29
29
  mixin :basic
30
30
 
31
31
  # Markdown descriptions
32
- rule /(""")(.*?)(""")/m do |m|
32
+ rule %r/(""")(.*?)(""")/m do |m|
33
33
  token Str::Double, m[1]
34
34
  delegate Markdown, m[2]
35
35
  token Str::Double, m[3]
@@ -37,22 +37,22 @@ module Rouge
37
37
  end
38
38
 
39
39
  state :basic do
40
- rule /\s+/m, Text::Whitespace
41
- rule /#.*$/, Comment
40
+ rule %r/\s+/m, Text::Whitespace
41
+ rule %r/#.*$/, Comment
42
42
 
43
- rule /[!,]/, Punctuation
43
+ rule %r/[!,]/, Punctuation
44
44
  end
45
45
 
46
46
  state :has_directives do
47
- rule /(@#{name})(\s*)(\()/ do
47
+ rule %r/(@#{name})(\s*)(\()/ do
48
48
  groups Keyword, Text::Whitespace, Punctuation
49
49
  push :arguments
50
50
  end
51
- rule /@#{name}\b/, Keyword
51
+ rule %r/@#{name}\b/, Keyword
52
52
  end
53
53
 
54
54
  state :fragment_definition do
55
- rule /\bon\b/, Keyword
55
+ rule %r/\bon\b/, Keyword
56
56
 
57
57
  mixin :query_definition
58
58
  end
@@ -60,31 +60,31 @@ module Rouge
60
60
  state :query_definition do
61
61
  mixin :has_directives
62
62
 
63
- rule /\b#{name}\b/, Name
64
- rule /\(/, Punctuation, :variable_definitions
65
- rule /\{/, Punctuation, :selection_set
63
+ rule %r/\b#{name}\b/, Name
64
+ rule %r/\(/, Punctuation, :variable_definitions
65
+ rule %r/\{/, Punctuation, :selection_set
66
66
 
67
67
  mixin :basic
68
68
  end
69
69
 
70
70
  state :type_definition do
71
- rule /\bimplements\b/, Keyword
72
- rule /\b#{name}\b/, Name
73
- rule /\(/, Punctuation, :variable_definitions
74
- rule /\{/, Punctuation, :type_definition_set
71
+ rule %r/\bimplements\b/, Keyword
72
+ rule %r/\b#{name}\b/, Name
73
+ rule %r/\(/, Punctuation, :variable_definitions
74
+ rule %r/\{/, Punctuation, :type_definition_set
75
75
 
76
76
  mixin :basic
77
77
  end
78
78
 
79
79
  state :union_definition do
80
- rule /\b#{name}\b/, Name
81
- rule /\=/, Punctuation, :union_definition_variant
80
+ rule %r/\b#{name}\b/, Name
81
+ rule %r/\=/, Punctuation, :union_definition_variant
82
82
 
83
83
  mixin :basic
84
84
  end
85
85
 
86
86
  state :union_definition_variant do
87
- rule /\b#{name}\b/ do
87
+ rule %r/\b#{name}\b/ do
88
88
  token Name
89
89
  pop!
90
90
  push :union_definition_pipe
@@ -94,13 +94,13 @@ module Rouge
94
94
  end
95
95
 
96
96
  state :union_definition_pipe do
97
- rule /\|/ do
97
+ rule %r/\|/ do
98
98
  token Punctuation
99
99
  pop!
100
100
  push :union_definition_variant
101
101
  end
102
102
 
103
- rule /(?!\||\s+|#[^\n]*)/ do
103
+ rule %r/(?!\||\s+|#[^\n]*)/ do
104
104
  pop! 2
105
105
  end
106
106
 
@@ -108,62 +108,62 @@ module Rouge
108
108
  end
109
109
 
110
110
  state :type_definition_set do
111
- rule /\}/ do
111
+ rule %r/\}/ do
112
112
  token Punctuation
113
113
  pop! 2
114
114
  end
115
115
 
116
- rule /\b(#{name})(\s*)(\()/ do
116
+ rule %r/\b(#{name})(\s*)(\()/ do
117
117
  groups Name, Text::Whitespace, Punctuation
118
118
  push :variable_definitions
119
119
  end
120
- rule /\b#{name}\b/, Name
120
+ rule %r/\b#{name}\b/, Name
121
121
 
122
- rule /:/, Punctuation, :type_names
122
+ rule %r/:/, Punctuation, :type_names
123
123
 
124
124
  mixin :basic
125
125
  end
126
126
 
127
127
  state :arguments do
128
- rule /\)/ do
128
+ rule %r/\)/ do
129
129
  token Punctuation
130
130
  pop!
131
131
  end
132
132
 
133
- rule /\b#{name}\b/, Name
134
- rule /:/, Punctuation, :value
133
+ rule %r/\b#{name}\b/, Name
134
+ rule %r/:/, Punctuation, :value
135
135
 
136
136
  mixin :basic
137
137
  end
138
138
 
139
139
  state :variable_definitions do
140
- rule /\)/ do
140
+ rule %r/\)/ do
141
141
  token Punctuation
142
142
  pop!
143
143
  end
144
144
 
145
- rule /\$#{name}\b/, Name::Variable
146
- rule /\b#{name}\b/, Name
147
- rule /:/, Punctuation, :type_names
148
- rule /\=/, Punctuation, :value
145
+ rule %r/\$#{name}\b/, Name::Variable
146
+ rule %r/\b#{name}\b/, Name
147
+ rule %r/:/, Punctuation, :type_names
148
+ rule %r/\=/, Punctuation, :value
149
149
 
150
150
  mixin :basic
151
151
  end
152
152
 
153
153
  state :type_names do
154
- rule /\b(?:Int|Float|String|Boolean|ID)\b/, Name::Builtin, :pop!
155
- rule /\b#{name}\b/, Name, :pop!
154
+ rule %r/\b(?:Int|Float|String|Boolean|ID)\b/, Name::Builtin, :pop!
155
+ rule %r/\b#{name}\b/, Name, :pop!
156
156
 
157
- rule /\[/, Punctuation, :type_name_list
157
+ rule %r/\[/, Punctuation, :type_name_list
158
158
 
159
159
  mixin :basic
160
160
  end
161
161
 
162
162
  state :type_name_list do
163
- rule /\b(?:Int|Float|String|Boolean|ID)\b/, Name::Builtin
164
- rule /\b#{name}\b/, Name
163
+ rule %r/\b(?:Int|Float|String|Boolean|ID)\b/, Name::Builtin
164
+ rule %r/\b#{name}\b/, Name
165
165
 
166
- rule /\]/ do
166
+ rule %r/\]/ do
167
167
  token Punctuation
168
168
  pop! 2
169
169
  end
@@ -174,35 +174,35 @@ module Rouge
174
174
  state :selection_set do
175
175
  mixin :has_directives
176
176
 
177
- rule /\}/ do
177
+ rule %r/\}/ do
178
178
  token Punctuation
179
179
  pop!
180
180
  pop! if state?(:query_definition) || state?(:fragment_definition)
181
181
  end
182
182
 
183
- rule /\b(#{name})(\s*)(\()/ do
183
+ rule %r/\b(#{name})(\s*)(\()/ do
184
184
  groups Name, Text::Whitespace, Punctuation
185
185
  push :arguments
186
186
  end
187
187
 
188
- rule /\b(#{name})(\s*)(:)/ do
188
+ rule %r/\b(#{name})(\s*)(:)/ do
189
189
  groups Name, Text::Whitespace, Punctuation
190
190
  end
191
191
 
192
- rule /\b#{name}\b/, Name
192
+ rule %r/\b#{name}\b/, Name
193
193
 
194
- rule /(\.\.\.)(\s+)(on)\b/ do
194
+ rule %r/(\.\.\.)(\s+)(on)\b/ do
195
195
  groups Punctuation, Text::Whitespace, Keyword
196
196
  end
197
- rule /\.\.\./, Punctuation
197
+ rule %r/\.\.\./, Punctuation
198
198
 
199
- rule /\{/, Punctuation, :selection_set
199
+ rule %r/\{/, Punctuation, :selection_set
200
200
 
201
201
  mixin :basic
202
202
  end
203
203
 
204
204
  state :list do
205
- rule /\]/ do
205
+ rule %r/\]/ do
206
206
  token Punctuation
207
207
  pop!
208
208
  pop! if state?(:value)
@@ -212,13 +212,13 @@ module Rouge
212
212
  end
213
213
 
214
214
  state :object do
215
- rule /\}/ do
215
+ rule %r/\}/ do
216
216
  token Punctuation
217
217
  pop!
218
218
  pop! if state?(:value)
219
219
  end
220
220
 
221
- rule /\b(#{name})(\s*)(:)/ do
221
+ rule %r/\b(#{name})(\s*)(:)/ do
222
222
  groups Name, Text::Whitespace, Punctuation
223
223
  push :value
224
224
  end
@@ -235,17 +235,17 @@ module Rouge
235
235
  }
236
236
 
237
237
  # Multiline strings
238
- rule /""".*?"""/m, Str::Double
238
+ rule %r/""".*?"""/m, Str::Double
239
239
 
240
- rule /\$#{name}\b/, &pop_unless_list[Name::Variable]
241
- rule /\b(?:true|false|null)\b/, &pop_unless_list[Keyword::Constant]
242
- rule /[+-]?[0-9]+\.[0-9]+(?:[eE][+-]?[0-9]+)?/, &pop_unless_list[Num::Float]
243
- rule /[+-]?[1-9][0-9]*(?:[eE][+-]?[0-9]+)?/, &pop_unless_list[Num::Integer]
244
- rule /"(\\[\\"]|[^"])*"/, &pop_unless_list[Str::Double]
245
- rule /\b#{name}\b/, &pop_unless_list[Name]
240
+ rule %r/\$#{name}\b/, &pop_unless_list[Name::Variable]
241
+ rule %r/\b(?:true|false|null)\b/, &pop_unless_list[Keyword::Constant]
242
+ rule %r/[+-]?[0-9]+\.[0-9]+(?:[eE][+-]?[0-9]+)?/, &pop_unless_list[Num::Float]
243
+ rule %r/[+-]?[1-9][0-9]*(?:[eE][+-]?[0-9]+)?/, &pop_unless_list[Num::Integer]
244
+ rule %r/"(\\[\\"]|[^"])*"/, &pop_unless_list[Str::Double]
245
+ rule %r/\b#{name}\b/, &pop_unless_list[Name]
246
246
 
247
- rule /\{/, Punctuation, :object
248
- rule /\[/, Punctuation, :list
247
+ rule %r/\{/, Punctuation, :object
248
+ rule %r/\[/, Punctuation, :list
249
249
 
250
250
  mixin :basic
251
251
  end