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
@@ -38,34 +38,34 @@ module Rouge
38
38
  end
39
39
 
40
40
  state :strings do
41
- rule /\\./, Str::Escape
42
- rule /\$\{/ do
41
+ rule %r/\\./, Str::Escape
42
+ rule %r/\$\{/ do
43
43
  token Keyword
44
44
  push :interpolation
45
45
  end
46
46
  end
47
47
 
48
48
  state :dq do
49
- rule /[^\\"\$]+/, Str::Double
49
+ rule %r/[^\\"\$]+/, Str::Double
50
50
  mixin :strings
51
- rule /"/, Str::Double, :pop!
51
+ rule %r/"/, Str::Double, :pop!
52
52
  end
53
53
 
54
54
  state :sq do
55
- rule /[^\\'\$]+/, Str::Single
55
+ rule %r/[^\\'\$]+/, Str::Single
56
56
  mixin :strings
57
- rule /'/, Str::Single, :pop!
57
+ rule %r/'/, Str::Single, :pop!
58
58
  end
59
59
 
60
60
  state :heredoc do
61
- rule /\n/, Str::Heredoc, :heredoc_nl
62
- rule /[^$\n\$]+/, Str::Heredoc
63
- rule /[$]/, Str::Heredoc
61
+ rule %r/\n/, Str::Heredoc, :heredoc_nl
62
+ rule %r/[^$\n]+/, Str::Heredoc
63
+ rule %r/[$]/, Str::Heredoc
64
64
  mixin :strings
65
65
  end
66
66
 
67
67
  state :interpolation do
68
- rule /\}/ do
68
+ rule %r/\}/ do
69
69
  token Keyword
70
70
  pop!
71
71
  end
@@ -77,12 +77,12 @@ module Rouge
77
77
 
78
78
  state :expression do
79
79
  mixin :primitives
80
- rule /\s+/, Text
80
+ rule %r/\s+/, Text
81
81
 
82
82
  rule %r(\+\+ | -- | ~ | && | \|\| | \\(?=\n) | << | >>>? | == | != )x, Operator
83
83
  rule %r([-<>+*%&|\^/!=?:]=?), Operator
84
- rule /[(\[,]/, Punctuation
85
- rule /[)\].]/, Punctuation
84
+ rule %r/[(\[,]/, Punctuation
85
+ rule %r/[)\].]/, Punctuation
86
86
 
87
87
  rule id do |m|
88
88
  if self.class.keywords.include? m[0]
@@ -19,50 +19,50 @@ module Rouge
19
19
  command = /\\([a-z]+|\s+|.)/i
20
20
 
21
21
  state :general do
22
- rule /%.*$/, Comment
23
- rule /[{}&_^]/, Punctuation
22
+ rule %r/%.*$/, Comment
23
+ rule %r/[{}&_^]/, Punctuation
24
24
  end
25
25
 
26
26
  state :root do
27
- rule /\\\[/, Punctuation, :displaymath
28
- rule /\\\(/, Punctuation, :inlinemath
29
- rule /\$\$/, Punctuation, :displaymath
30
- rule /\$/, Punctuation, :inlinemath
31
- rule /\\(begin|end)\{.*?\}/, Name::Tag
27
+ rule %r/\\\[/, Punctuation, :displaymath
28
+ rule %r/\\\(/, Punctuation, :inlinemath
29
+ rule %r/\$\$/, Punctuation, :displaymath
30
+ rule %r/\$/, Punctuation, :inlinemath
31
+ rule %r/\\(begin|end)\{.*?\}/, Name::Tag
32
32
 
33
- rule /(\\verb)\b(\S)(.*?)(\2)/ do |m|
33
+ rule %r/(\\verb)\b(\S)(.*?)(\2)/ do |m|
34
34
  groups Name::Builtin, Keyword::Pseudo, Str::Other, Keyword::Pseudo
35
35
  end
36
36
 
37
37
  rule command, Keyword, :command
38
38
  mixin :general
39
- rule /[^\\$%&_^{}]+/, Text
39
+ rule %r/[^\\$%&_^{}]+/, Text
40
40
  end
41
41
 
42
42
  state :math do
43
43
  rule command, Name::Variable
44
44
  mixin :general
45
- rule /[0-9]+/, Num
46
- rule /[-=!+*\/()\[\]]/, Operator
47
- rule /[^=!+*\/()\[\]\\$%&_^{}0-9-]+/, Name::Builtin
45
+ rule %r/[0-9]+/, Num
46
+ rule %r/[-=!+*\/()\[\]]/, Operator
47
+ rule %r/[^=!+*\/()\[\]\\$%&_^{}0-9-]+/, Name::Builtin
48
48
  end
49
49
 
50
50
  state :inlinemath do
51
- rule /\\\)/, Punctuation, :pop!
52
- rule /\$/, Punctuation, :pop!
51
+ rule %r/\\\)/, Punctuation, :pop!
52
+ rule %r/\$/, Punctuation, :pop!
53
53
  mixin :math
54
54
  end
55
55
 
56
56
  state :displaymath do
57
- rule /\\\]/, Punctuation, :pop!
58
- rule /\$\$/, Punctuation, :pop!
59
- rule /\$/, Name::Builtin
57
+ rule %r/\\\]/, Punctuation, :pop!
58
+ rule %r/\$\$/, Punctuation, :pop!
59
+ rule %r/\$/, Name::Builtin
60
60
  mixin :math
61
61
  end
62
62
 
63
63
  state :command do
64
- rule /\[.*?\]/, Name::Attribute
65
- rule /\*/, Keyword
64
+ rule %r/\[.*?\]/, Name::Attribute
65
+ rule %r/\*/, Keyword
66
66
  rule(//) { pop! }
67
67
  end
68
68
  end
@@ -11,25 +11,25 @@ module Rouge
11
11
  filenames '*.toml'
12
12
  mimetypes 'text/x-toml'
13
13
 
14
- identifier = /[\w.\S]+/
14
+ identifier = /\S+/
15
15
 
16
16
  state :basic do
17
- rule /\s+/, Text
18
- rule /#.*?$/, Comment
19
- rule /(true|false)/, Keyword::Constant
20
- rule /(?<!=)\s*\[[\w\d\S]+\]/, Name::Namespace
17
+ rule %r/\s+/, Text
18
+ rule %r/#.*?$/, Comment
19
+ rule %r/(true|false)/, Keyword::Constant
20
+ rule %r/(?<!=)\s*\[[\S]+\]/, Name::Namespace
21
21
 
22
- rule /\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}Z/, Literal::Date
22
+ rule %r/\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}Z/, Literal::Date
23
23
 
24
- rule /(\d+\.\d*|\d*\.\d+)([eE][+-]?[0-9]+)?j?/, Num::Float
25
- rule /\d+[eE][+-]?[0-9]+j?/, Num::Float
26
- rule /\-?\d+/, Num::Integer
24
+ rule %r/(\d+\.\d*|\d*\.\d+)([eE][+-]?[0-9]+)?j?/, Num::Float
25
+ rule %r/\d+[eE][+-]?[0-9]+j?/, Num::Float
26
+ rule %r/\-?\d+/, Num::Integer
27
27
  end
28
28
 
29
29
  state :root do
30
30
  mixin :basic
31
31
 
32
- rule /(#{identifier})(\s*)(=)/ do
32
+ rule %r/(#{identifier})(\s*)(=)/ do
33
33
  groups Name::Property, Text, Punctuation
34
34
  push :value
35
35
  end
@@ -37,31 +37,31 @@ module Rouge
37
37
  end
38
38
 
39
39
  state :value do
40
- rule /\n/, Text, :pop!
40
+ rule %r/\n/, Text, :pop!
41
41
  mixin :content
42
42
  end
43
43
 
44
44
  state :content do
45
45
  mixin :basic
46
- rule /"/, Str, :dq
46
+ rule %r/"/, Str, :dq
47
47
  mixin :esc_str
48
- rule /\,/, Punctuation
49
- rule /\[/, Punctuation, :array
48
+ rule %r/\,/, Punctuation
49
+ rule %r/\[/, Punctuation, :array
50
50
  end
51
51
 
52
52
  state :dq do
53
- rule /"/, Str, :pop!
53
+ rule %r/"/, Str, :pop!
54
54
  mixin :esc_str
55
- rule /[^\\"]+/, Str
55
+ rule %r/[^\\"]+/, Str
56
56
  end
57
57
 
58
58
  state :esc_str do
59
- rule /\\[0t\tn\n "\\ r]/, Str::Escape
59
+ rule %r/\\[0t\tn\n "\\r]/, Str::Escape
60
60
  end
61
61
 
62
62
  state :array do
63
63
  mixin :content
64
- rule /\]/, Punctuation, :pop!
64
+ rule %r/\]/, Punctuation, :pop!
65
65
  end
66
66
  end
67
67
  end
@@ -19,77 +19,77 @@ module Rouge
19
19
  upper_id = /[A-Z][\w-]*/
20
20
 
21
21
  state :comments_and_whitespace do
22
- rule /\s+/, Text
23
- rule /#.*?$/, Comment
22
+ rule %r/\s+/, Text
23
+ rule %r/#.*?$/, Comment
24
24
  end
25
25
 
26
26
  state :root do
27
27
  mixin :comments_and_whitespace
28
28
 
29
- rule /@#{id}/, Keyword
29
+ rule %r/@#{id}/, Keyword
30
30
 
31
31
 
32
- rule /(\\#{id})([{])/ do
32
+ rule %r/(\\#{id})([{])/ do
33
33
  groups Name::Function, Str
34
34
  push :nested_string
35
35
  end
36
36
 
37
- rule /([+]#{id})([{])/ do
37
+ rule %r/([+]#{id})([{])/ do
38
38
  groups Name::Decorator, Str
39
39
  push :nested_string
40
40
  end
41
41
 
42
- rule /\\#{id}/, Name::Function
43
- rule /[+]#{id}/, Name::Decorator
42
+ rule %r/\\#{id}/, Name::Function
43
+ rule %r/[+]#{id}/, Name::Decorator
44
44
 
45
- rule /"[{]/, Str, :dqi
46
- rule /"/, Str, :dq
45
+ rule %r/"[{]/, Str, :dqi
46
+ rule %r/"/, Str, :dq
47
47
 
48
- rule /'{/, Str, :nested_string
49
- rule /'#{id}/, Str
48
+ rule %r/'{/, Str, :nested_string
49
+ rule %r/'#{id}/, Str
50
50
 
51
- rule /[.]#{id}/, Name::Tag
52
- rule /[$]#{id}?/, Name::Variable
53
- rule /-#{id}:?/, Name::Label
54
- rule /%#{id}/, Name::Function
55
- rule /`#{id}/, Operator::Word
51
+ rule %r/[.]#{id}/, Name::Tag
52
+ rule %r/[$]#{id}?/, Name::Variable
53
+ rule %r/-#{id}:?/, Name::Label
54
+ rule %r/%#{id}/, Name::Function
55
+ rule %r/`#{id}/, Operator::Word
56
56
 
57
- rule /[?~%._>,!\[\]:{}()=;\/-]/, Punctuation
57
+ rule %r/[?~%._>,!\[\]:{}()=;\/-]/, Punctuation
58
58
 
59
- rule /[0-9]+([.][0-9]+)?/, Num
59
+ rule %r/[0-9]+([.][0-9]+)?/, Num
60
60
 
61
- rule /#{id}/, Name
61
+ rule %r/#{id}/, Name
62
62
 
63
- rule /</, Comment::Preproc, :angle_brackets
63
+ rule %r/</, Comment::Preproc, :angle_brackets
64
64
  end
65
65
 
66
66
  state :dq do
67
- rule /[^\\"]+/, Str
68
- rule /"/, Str, :pop!
69
- rule /\\./, Str::Escape
67
+ rule %r/[^\\"]+/, Str
68
+ rule %r/"/, Str, :pop!
69
+ rule %r/\\./, Str::Escape
70
70
  end
71
71
 
72
72
  state :dqi do
73
- rule /[$][(]/, Str::Interpol, :interp_root
74
- rule /[{]/, Str, :dqi
75
- rule /[}]/, Str, :pop!
76
- rule /[^{}$]+/, Str
77
- rule /./, Str
73
+ rule %r/[$][(]/, Str::Interpol, :interp_root
74
+ rule %r/[{]/, Str, :dqi
75
+ rule %r/[}]/, Str, :pop!
76
+ rule %r/[^{}$]+/, Str
77
+ rule %r/./, Str
78
78
  end
79
79
 
80
80
  state :interp_root do
81
- rule /[)]/, Str::Interpol, :pop!
81
+ rule %r/[)]/, Str::Interpol, :pop!
82
82
  mixin :interp
83
83
  end
84
84
 
85
85
  state :interp do
86
- rule /[(]/, Punctuation, :interp
87
- rule /[)]/, Punctuation, :pop!
86
+ rule %r/[(]/, Punctuation, :interp
87
+ rule %r/[)]/, Punctuation, :pop!
88
88
  mixin :root
89
89
  end
90
90
 
91
91
  state :nested_string do
92
- rule /\\./, Str::Escape
92
+ rule %r/\\./, Str::Escape
93
93
  rule(/{/) { token Str; push :nested_string }
94
94
  rule(/}/) { token Str; pop! }
95
95
  rule(/[^{}\\]+/) { token Str }
@@ -97,10 +97,10 @@ module Rouge
97
97
 
98
98
  state :angle_brackets do
99
99
  mixin :comments_and_whitespace
100
- rule />/, Comment::Preproc, :pop!
101
- rule /[*:]/, Punctuation
102
- rule /#{upper_id}/, Keyword::Type
103
- rule /#{id}/, Name::Variable
100
+ rule %r/>/, Comment::Preproc, :pop!
101
+ rule %r/[*:]/, Punctuation
102
+ rule %r/#{upper_id}/, Keyword::Type
103
+ rule %r/#{id}/, Name::Variable
104
104
  end
105
105
  end
106
106
  end
@@ -7,57 +7,54 @@ module Rouge
7
7
  title "Turtle/TriG"
8
8
  desc "Terse RDF Triple Language, TriG"
9
9
  tag 'turtle'
10
- filenames *%w(*.ttl *.trig)
11
- mimetypes *%w(
12
- text/turtle
13
- application/trig
14
- )
10
+ filenames '*.ttl', '*.trig'
11
+ mimetypes 'text/turtle', 'application/trig'
15
12
 
16
13
  state :root do
17
- rule /@base\b/, Keyword::Declaration
18
- rule /@prefix\b/, Keyword::Declaration
19
- rule /true\b/, Keyword::Constant
20
- rule /false\b/, Keyword::Constant
14
+ rule %r/@base\b/, Keyword::Declaration
15
+ rule %r/@prefix\b/, Keyword::Declaration
16
+ rule %r/true\b/, Keyword::Constant
17
+ rule %r/false\b/, Keyword::Constant
21
18
 
22
- rule /""".*?"""/m, Literal::String
23
- rule /"([^"\\]|\\.)*"/, Literal::String
24
- rule /'''.*?'''/m, Literal::String
25
- rule /'([^'\\]|\\.)*'/, Literal::String
19
+ rule %r/""".*?"""/m, Literal::String
20
+ rule %r/"([^"\\]|\\.)*"/, Literal::String
21
+ rule %r/'''.*?'''/m, Literal::String
22
+ rule %r/'([^'\\]|\\.)*'/, Literal::String
26
23
 
27
- rule /#.*$/, Comment::Single
24
+ rule %r/#.*$/, Comment::Single
28
25
 
29
- rule /@[^\s,.; ]+/, Name::Attribute
26
+ rule %r/@[^\s,.;]+/, Name::Attribute
30
27
 
31
- rule /[+-]?[0-9]+\.[0-9]*E[+-]?[0-9]+/, Literal::Number::Float
32
- rule /[+-]?\.[0-9]+E[+-]?[0-9]+/, Literal::Number::Float
33
- rule /[+-]?[0-9]+E[+-]?[0-9]+/, Literal::Number::Float
28
+ rule %r/[+-]?[0-9]+\.[0-9]*E[+-]?[0-9]+/, Literal::Number::Float
29
+ rule %r/[+-]?\.[0-9]+E[+-]?[0-9]+/, Literal::Number::Float
30
+ rule %r/[+-]?[0-9]+E[+-]?[0-9]+/, Literal::Number::Float
34
31
 
35
- rule /[+-]?[0-9]*\.[0-9]+?/, Literal::Number::Float
32
+ rule %r/[+-]?[0-9]*\.[0-9]+?/, Literal::Number::Float
36
33
 
37
- rule /[+-]?[0-9]+/, Literal::Number::Integer
34
+ rule %r/[+-]?[0-9]+/, Literal::Number::Integer
38
35
 
39
- rule /\./, Punctuation
40
- rule /,/, Punctuation
41
- rule /;/, Punctuation
42
- rule /\(/, Punctuation
43
- rule /\)/, Punctuation
44
- rule /\{/, Punctuation
45
- rule /\}/, Punctuation
46
- rule /\[/, Punctuation
47
- rule /\]/, Punctuation
48
- rule /\^\^/, Punctuation
36
+ rule %r/\./, Punctuation
37
+ rule %r/,/, Punctuation
38
+ rule %r/;/, Punctuation
39
+ rule %r/\(/, Punctuation
40
+ rule %r/\)/, Punctuation
41
+ rule %r/\{/, Punctuation
42
+ rule %r/\}/, Punctuation
43
+ rule %r/\[/, Punctuation
44
+ rule %r/\]/, Punctuation
45
+ rule %r/\^\^/, Punctuation
49
46
 
50
- rule /<[^>]*>/, Name::Label
47
+ rule %r/<[^>]*>/, Name::Label
51
48
 
52
- rule /base\b/i, Keyword::Declaration
53
- rule /prefix\b/i, Keyword::Declaration
54
- rule /GRAPH\b/, Keyword
55
- rule /a\b/, Keyword
49
+ rule %r/base\b/i, Keyword::Declaration
50
+ rule %r/prefix\b/i, Keyword::Declaration
51
+ rule %r/GRAPH\b/, Keyword
52
+ rule %r/a\b/, Keyword
56
53
 
57
- rule /\s+/, Text::Whitespace
54
+ rule %r/\s+/, Text::Whitespace
58
55
 
59
- rule /[^:;<>#\@"\(\).\[\]\{\} ]+:/, Name::Namespace
60
- rule /[^:;<>#\@"\(\).\[\]\{\} ]+/, Name
56
+ rule %r/[^:;<>#\@"\(\).\[\]\{\} ]+:/, Name::Namespace
57
+ rule %r/[^:;<>#\@"\(\).\[\]\{\} ]+/, Name
61
58
  end
62
59
  end
63
60
  end
@@ -29,7 +29,7 @@ module Rouge
29
29
  )
30
30
 
31
31
  state :whitespace do
32
- rule /\s+/m, Text
32
+ rule %r/\s+/m, Text
33
33
  rule %r(//.*?$), Comment::Single
34
34
  rule %r(/[*].*?[*]/)m, Comment::Multiline
35
35
  end
@@ -37,30 +37,30 @@ module Rouge
37
37
  state :root do
38
38
  mixin :whitespace
39
39
 
40
- rule /^\s*\[.*?\]/, Name::Attribute
40
+ rule %r/^\s*\[.*?\]/, Name::Attribute
41
41
 
42
- rule /(<\[)\s*(#{id}:)?/, Keyword
43
- rule /\]>/, Keyword
42
+ rule %r/(<\[)\s*(#{id}:)?/, Keyword
43
+ rule %r/\]>/, Keyword
44
44
 
45
- rule /[~!%^&*()+=|\[\]{}:;,.<>\/?-]/, Punctuation
46
- rule /@"(\\.|.)*?"/, Str
47
- rule /"(\\.|.)*?["\n]/, Str
48
- rule /'(\\.|.)'/, Str::Char
49
- rule /0x[0-9a-f]+[lu]?/i, Num
45
+ rule %r/[~!%^&*()+=|\[\]{}:;,.<>\/?-]/, Punctuation
46
+ rule %r/@"(\\.|.)*?"/, Str
47
+ rule %r/"(\\.|.)*?["\n]/, Str
48
+ rule %r/'(\\.|.)'/, Str::Char
49
+ rule %r/0x[0-9a-f]+[lu]?/i, Num
50
50
  rule %r(
51
51
  [0-9]
52
52
  ([.][0-9]*)? # decimal
53
53
  (e[+-][0-9]+)? # exponent
54
54
  [fldu]? # type
55
55
  )ix, Num
56
- rule /\b(#{keywords.join('|')})\b/, Keyword
57
- rule /\b(#{keywords_type.join('|')})\b/, Keyword::Type
58
- rule /class|struct/, Keyword, :class
59
- rule /namespace|using/, Keyword, :namespace
60
- rule /#{id}(?=\s*[(])/, Name::Function
56
+ rule %r/\b(#{keywords.join('|')})\b/, Keyword
57
+ rule %r/\b(#{keywords_type.join('|')})\b/, Keyword::Type
58
+ rule %r/class|struct/, Keyword, :class
59
+ rule %r/namespace|using/, Keyword, :namespace
60
+ rule %r/#{id}(?=\s*[(])/, Name::Function
61
61
  rule id, Name
62
62
 
63
- rule /#.*/, Comment::Preproc
63
+ rule %r/#.*/, Comment::Preproc
64
64
  end
65
65
 
66
66
  state :class do
@@ -70,8 +70,8 @@ module Rouge
70
70
 
71
71
  state :namespace do
72
72
  mixin :whitespace
73
- rule /(?=[(])/, Text, :pop!
74
- rule /(#{id}|[.])+/, Name::Namespace, :pop!
73
+ rule %r/(?=[(])/, Text, :pop!
74
+ rule %r/(#{id}|[.])+/, Name::Namespace, :pop!
75
75
  end
76
76
  end
77
77
  end