rouge 0.4.0 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (69) hide show
  1. data/Gemfile +2 -0
  2. data/bin/rougify +1 -1
  3. data/lib/rouge/demos/{text → plaintext} +0 -0
  4. data/lib/rouge/formatters/html.rb +13 -8
  5. data/lib/rouge/formatters/terminal256.rb +15 -11
  6. data/lib/rouge/lexer.rb +3 -1
  7. data/lib/rouge/lexers/c.rb +65 -55
  8. data/lib/rouge/lexers/clojure.rb +19 -19
  9. data/lib/rouge/lexers/coffeescript.rb +42 -42
  10. data/lib/rouge/lexers/common_lisp.rb +49 -48
  11. data/lib/rouge/lexers/conf.rb +6 -6
  12. data/lib/rouge/lexers/cpp.rb +48 -48
  13. data/lib/rouge/lexers/csharp.rb +25 -25
  14. data/lib/rouge/lexers/css.rb +32 -33
  15. data/lib/rouge/lexers/diff.rb +8 -8
  16. data/lib/rouge/lexers/elixir.rb +30 -30
  17. data/lib/rouge/lexers/erb.rb +5 -5
  18. data/lib/rouge/lexers/erlang.rb +38 -38
  19. data/lib/rouge/lexers/factor.rb +56 -56
  20. data/lib/rouge/lexers/gherkin.rb +27 -27
  21. data/lib/rouge/lexers/go.rb +21 -21
  22. data/lib/rouge/lexers/groovy.rb +32 -32
  23. data/lib/rouge/lexers/haml.rb +35 -35
  24. data/lib/rouge/lexers/handlebars.rb +27 -27
  25. data/lib/rouge/lexers/haskell.rb +78 -79
  26. data/lib/rouge/lexers/html.rb +28 -28
  27. data/lib/rouge/lexers/http.rb +13 -13
  28. data/lib/rouge/lexers/ini.rb +13 -13
  29. data/lib/rouge/lexers/io.rb +19 -19
  30. data/lib/rouge/lexers/java.rb +29 -29
  31. data/lib/rouge/lexers/javascript.rb +49 -52
  32. data/lib/rouge/lexers/literate_haskell.rb +5 -5
  33. data/lib/rouge/lexers/llvm.rb +14 -14
  34. data/lib/rouge/lexers/lua.rb +33 -33
  35. data/lib/rouge/lexers/make.rb +26 -26
  36. data/lib/rouge/lexers/markdown.rb +49 -49
  37. data/lib/rouge/lexers/nginx.rb +19 -19
  38. data/lib/rouge/lexers/perl.rb +53 -54
  39. data/lib/rouge/lexers/php.rb +42 -43
  40. data/lib/rouge/lexers/{text.rb → plain_text.rb} +3 -2
  41. data/lib/rouge/lexers/prolog.rb +19 -19
  42. data/lib/rouge/lexers/puppet.rb +40 -40
  43. data/lib/rouge/lexers/python.rb +63 -63
  44. data/lib/rouge/lexers/r.rb +15 -15
  45. data/lib/rouge/lexers/racket.rb +29 -29
  46. data/lib/rouge/lexers/ruby.rb +94 -97
  47. data/lib/rouge/lexers/rust.rb +37 -37
  48. data/lib/rouge/lexers/sass.rb +15 -15
  49. data/lib/rouge/lexers/sass/common.rb +144 -136
  50. data/lib/rouge/lexers/scheme.rb +25 -25
  51. data/lib/rouge/lexers/scss.rb +7 -7
  52. data/lib/rouge/lexers/sed.rb +39 -39
  53. data/lib/rouge/lexers/shell.rb +45 -45
  54. data/lib/rouge/lexers/smalltalk.rb +36 -36
  55. data/lib/rouge/lexers/sql.rb +27 -27
  56. data/lib/rouge/lexers/tcl.rb +34 -34
  57. data/lib/rouge/lexers/tex.rb +24 -24
  58. data/lib/rouge/lexers/toml.rb +18 -18
  59. data/lib/rouge/lexers/viml.rb +19 -19
  60. data/lib/rouge/lexers/xml.rb +16 -16
  61. data/lib/rouge/lexers/yaml.rb +78 -81
  62. data/lib/rouge/plugins/redcarpet.rb +1 -1
  63. data/lib/rouge/regex_lexer.rb +31 -14
  64. data/lib/rouge/template_lexer.rb +1 -1
  65. data/lib/rouge/theme.rb +12 -10
  66. data/lib/rouge/themes/thankful_eyes.rb +43 -43
  67. data/lib/rouge/token.rb +145 -148
  68. data/lib/rouge/version.rb +1 -1
  69. metadata +4 -4
@@ -58,103 +58,102 @@ module Rouge
58
58
  end
59
59
 
60
60
  state :root do
61
- rule /<\?(php|=)?/, 'Comment.Preproc', :php
61
+ rule /<\?(php|=)?/, Comment::Preproc, :php
62
62
  rule(/.*?(?=<\?)|.*/m) { delegate parent }
63
63
  end
64
64
 
65
65
  state :php do
66
- rule /\?>/, 'Comment.Preproc', :pop!
66
+ rule /\?>/, Comment::Preproc, :pop!
67
67
  # heredocs
68
- rule /<<<('?)([a-z_]\w*)\1\n.*?\n\2;?\n/im, 'Literal.String.Heredoc'
69
- rule /\s+/, 'Text'
70
- rule /#.*?\n/, 'Comment.Single'
71
- rule %r(//.*?\n), 'Comment.Single'
68
+ rule /<<<('?)([a-z_]\w*)\1\n.*?\n\2;?\n/im, Str::Heredoc
69
+ rule /\s+/, Text
70
+ rule /#.*?\n/, Comment::Single
71
+ rule %r(//.*?\n), Comment::Single
72
72
  # empty comment, otherwise seen as the start of a docstring
73
73
  rule %r(/\*\*/)
74
- rule %r(/\*\*.*?\*/)m, 'Literal.String.Doc'
75
- rule %r(/\*.*?\*/)m, 'Comment.Multiline'
74
+ rule %r(/\*\*.*?\*/)m, Str::Doc
75
+ rule %r(/\*.*?\*/)m, Comment::Multiline
76
76
  rule /(->|::)(\s*)([a-zA-Z_][a-zA-Z0-9_]*)/ do
77
- group 'Operator'; group 'Text'; group 'Name.Attribute'
77
+ group Operator; group Text; group Name::Attribute
78
78
  end
79
79
 
80
- rule /[~!%^&*+=\|:.<>\/?@-]+/, 'Operator'
81
- rule /[\[\]{}();,]+/, 'Punctuation'
82
- rule /class\b/, 'Keyword', :classname
80
+ rule /[~!%^&*+=\|:.<>\/?@-]+/, Operator
81
+ rule /[\[\]{}();,]+/, Punctuation
82
+ rule /class\b/, Keyword, :classname
83
83
  # anonymous functions
84
84
  rule /(function)(\s*)(?=\()/ do
85
- group 'Keyword'; group 'Text'
85
+ group Keyword; group Text
86
86
  end
87
87
 
88
88
  # named functions
89
89
  rule /(function)(\s+)(&?)(\s*)/ do
90
- group 'Keyword'; group 'Text'; group 'Operator'; group 'Text'
90
+ group Keyword; group Text; group Operator; group Text
91
91
  push :funcname
92
92
  end
93
93
 
94
94
  rule /(const)(\s+)([a-zA-Z_]\w*)/i do
95
- group 'Keyword'; group 'Text'; group 'Name.Constant'
95
+ group Keyword; group Text; group Name::Constant
96
96
  end
97
97
 
98
- rule /(true|false|null)\b/, 'Keyword.Constant'
99
- rule /\$\{\$+[a-z_]\w*\}/i, 'Name.Variable'
100
- rule /\$+[a-z_]\w*/i, 'Name.Variable'
98
+ rule /(true|false|null)\b/, Keyword::Constant
99
+ rule /\$\{\$+[a-z_]\w*\}/i, Name::Variable
100
+ rule /\$+[a-z_]\w*/i, Name::Variable
101
101
 
102
102
  # may be intercepted for builtin highlighting
103
103
  rule /[\\a-z_][\\\w]*/i do |m|
104
104
  name = m[0]
105
105
 
106
106
  if self.class.keywords.include? name
107
- token 'Keyword'
107
+ token Keyword
108
108
  elsif self.builtins.include? name
109
- token 'Name.Builtin'
109
+ token Name::Builtin
110
110
  else
111
- token 'Name.Other'
111
+ token Name::Other
112
112
  end
113
113
  end
114
114
 
115
- rule /(\d+\.\d*|\d*\.\d+)(e[+-]?\d+)?/i, 'Literal.Number.Float'
116
- rule /\d+e[+-]?\d+/i, 'Literal.Number.Float'
117
- rule /0[0-7]+/, 'Literal.Number.Oct'
118
- rule /0x[a-f0-9]+/i, 'Literal.Number.Hex'
119
- rule /\d+/, 'Literal.Number.Integer'
120
- rule /'([^'\\]*(?:\\.[^'\\]*)*)'/, 'Literal.String.Single'
121
- rule /`([^`\\]*(?:\\.[^`\\]*)*)`/, 'Literal.String.Backtick'
122
- rule /"/, 'Literal.String.Double', :string
115
+ rule /(\d+\.\d*|\d*\.\d+)(e[+-]?\d+)?/i, Num::Float
116
+ rule /\d+e[+-]?\d+/i, Num::Float
117
+ rule /0[0-7]+/, Num::Oct
118
+ rule /0x[a-f0-9]+/i, Num::Hex
119
+ rule /\d+/, Num::Integer
120
+ rule /'([^'\\]*(?:\\.[^'\\]*)*)'/, Str::Single
121
+ rule /`([^`\\]*(?:\\.[^`\\]*)*)`/, Str::Backtick
122
+ rule /"/, Str::Double, :string
123
123
  end
124
124
 
125
125
  state :classname do
126
- rule /\s+/, 'Text'
127
- rule /[a-z_][\\\w]*/i, 'Name.Class', :pop!
126
+ rule /\s+/, Text
127
+ rule /[a-z_][\\\w]*/i, Name::Class, :pop!
128
128
  end
129
129
 
130
130
  state :funcname do
131
- rule /[a-z_]\w*/i, 'Name.Function', :pop!
131
+ rule /[a-z_]\w*/i, Name::Function, :pop!
132
132
  end
133
133
 
134
134
  state :string do
135
- rule /"/, 'Literal.String.Double', :pop!
136
- rule /[^\\{$"]+/, 'Literal.String.Double'
135
+ rule /"/, Str::Double, :pop!
136
+ rule /[^\\{$"]+/, Str::Double
137
137
  rule /\\([nrt\"$\\]|[0-7]{1,3}|x[0-9A-Fa-f]{1,2})/,
138
- 'Literal.String.Escape'
139
- rule /\$[a-zA-Z_][a-zA-Z0-9_]*(\[\S+\]|->[a-zA-Z_][a-zA-Z0-9_]*)?/, 'Name.Variable'
138
+ Str::Escape
139
+ rule /\$[a-zA-Z_][a-zA-Z0-9_]*(\[\S+\]|->[a-zA-Z_][a-zA-Z0-9_]*)?/, Name::Variable
140
140
 
141
- lsi = 'Literal.String.Interpol'
142
- rule /\{\$\{/, lsi, :interp_double
143
- rule /\{(?=\$)/, lsi, :interp_single
141
+ rule /\{\$\{/, Str::Interpol, :interp_double
142
+ rule /\{(?=\$)/, Str::Interpol, :interp_single
144
143
  rule /(\{)(\S+)(\})/ do
145
- group lsi; group 'Name.Variable'; group lsi
144
+ group Str::Interpol; group Name::Variable; group Str::Interpol
146
145
  end
147
146
 
148
- rule /[${\\]+/, 'Literal.String.Double'
147
+ rule /[${\\]+/, Str::Double
149
148
  end
150
149
 
151
150
  state :interp_double do
152
- rule /\}\}/, 'Literal.String.Interpol', :pop!
151
+ rule /\}\}/, Str::Interpol, :pop!
153
152
  mixin :php
154
153
  end
155
154
 
156
155
  state :interp_single do
157
- rule /\}/, 'Literal.String.Interpol', :pop!
156
+ rule /\}/, Str::Interpol, :pop!
158
157
  mixin :php
159
158
  end
160
159
  end
@@ -1,9 +1,10 @@
1
1
  module Rouge
2
2
  module Lexers
3
- class Text < Lexer
3
+ class PlainText < Lexer
4
4
  desc "A boring lexer that doesn't highlight anything"
5
5
 
6
- tag 'text'
6
+ tag 'plaintext'
7
+ aliases 'text'
7
8
  filenames '*.txt'
8
9
  mimetypes 'text/plain'
9
10
 
@@ -13,35 +13,35 @@ module Rouge
13
13
  end
14
14
 
15
15
  state :basic do
16
- rule /\s+/, 'Text'
17
- rule /^#.*/, 'Comment.Single'
18
- rule /\/\*/, 'Comment.Multiline', :nested_comment
16
+ rule /\s+/, Text
17
+ rule /^#.*/, Comment::Single
18
+ rule /\/\*/, Comment::Multiline, :nested_comment
19
19
 
20
- rule /[\[\](){}|.,;!]/, 'Punctuation'
21
- rule /:-|-->/, 'Punctuation'
20
+ rule /[\[\](){}|.,;!]/, Punctuation
21
+ rule /:-|-->/, Punctuation
22
22
 
23
- rule /"[^"]*"/, 'Literal.String.Double'
23
+ rule /"[^"]*"/, Str::Double
24
24
 
25
- rule /\d+\.\d+/, 'Literal.Number.Float'
26
- rule /\d+/, 'Literal.Number'
25
+ rule /\d+\.\d+/, Num::Float
26
+ rule /\d+/, Num
27
27
  end
28
28
 
29
29
  state :atoms do
30
- rule /[[:lower:]]([_[:lower:][:digit:]])*/, 'Literal.String.Symbol'
31
- rule /'[^']*'/, 'Literal.String.Symbol'
30
+ rule /[[:lower:]]([_[:lower:][:digit:]])*/, Str::Symbol
31
+ rule /'[^']*'/, Str::Symbol
32
32
  end
33
33
 
34
34
  state :operators do
35
35
  rule /(<|>|=<|>=|==|=:=|=|\/|\/\/|\*|\+|-)(?=\s|[a-zA-Z0-9\[])/,
36
- 'Operator'
37
- rule /is/, 'Operator'
38
- rule /(mod|div|not)/, 'Operator'
39
- rule /[#&*+-.\/:<=>?@^~]+/, 'Operator'
36
+ Operator
37
+ rule /is/, Operator
38
+ rule /(mod|div|not)/, Operator
39
+ rule /[#&*+-.\/:<=>?@^~]+/, Operator
40
40
  end
41
41
 
42
42
  state :variables do
43
- rule /[A-Z]+\w*/, 'Name.Variable'
44
- rule /_[[:word:]]*/, 'Name.Variable'
43
+ rule /[A-Z]+\w*/, Name::Variable
44
+ rule /_[[:word:]]*/, Name::Variable
45
45
  end
46
46
 
47
47
  state :root do
@@ -52,9 +52,9 @@ module Rouge
52
52
  end
53
53
 
54
54
  state :nested_comment do
55
- rule /\/\*/, 'Comment.Multiline', :push
56
- rule /\s*\*[^*\/]+/, 'Comment.Multiline'
57
- rule /\*\//, 'Comment.Multiline', :pop!
55
+ rule /\/\*/, Comment::Multiline, :push
56
+ rule /\s*\*[^*\/]+/, Comment::Multiline
57
+ rule /\*\//, Comment::Multiline, :pop!
58
58
  end
59
59
  end
60
60
  end
@@ -35,91 +35,91 @@ module Rouge
35
35
  qualname = /(::)?(#{id}::)*\w+/
36
36
 
37
37
  state :whitespace do
38
- rule /\s+/m, 'Text'
39
- rule /#.*?\n/, 'Comment'
38
+ rule /\s+/m, Text
39
+ rule /#.*?\n/, Comment
40
40
  end
41
41
 
42
42
  state :root do
43
43
  mixin :whitespace
44
44
 
45
- rule /[$]#{qualname}/, 'Name.Variable'
45
+ rule /[$]#{qualname}/, Name::Variable
46
46
  rule /(#{id})(?=\s*[=+]>)/m do |m|
47
47
  if self.class.metaparameters.include? m[0]
48
- token 'Keyword.Pseudo'
48
+ token Keyword::Pseudo
49
49
  else
50
- token 'Name.Property'
50
+ token Name::Property
51
51
  end
52
52
  end
53
53
 
54
- rule /(#{qualname})(?=\s*[(])/m, 'Name.Function'
55
- rule cap_id, 'Name.Class'
54
+ rule /(#{qualname})(?=\s*[(])/m, Name::Function
55
+ rule cap_id, Name::Class
56
56
 
57
- rule /[+=|~-]>|<[|~-]/, 'Punctuation'
58
- rule /[:}();\[\]]/, 'Punctuation'
57
+ rule /[+=|~-]>|<[|~-]/, Punctuation
58
+ rule /[:}();\[\]]/, Punctuation
59
59
 
60
60
  # HACK for case statements and selectors
61
- rule /{/, 'Punctuation', :regex_allowed
62
- rule /,/, 'Punctuation', :regex_allowed
61
+ rule /{/, Punctuation, :regex_allowed
62
+ rule /,/, Punctuation, :regex_allowed
63
63
 
64
- rule /(in|and|or)\b/, 'Operator.Word'
65
- rule /[=!<>]=/, 'Operator'
66
- rule /[=!]~/, 'Operator', :regex_allowed
67
- rule %r([<>!+*/-]), 'Operator'
64
+ rule /(in|and|or)\b/, Operator::Word
65
+ rule /[=!<>]=/, Operator
66
+ rule /[=!]~/, Operator, :regex_allowed
67
+ rule %r([<>!+*/-]), Operator
68
68
 
69
69
  rule /(class|include)(\s*)(#{qualname})/ do
70
- group 'Keyword'; group 'Text'
71
- group 'Name.Class'
70
+ group Keyword; group Text
71
+ group Name::Class
72
72
  end
73
73
 
74
- rule /node\b/, 'Keyword', :regex_allowed
74
+ rule /node\b/, Keyword, :regex_allowed
75
75
 
76
- rule /'(\\[\\']|[^'])*'/m, 'Literal.String.Single'
77
- rule /"/, 'Literal.String.Double', :dquotes
76
+ rule /'(\\[\\']|[^'])*'/m, Str::Single
77
+ rule /"/, Str::Double, :dquotes
78
78
 
79
- rule /\d+([.]\d+)?(e[+-]\d+)?/, 'Literal.Number'
79
+ rule /\d+([.]\d+)?(e[+-]\d+)?/, Num
80
80
 
81
81
  # a valid regex. TODO: regexes are only allowed
82
82
  # in certain places in puppet.
83
83
  rule qualname do |m|
84
84
  if self.class.keywords.include? m[0]
85
- token 'Keyword'
85
+ token Keyword
86
86
  elsif self.class.constants.include? m[0]
87
- token 'Keyword.Constant'
87
+ token Keyword::Constant
88
88
  else
89
- token 'Name'
89
+ token Name
90
90
  end
91
91
  end
92
92
  end
93
93
 
94
94
  state :regex_allowed do
95
95
  mixin :whitespace
96
- rule %r(/), 'Literal.String.Regex', :regex
96
+ rule %r(/), Str::Regex, :regex
97
97
 
98
98
  rule(//) { pop! }
99
99
  end
100
100
 
101
101
  state :regex do
102
- rule %r(/), 'Literal.String.Regex', :pop!
103
- rule /\\./, 'Literal.String.Escape'
104
- rule /[(){}]/, 'Literal.String.Interpol'
105
- rule /\[/, 'Literal.String.Interpol', :regex_class
106
- rule /./, 'Literal.String.Regex'
102
+ rule %r(/), Str::Regex, :pop!
103
+ rule /\\./, Str::Escape
104
+ rule /[(){}]/, Str::Interpol
105
+ rule /\[/, Str::Interpol, :regex_class
106
+ rule /./, Str::Regex
107
107
  end
108
108
 
109
109
  state :regex_class do
110
- rule /\]/, 'Literal.String.Interpol', :pop!
111
- rule /(?<!\[)-(?=\])/, 'Literal.String.Regex'
112
- rule /-/, 'Literal.String.Interpol'
113
- rule /\\./, 'Literal.String.Escape'
114
- rule /[^\\\]-]+/, 'Literal.String.Regex'
110
+ rule /\]/, Str::Interpol, :pop!
111
+ rule /(?<!\[)-(?=\])/, Str::Regex
112
+ rule /-/, Str::Interpol
113
+ rule /\\./, Str::Escape
114
+ rule /[^\\\]-]+/, Str::Regex
115
115
  end
116
116
 
117
117
  state :dquotes do
118
- rule /"/, 'Literal.String.Double', :pop!
119
- rule /[^$\\"]+/m, 'Literal.String.Double'
120
- rule /\\./m, 'Literal.String.Escape'
121
- rule /[$]#{qualname}/, 'Name.Variable'
122
- rule /[$][{]#{qualname}[}]/, 'Name.Variable'
118
+ rule /"/, Str::Double, :pop!
119
+ rule /[^$\\"]+/m, Str::Double
120
+ rule /\\./m, Str::Escape
121
+ rule /[$]#{qualname}/, Name::Variable
122
+ rule /[$][{]#{qualname}[}]/, Name::Variable
123
123
  end
124
124
  end
125
125
  end
@@ -50,116 +50,116 @@ module Rouge
50
50
  identifier = /[a-z_][a-z0-9_]*/i
51
51
  dotted_identifier = /[a-z_.][a-z0-9_.]*/i
52
52
  state :root do
53
- rule /\n+/m, 'Text'
53
+ rule /\n+/m, Text
54
54
  rule /^(:)(\s*)([ru]{,2}""".*?""")/mi do
55
- group 'Punctuation'
56
- group 'Text'
57
- group 'Literal.String.Doc'
55
+ group Punctuation
56
+ group Text
57
+ group Str::Doc
58
58
  end
59
59
 
60
- rule /[^\S\n]+/, 'Text'
61
- rule /#.*$/, 'Comment'
62
- rule /[\[\]{}:(),;]/, 'Punctuation'
63
- rule /\\\n/, 'Text'
64
- rule /\\/, 'Text'
60
+ rule /[^\S\n]+/, Text
61
+ rule /#.*$/, Comment
62
+ rule /[\[\]{}:(),;]/, Punctuation
63
+ rule /\\\n/, Text
64
+ rule /\\/, Text
65
65
 
66
- rule /(in|is|and|or|not)\b/, 'Operator.Word'
67
- rule /!=|==|<<|>>|[-~+\/*%=<>&^|.]/, 'Operator'
66
+ rule /(in|is|and|or|not)\b/, Operator::Word
67
+ rule /!=|==|<<|>>|[-~+\/*%=<>&^|.]/, Operator
68
68
 
69
- rule /(?:#{keywords.join('|')})\b/, 'Keyword'
69
+ rule /(?:#{keywords.join('|')})\b/, Keyword
70
70
 
71
71
  rule /(def)((?:\s|\\\s)+)/ do
72
- group 'Keyword' # def
73
- group 'Text' # whitespae
72
+ group Keyword # def
73
+ group Text # whitespae
74
74
  push :funcname
75
75
  end
76
76
 
77
77
  rule /(class)((?:\s|\\\s)+)/ do
78
- group 'Keyword'
79
- group 'Text'
78
+ group Keyword
79
+ group Text
80
80
  push :classname
81
81
  end
82
82
 
83
83
  rule /(from)((?:\s|\\\s)+)/ do
84
- group 'Keyword.Namespace'
85
- group 'Text'
84
+ group Keyword::Namespace
85
+ group Text
86
86
  push :fromimport
87
87
  end
88
88
 
89
89
  rule /(import)((?:\s|\\\s)+)/ do
90
- group 'Keyword.Namespace'
91
- group 'Text'
90
+ group Keyword::Namespace
91
+ group Text
92
92
  push :import
93
93
  end
94
94
 
95
95
  # using negative lookbehind so we don't match property names
96
- rule /(?<!\.)(?:#{builtins.join('|')})/, 'Name.Builtin'
97
- rule /(?<!\.)(?:#{builtins_pseudo.join('|')})/, 'Name.Builtin.Pseudo'
96
+ rule /(?<!\.)(?:#{builtins.join('|')})/, Name::Builtin
97
+ rule /(?<!\.)(?:#{builtins_pseudo.join('|')})/, Name::Builtin::Pseudo
98
98
 
99
99
  # TODO: not in python 3
100
- rule /`.*?`/, 'Literal.String.Backtick'
101
- rule /(?:r|ur|ru)"""/i, 'Literal.String', :tdqs
102
- rule /(?:r|ur|ru)'''/i, 'Literal.String', :tsqs
103
- rule /(?:r|ur|ru)"/i, 'Literal.String', :dqs
104
- rule /(?:r|ur|ru)'/i, 'Literal.String', :sqs
105
- rule /u?"""/i, 'Literal.String', :escape_tdqs
106
- rule /u?'''/i, 'Literal.String', :escape_tsqs
107
- rule /u?"/i, 'Literal.String', :escape_dqs
108
- rule /u?'/i, 'Literal.String', :escape_sqs
109
-
110
- rule /@#{dotted_identifier}/i, 'Name.Decorator'
111
- rule identifier, 'Name'
112
-
113
- rule /(\d+\.\d*|\d*\.\d+)(e[+-]?[0-9]+)?/i, 'Literal.Number.Float'
114
- rule /\d+e[+-]?[0-9]+/i, 'Literal.Number.Float'
115
- rule /0[0-7]+/, 'Literal.Number.Oct'
116
- rule /0x[a-f0-9]+/i, 'Literal.Number.Hex'
117
- rule /\d+L/, 'Literal.Number.Integer.Long'
118
- rule /\d+/, 'Literal.Number.Integer'
100
+ rule /`.*?`/, Str::Backtick
101
+ rule /(?:r|ur|ru)"""/i, Str, :tdqs
102
+ rule /(?:r|ur|ru)'''/i, Str, :tsqs
103
+ rule /(?:r|ur|ru)"/i, Str, :dqs
104
+ rule /(?:r|ur|ru)'/i, Str, :sqs
105
+ rule /u?"""/i, Str, :escape_tdqs
106
+ rule /u?'''/i, Str, :escape_tsqs
107
+ rule /u?"/i, Str, :escape_dqs
108
+ rule /u?'/i, Str, :escape_sqs
109
+
110
+ rule /@#{dotted_identifier}/i, Name::Decorator
111
+ rule identifier, Name
112
+
113
+ rule /(\d+\.\d*|\d*\.\d+)(e[+-]?[0-9]+)?/i, Num::Float
114
+ rule /\d+e[+-]?[0-9]+/i, Num::Float
115
+ rule /0[0-7]+/, Num::Oct
116
+ rule /0x[a-f0-9]+/i, Num::Hex
117
+ rule /\d+L/, Num::Integer::Long
118
+ rule /\d+/, Num::Integer
119
119
  end
120
120
 
121
121
  state :funcname do
122
- rule identifier, 'Name.Function', :pop!
122
+ rule identifier, Name::Function, :pop!
123
123
  end
124
124
 
125
125
  state :classname do
126
- rule identifier, 'Name.Class', :pop!
126
+ rule identifier, Name::Class, :pop!
127
127
  end
128
128
 
129
129
  state :import do
130
130
  # non-line-terminating whitespace
131
- rule /(?:[ \t]|\\\n)+/, 'Text'
131
+ rule /(?:[ \t]|\\\n)+/, Text
132
132
 
133
- rule /as\b/, 'Keyword.Namespace'
134
- rule /,/, 'Operator'
135
- rule dotted_identifier, 'Name.Namespace'
133
+ rule /as\b/, Keyword::Namespace
134
+ rule /,/, Operator
135
+ rule dotted_identifier, Name::Namespace
136
136
  rule(//) { pop! } # anything else -> go back
137
137
  end
138
138
 
139
139
  state :fromimport do
140
140
  # non-line-terminating whitespace
141
- rule /(?:[ \t]|\\\n)+/, 'Text'
141
+ rule /(?:[ \t]|\\\n)+/, Text
142
142
 
143
- rule /import\b/, 'Keyword.Namespace', :pop!
144
- rule dotted_identifier, 'Name.Namespace'
143
+ rule /import\b/, Keyword::Namespace, :pop!
144
+ rule dotted_identifier, Name::Namespace
145
145
  end
146
146
 
147
147
  state :strings do
148
- rule /%(\([a-z0-9_]+\))?[-#0 +]*([0-9]+|[*])?(\.([0-9]+|[*]))?/i, 'Literal.String.Interpol'
148
+ rule /%(\([a-z0-9_]+\))?[-#0 +]*([0-9]+|[*])?(\.([0-9]+|[*]))?/i, Str::Interpol
149
149
  end
150
150
 
151
151
  state :strings_double do
152
- rule /[^\\"%\n]+/, 'Literal.String'
152
+ rule /[^\\"%\n]+/, Str
153
153
  mixin :strings
154
154
  end
155
155
 
156
156
  state :strings_single do
157
- rule /[^\\'%\n]+/, 'Literal.String'
157
+ rule /[^\\'%\n]+/, Str
158
158
  mixin :strings
159
159
  end
160
160
 
161
161
  state :nl do
162
- rule /\n/, 'Literal.String'
162
+ rule /\n/, Str
163
163
  end
164
164
 
165
165
  state :escape do
@@ -172,31 +172,31 @@ module Rouge
172
172
  | x[a-fA-F0-9]{2}
173
173
  | [0-7]{1,3}
174
174
  )
175
- )x, 'Literal.String.Escape'
175
+ )x, Str::Escape
176
176
  end
177
177
 
178
178
  state :dqs do
179
- rule /"/, 'Literal.String', :pop!
180
- rule /\\\\|\\"|\\\n/, 'Literal.String.Escape'
179
+ rule /"/, Str, :pop!
180
+ rule /\\\\|\\"|\\\n/, Str::Escape
181
181
  mixin :strings_double
182
182
  end
183
183
 
184
184
  state :sqs do
185
- rule /'/, 'Literal.String', :pop!
186
- rule /\\\\|\\'|\\\n/, 'Literal.String.Escape'
185
+ rule /'/, Str, :pop!
186
+ rule /\\\\|\\'|\\\n/, Str::Escape
187
187
  mixin :strings_single
188
188
  end
189
189
 
190
190
  state :tdqs do
191
- rule /"""/, 'Literal.String', :pop!
192
- rule /"/, 'Literal.String'
191
+ rule /"""/, Str, :pop!
192
+ rule /"/, Str
193
193
  mixin :strings_double
194
194
  mixin :nl
195
195
  end
196
196
 
197
197
  state :tsqs do
198
- rule /'''/, 'Literal.String', :pop!
199
- rule /'/, 'Literal.String'
198
+ rule /'''/, Str, :pop!
199
+ rule /'/, Str
200
200
  mixin :strings_single
201
201
  mixin :nl
202
202
  end