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
@@ -29,54 +29,54 @@ module Rouge
29
29
  start { @shell.reset! }
30
30
 
31
31
  state :root do
32
- rule /\s+/, 'Text'
32
+ rule /\s+/, Text
33
33
 
34
- rule /#.*?\n/, 'Comment'
34
+ rule /#.*?\n/, Comment
35
35
 
36
36
  rule /(export)(\s+)(?=[a-zA-Z0-9_\${}\t -]+\n)/ do
37
- group 'Keyword'; group 'Text'
37
+ group Keyword; group Text
38
38
  push :export
39
39
  end
40
40
 
41
- rule /export\s+/, 'Keyword'
41
+ rule /export\s+/, Keyword
42
42
 
43
43
  # assignment
44
44
  rule /([a-zA-Z0-9_${}.-]+)(\s*)([!?:+]?=)/m do |m|
45
- token 'Name.Variable', m[1]
46
- token 'Text', m[2]
47
- token 'Operator', m[3]
45
+ token Name::Variable, m[1]
46
+ token Text, m[2]
47
+ token Operator, m[3]
48
48
  push :shell_line
49
49
  end
50
50
 
51
- rule /"(\\\\|\\.|[^"\\])*"/, 'Literal.String.Double'
52
- rule /'(\\\\|\\.|[^'\\])*'/, 'Literal.String.Single'
51
+ rule /"(\\\\|\\.|[^"\\])*"/, Str::Double
52
+ rule /'(\\\\|\\.|[^'\\])*'/, Str::Single
53
53
  rule /([^\n:]+)(:+)([ \t]*)/ do
54
- group 'Name.Label'; group 'Operator'; group 'Text'
54
+ group Name::Label; group Operator; group Text
55
55
  push :block_header
56
56
  end
57
57
  end
58
58
 
59
59
  state :export do
60
- rule /[\w\${}-]/, 'Name.Variable'
61
- rule /\n/, 'Text', :pop!
62
- rule /\s+/, 'Text'
60
+ rule /[\w\${}-]/, Name::Variable
61
+ rule /\n/, Text, :pop!
62
+ rule /\s+/, Text
63
63
  end
64
64
 
65
65
  state :block_header do
66
- rule /[^,\\\n#]+/, 'Name.Function'
67
- rule /,/, 'Punctuation'
68
- rule /#.*?/, 'Comment'
69
- rule /\\\n/, 'Text'
70
- rule /\\./, 'Text'
66
+ rule /[^,\\\n#]+/, Name::Function
67
+ rule /,/, Punctuation
68
+ rule /#.*?/, Comment
69
+ rule /\\\n/, Text
70
+ rule /\\./, Text
71
71
  rule /\n/ do
72
- token 'Text'
73
- pop!; push :block_body
72
+ token Text
73
+ goto :block_body
74
74
  end
75
75
  end
76
76
 
77
77
  state :block_body do
78
78
  rule /(\t[\t ]*)([@-]?)/ do |m|
79
- group 'Text'; group 'Punctuation'
79
+ group Text; group Punctuation
80
80
  push :shell_line
81
81
  end
82
82
 
@@ -85,11 +85,11 @@ module Rouge
85
85
 
86
86
  state :shell do
87
87
  # macro interpolation
88
- rule /\$\(\s*[a-z_]\w*\s*\)/i, 'Name.Variable'
88
+ rule /\$\(\s*[a-z_]\w*\s*\)/i, Name::Variable
89
89
  # $(shell ...)
90
90
  rule /(\$\()(\s*)(shell)(\s+)/m do
91
- group 'Name.Function'; group 'Text'
92
- group 'Name.Builtin'; group 'Text'
91
+ group Name::Function; group Text
92
+ group Name::Builtin; group Text
93
93
  push :shell_expr
94
94
  end
95
95
 
@@ -101,12 +101,12 @@ module Rouge
101
101
 
102
102
  state :shell_expr do
103
103
  rule(/\(/) { delegate @shell; push }
104
- rule /\)/, 'Name.Variable', :pop!
104
+ rule /\)/, Name::Variable, :pop!
105
105
  mixin :shell
106
106
  end
107
107
 
108
108
  state :shell_line do
109
- rule /\n/, 'Text', :pop!
109
+ rule /\n/, Text, :pop!
110
110
  mixin :shell
111
111
  end
112
112
  end
@@ -20,44 +20,44 @@ module Rouge
20
20
  # YAML frontmatter
21
21
  rule(/\A(---\s*\n.*?\n?)^(---\s*$\n?)/m) { delegate YAML }
22
22
 
23
- rule /\\./, 'Literal.String.Escape'
23
+ rule /\\./, Str::Escape
24
24
 
25
- rule /^[\S ]+\n(?:---*)\n/, 'Generic.Heading'
26
- rule /^[\S ]+\n(?:===*)\n/, 'Generic.Subheading'
25
+ rule /^[\S ]+\n(?:---*)\n/, Generic::Heading
26
+ rule /^[\S ]+\n(?:===*)\n/, Generic::Subheading
27
27
 
28
- rule /^#(?=[^#]).*?$/, 'Generic.Heading'
29
- rule /^##*.*?$/, 'Generic.Subheading'
28
+ rule /^#(?=[^#]).*?$/, Generic::Heading
29
+ rule /^##*.*?$/, Generic::Subheading
30
30
 
31
31
  # TODO: syntax highlight the code block, github style
32
32
  rule /(\n[ \t]*)(```|~~~)(.*?)(\n.*?)(\2)/m do |m|
33
33
  sublexer = Lexer.find_fancy(m[3].strip, m[4])
34
- sublexer ||= Text.new(:token => 'Literal.String.Backtick')
34
+ sublexer ||= Text.new(:token => Str::Backtick)
35
35
 
36
- token 'Text', m[1]
37
- token 'Punctuation', m[2]
38
- token 'Name.Label', m[3]
36
+ token Text, m[1]
37
+ token Punctuation, m[2]
38
+ token Name::Label, m[3]
39
39
  delegate sublexer, m[4]
40
- token 'Punctuation', m[5]
40
+ token Punctuation, m[5]
41
41
  end
42
42
 
43
- rule /\n\n(( |\t).*?\n|\n)+/, 'Literal.String.Backtick'
43
+ rule /\n\n(( |\t).*?\n|\n)+/, Str::Backtick
44
44
 
45
- rule /(`+)#{edot}*\1/, 'Literal.String.Backtick'
45
+ rule /(`+)#{edot}*\1/, Str::Backtick
46
46
 
47
47
  # various uses of * are in order of precedence
48
48
 
49
49
  # line breaks
50
- rule /^(\s*[*]){3,}\s*$/, 'Punctuation'
51
- rule /^(\s*[-]){3,}\s*$/, 'Punctuation'
50
+ rule /^(\s*[*]){3,}\s*$/, Punctuation
51
+ rule /^(\s*[-]){3,}\s*$/, Punctuation
52
52
 
53
53
  # bulleted lists
54
- rule /^\s*[*+-](?=\s)/, 'Punctuation'
54
+ rule /^\s*[*+-](?=\s)/, Punctuation
55
55
 
56
56
  # numbered lists
57
- rule /^\s*\d+\./, 'Punctuation'
57
+ rule /^\s*\d+\./, Punctuation
58
58
 
59
59
  # blockquotes
60
- rule /^\s*>.*?$/, 'Generic.Traceback'
60
+ rule /^\s*>.*?$/, Generic::Traceback
61
61
 
62
62
  # link references
63
63
  # [foo]: bar "baz"
@@ -66,9 +66,9 @@ module Rouge
66
66
  (\[) (#{edot}+?) (\]) # the reference
67
67
  (\s*) (:) # colon
68
68
  )x do
69
- group 'Text'
70
- group 'Punctuation'; group 'Literal.String.Symbol'; group 'Punctuation'
71
- group 'Text'; group 'Punctuation'
69
+ group Text
70
+ group Punctuation; group Str::Symbol; group Punctuation
71
+ group Text; group Punctuation
72
72
 
73
73
  push :title
74
74
  push :url
@@ -76,82 +76,82 @@ module Rouge
76
76
 
77
77
  # links and images
78
78
  rule /(!?\[)(#{edot}+?)(\])/ do
79
- group 'Punctuation'
80
- group 'Name.Variable'
81
- group 'Punctuation'
79
+ group Punctuation
80
+ group Name::Variable
81
+ group Punctuation
82
82
  push :link
83
83
  end
84
84
 
85
- rule /[*][*]#{edot}*?[*][*]/, 'Generic.Strong'
86
- rule /__#{edot}*?__/, 'Generic.Strong'
85
+ rule /[*][*]#{edot}*?[*][*]/, Generic::Strong
86
+ rule /__#{edot}*?__/, Generic::Strong
87
87
 
88
- rule /[*]#{edot}*?[*]/, 'Generic.Emph'
89
- rule /_#{edot}*?_/, 'Generic.Emph'
88
+ rule /[*]#{edot}*?[*]/, Generic::Emph
89
+ rule /_#{edot}*?_/, Generic::Emph
90
90
 
91
91
  # Automatic links
92
- rule /<.*?@.+[.].+>/, 'Name.Variable'
93
- rule %r[<(https?|mailto|ftp)://#{edot}*?>], 'Name.Variable'
92
+ rule /<.*?@.+[.].+>/, Name::Variable
93
+ rule %r[<(https?|mailto|ftp)://#{edot}*?>], Name::Variable
94
94
 
95
95
 
96
- rule /[^\\`\[*\n&<]+/, 'Text'
96
+ rule /[^\\`\[*\n&<]+/, Text
97
97
 
98
98
  # inline html
99
99
  rule(/&\S*;/) { delegate html }
100
100
  rule(/<#{edot}*?>/) { delegate html }
101
- rule /[&<]/, 'Text'
101
+ rule /[&<]/, Text
102
102
 
103
- rule /\n/, 'Text'
103
+ rule /\n/, Text
104
104
  end
105
105
 
106
106
  state :link do
107
107
  rule /(\[)(#{edot}*?)(\])/ do
108
- group 'Punctuation'
109
- group 'Literal.String.Symbol'
110
- group 'Punctuation'
108
+ group Punctuation
109
+ group Str::Symbol
110
+ group Punctuation
111
111
  pop!
112
112
  end
113
113
 
114
114
  rule /[(]/ do
115
- token 'Punctuation'
115
+ token Punctuation
116
116
  push :inline_title
117
117
  push :inline_url
118
118
  end
119
119
 
120
- rule /[ \t]+/, 'Text'
120
+ rule /[ \t]+/, Text
121
121
 
122
122
  rule(//) { pop! }
123
123
  end
124
124
 
125
125
  state :url do
126
- rule /[ \t]+/, 'Text'
126
+ rule /[ \t]+/, Text
127
127
 
128
128
  # the url
129
129
  rule /(<)(#{edot}*?)(>)/ do
130
- group 'Name.Tag'
131
- group 'Literal.String.Other'
132
- group 'Name.Tag'
130
+ group Name::Tag
131
+ group Str::Other
132
+ group Name::Tag
133
133
  pop!
134
134
  end
135
135
 
136
- rule /\S+/, 'Literal.String.Other', :pop!
136
+ rule /\S+/, Str::Other, :pop!
137
137
  end
138
138
 
139
139
  state :title do
140
- rule /"#{edot}*?"/, 'Name.Namespace'
141
- rule /'#{edot}*?'/, 'Name.Namespace'
142
- rule /[(]#{edot}*?[)]/, 'Name.Namespace'
143
- rule /\s*(?=["'()])/, 'Text'
140
+ rule /"#{edot}*?"/, Name::Namespace
141
+ rule /'#{edot}*?'/, Name::Namespace
142
+ rule /[(]#{edot}*?[)]/, Name::Namespace
143
+ rule /\s*(?=["'()])/, Text
144
144
  rule(//) { pop! }
145
145
  end
146
146
 
147
147
  state :inline_title do
148
- rule /[)]/, 'Punctuation', :pop!
148
+ rule /[)]/, Punctuation, :pop!
149
149
  mixin :title
150
150
  end
151
151
 
152
152
  state :inline_url do
153
- rule /[^<\s)]+/, 'Literal.String.Other', :pop!
154
- rule /\s+/m, 'Text'
153
+ rule /[^<\s)]+/, Str::Other, :pop!
154
+ rule /\s+/m, Text
155
155
  mixin :url
156
156
  end
157
157
  end
@@ -10,59 +10,59 @@ module Rouge
10
10
 
11
11
  state :root do
12
12
  rule /(include)(\s+)([^\s;]+)/ do
13
- group 'Keyword'; group 'Text'; group 'Name'
13
+ group Keyword; group Text; group Name
14
14
  end
15
15
 
16
- rule id, 'Keyword', :statement
16
+ rule id, Keyword, :statement
17
17
 
18
18
  mixin :base
19
19
  end
20
20
 
21
21
  state :block do
22
- rule /}/, 'Punctuation', :pop!
23
- rule id, 'Keyword.Namespace', :statement
22
+ rule /}/, Punctuation, :pop!
23
+ rule id, Keyword::Namespace, :statement
24
24
  mixin :base
25
25
  end
26
26
 
27
27
  state :statement do
28
28
  rule /{/ do
29
- token 'Punctuation'; pop!; push :block
29
+ token Punctuation; pop!; push :block
30
30
  end
31
31
 
32
- rule /;/, 'Punctuation', :pop!
32
+ rule /;/, Punctuation, :pop!
33
33
 
34
34
  mixin :base
35
35
  end
36
36
 
37
37
  state :base do
38
- rule /\s+/, 'Text'
38
+ rule /\s+/, Text
39
39
 
40
- rule /#.*?\n/, 'Comment.Single'
41
- rule /(?:on|off)\b/, 'Name.Constant'
42
- rule /[$][\w-]+/, 'Name.Variable'
40
+ rule /#.*?\n/, Comment::Single
41
+ rule /(?:on|off)\b/, Name::Constant
42
+ rule /[$][\w-]+/, Name::Variable
43
43
 
44
44
  # host/port
45
45
  rule /([a-z0-9.-]+)(:)([0-9]+)/i do
46
- group 'Name.Function'; group 'Punctuation'
47
- group 'Literal.Number.Integer'
46
+ group Name::Function; group Punctuation
47
+ group Num::Integer
48
48
  end
49
49
 
50
50
  # mimetype
51
- rule %r([a-z-]+/[a-z-]+)i, 'Name.Class'
51
+ rule %r([a-z-]+/[a-z-]+)i, Name::Class
52
52
 
53
- rule /[0-9]+[kmg]?\b/i, 'Literal.Number.Integer'
53
+ rule /[0-9]+[kmg]?\b/i, Num::Integer
54
54
  rule /(~)(\s*)([^\s{]+)/ do
55
- group 'Punctuation'; group 'Text'; group 'Literal.String.Regex'
55
+ group Punctuation; group Text; group Str::Regex
56
56
  end
57
57
 
58
- rule /[:=~]/, 'Punctuation'
58
+ rule /[:=~]/, Punctuation
59
59
 
60
60
  # pathname
61
- rule %r(/#{id}?), 'Name'
61
+ rule %r(/#{id}?), Name
62
62
 
63
- rule /[^#\s;{}$\\]+/, 'Literal.String' # catchall
63
+ rule /[^#\s;{}$\\]+/, Str # catchall
64
64
 
65
- rule /[$;]/, 'Text'
65
+ rule /[$;]/, Text
66
66
  end
67
67
  end
68
68
  end
@@ -46,7 +46,7 @@ module Rouge
46
46
  utime values vec wait waitpid wantarray warn write
47
47
  )
48
48
 
49
- re_tok = 'Literal.String.Regex'
49
+ re_tok = Str::Regex
50
50
 
51
51
  state :balanced_regex do
52
52
  rule %r(/(\\\\|\\/|[^/])*/[egimosx]*)m, re_tok, :pop!
@@ -62,19 +62,19 @@ module Rouge
62
62
  end
63
63
 
64
64
  state :root do
65
- rule /#.*?$/, 'Comment.Single'
66
- rule /^=[a-zA-Z0-9]+\s+.*?\n=cut/, 'Comment.Multiline'
67
- rule /(?:#{keywords.join('|')})\b/, 'Keyword'
65
+ rule /#.*?$/, Comment::Single
66
+ rule /^=[a-zA-Z0-9]+\s+.*?\n=cut/, Comment::Multiline
67
+ rule /(?:#{keywords.join('|')})\b/, Keyword
68
68
 
69
69
  rule /(format)(\s+)([a-zA-Z0-9_]+)(\s*)(=)(\s*\n)/ do
70
- group 'Keyword'; group 'Text'
71
- group 'Name'; group 'Text'
72
- group 'Punctuation'; group 'Text'
70
+ group Keyword; group Text
71
+ group Name; group Text
72
+ group Punctuation; group Text
73
73
 
74
74
  push :format
75
75
  end
76
76
 
77
- rule /(?:eq|lt|gt|le|ge|ne|not|and|or|cmp)\b/, 'Operator.Word'
77
+ rule /(?:eq|lt|gt|le|ge|ne|not|and|or|cmp)\b/, Operator::Word
78
78
 
79
79
  # common delimiters
80
80
  rule %r(s/(\\\\|\\/|[^/])*/(\\\\|\\/|[^/])*/[egimosx]*), re_tok
@@ -94,92 +94,91 @@ module Rouge
94
94
  rule %r(((?<==~)|(?<=\())\s*/(\\\\|\\/|[^/])*/[gcimosx]*),
95
95
  re_tok, :balanced_regex
96
96
 
97
- rule /\s+/, 'Text'
98
- rule /(?:#{builtins.join('|')})\b/, 'Name.Builtin'
97
+ rule /\s+/, Text
98
+ rule /(?:#{builtins.join('|')})\b/, Name::Builtin
99
99
  rule /((__(DATA|DIE|WARN)__)|(STD(IN|OUT|ERR)))\b/,
100
- 'Name.Builtin.Pseudo'
100
+ Name::Builtin::Pseudo
101
101
 
102
- rule /<<([\'"]?)([a-zA-Z_][a-zA-Z0-9_]*)\1;?\n.*?\n\2\n/m,
103
- 'Literal.String'
102
+ rule /<<([\'"]?)([a-zA-Z_][a-zA-Z0-9_]*)\1;?\n.*?\n\2\n/m, Str
104
103
 
105
- rule /__END__\b/, 'Comment.Preproc', :end_part
106
- rule /\$\^[ADEFHILMOPSTWX]/, 'Name.Variable.Global'
107
- rule /\$[\\"\[\]'&`+*.,;=%~?@$!<>(^\|\/-](?!\w)/, 'Name.Variable.Global'
108
- rule /[$@%#]+/, 'Name.Variable', :varname
104
+ rule /__END__\b/, Comment::Preproc, :end_part
105
+ rule /\$\^[ADEFHILMOPSTWX]/, Name::Variable::Global
106
+ rule /\$[\\"'\[\]&`+*.,;=%~?@$!<>(^\|\/-](?!\w)/, Name::Variable::Global
107
+ rule /[$@%#]+/, Name::Variable, :varname
109
108
 
110
- rule /0_?[0-7]+(_[0-7]+)*/, 'Literal.Number.Oct'
111
- rule /0x[0-9A-Fa-f]+(_[0-9A-Fa-f]+)*/, 'Literal.Number.Hex'
112
- rule /0b[01]+(_[01]+)*/, 'Literal.Number.Bin'
109
+ rule /0_?[0-7]+(_[0-7]+)*/, Num::Oct
110
+ rule /0x[0-9A-Fa-f]+(_[0-9A-Fa-f]+)*/, Num::Hex
111
+ rule /0b[01]+(_[01]+)*/, Num::Bin
113
112
  rule /(\d*(_\d*)*\.\d+(_\d*)*|\d+(_\d*)*\.\d+(_\d*)*)(e[+-]?\d+)?/i,
114
- 'Literal.Number.Float'
115
- rule /\d+(_\d*)*e[+-]?\d+(_\d*)*/i, 'Literal.Number.Float'
116
- rule /\d+(_\d+)*/, 'Literal.Number.Integer'
113
+ Num::Float
114
+ rule /\d+(_\d*)*e[+-]?\d+(_\d*)*/i, Num::Float
115
+ rule /\d+(_\d+)*/, Num::Integer
117
116
 
118
- rule /'(\\\\|\\'|[^'])*'/, 'Literal.String'
119
- rule /"(\\\\|\\"|[^"])*"/, 'Literal.String'
120
- rule /`(\\\\|\\`|[^`])*`/, 'Literal.String.Backtick'
117
+ rule /'(\\\\|\\'|[^'])*'/, Str
118
+ rule /"(\\\\|\\"|[^"])*"/, Str
119
+ rule /`(\\\\|\\`|[^`])*`/, Str::Backtick
121
120
  rule /<([^\s>]+)>/, re_tok
122
- rule /(q|qq|qw|qr|qx)\{/, 'Literal.String.Other', :cb_string
123
- rule /(q|qq|qw|qr|qx)\(/, 'Literal.String.Other', :rb_string
124
- rule /(q|qq|qw|qr|qx)\[/, 'Literal.String.Other', :sb_string
125
- rule /(q|qq|qw|qr|qx)</, 'Literal.String.Other', :lt_string
126
- rule /(q|qq|qw|qr|qx)([^a-zA-Z0-9])(.|\n)*?\2/, 'Literal.String.Other'
127
-
128
- rule /package\s+/, 'Keyword', :modulename
129
- rule /sub\s+/, 'Keyword', :funcname
121
+ rule /(q|qq|qw|qr|qx)\{/, Str::Other, :cb_string
122
+ rule /(q|qq|qw|qr|qx)\(/, Str::Other, :rb_string
123
+ rule /(q|qq|qw|qr|qx)\[/, Str::Other, :sb_string
124
+ rule /(q|qq|qw|qr|qx)</, Str::Other, :lt_string
125
+ rule /(q|qq|qw|qr|qx)([^a-zA-Z0-9])(.|\n)*?\2/, Str::Other
126
+
127
+ rule /package\s+/, Keyword, :modulename
128
+ rule /sub\s+/, Keyword, :funcname
130
129
  rule /\[\]|\*\*|::|<<|>>|>=|<=|<=>|={3}|!=|=~|!~|&&?|\|\||\.{1,3}/,
131
- 'Operator'
132
- rule /[-+\/*%=<>&^\|!\\~]=?/, 'Operator'
133
- rule /[()\[\]:;,<>\/?{}]/, 'Punctuation'
130
+ Operator
131
+ rule /[-+\/*%=<>&^\|!\\~]=?/, Operator
132
+ rule /[()\[\]:;,<>\/?{}]/, Punctuation
134
133
  rule(/(?=\w)/) { push :name }
135
134
  end
136
135
 
137
136
  state :format do
138
- rule /\.\n/, 'Literal.String.Interpol', :pop!
139
- rule /.*?\n/, 'Literal.String.Interpol'
137
+ rule /\.\n/, Str::Interpol, :pop!
138
+ rule /.*?\n/, Str::Interpol
140
139
  end
141
140
 
142
141
  state :name_common do
143
- rule /\w+::/, 'Name.Namespace'
144
- rule /[\w:]+/, 'Name.Variable', :pop!
142
+ rule /\w+::/, Name::Namespace
143
+ rule /[\w:]+/, Name::Variable, :pop!
145
144
  end
146
145
 
147
146
  state :varname do
148
- rule /\s+/, 'Text'
149
- rule /\{/, 'Punctuation', :pop! # hash syntax
150
- rule /\)|,/, 'Punctuation', :pop! # arg specifier
147
+ rule /\s+/, Text
148
+ rule /\{/, Punctuation, :pop! # hash syntax
149
+ rule /\)|,/, Punctuation, :pop! # arg specifier
151
150
  mixin :name_common
152
151
  end
153
152
 
154
153
  state :name do
155
154
  mixin :name_common
156
- rule /[A-Z_]+(?=[^a-zA-Z0-9_])/, 'Name.Constant', :pop!
155
+ rule /[A-Z_]+(?=[^a-zA-Z0-9_])/, Name::Constant, :pop!
157
156
  rule(/(?=\W)/) { pop! }
158
157
  end
159
158
 
160
159
  state :modulename do
161
- rule /[a-z_]\w*/i, 'Name.Namespace', :pop!
160
+ rule /[a-z_]\w*/i, Name::Namespace, :pop!
162
161
  end
163
162
 
164
163
  state :funcname do
165
- rule /[a-zA-Z_]\w*[!?]?/, 'Name.Function'
166
- rule /\s+/, 'Text'
164
+ rule /[a-zA-Z_]\w*[!?]?/, Name::Function
165
+ rule /\s+/, Text
167
166
 
168
167
  # argument declaration
169
168
  rule /(\([$@%]*\))(\s*)/ do
170
- group 'Punctuation'
171
- group 'Text'
169
+ group Punctuation
170
+ group Text
172
171
  end
173
172
 
174
- rule /.*?{/, 'Punctuation', :pop!
175
- rule /;/, 'Punctuation', :pop!
173
+ rule /.*?{/, Punctuation, :pop!
174
+ rule /;/, Punctuation, :pop!
176
175
  end
177
176
 
178
177
  [[:cb, '\{', '\}'],
179
178
  [:rb, '\(', '\)'],
180
179
  [:sb, '\[', '\]'],
181
180
  [:lt, '<', '>']].each do |name, open, close|
182
- tok = 'Literal.String.Other'
181
+ tok = Str::Other
183
182
  state :"#{name}_string" do
184
183
  rule /\\[#{open}#{close}\\]/, tok
185
184
  rule /\\/, tok
@@ -191,7 +190,7 @@ module Rouge
191
190
 
192
191
  state :end_part do
193
192
  # eat the rest of the stream
194
- rule /.+/m, 'Comment.Preproc', :pop!
193
+ rule /.+/m, Comment::Preproc, :pop!
195
194
  end
196
195
  end
197
196
  end