rouge 0.3.4 → 0.3.5
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/rouge.rb +1 -0
- data/lib/rouge/lexers/cpp.rb +36 -9
- data/lib/rouge/lexers/puppet.rb +2 -2
- data/lib/rouge/lexers/ruby.rb +6 -5
- data/lib/rouge/themes/github.rb +69 -0
- data/lib/rouge/version.rb +1 -1
- metadata +3 -2
data/lib/rouge.rb
CHANGED
data/lib/rouge/lexers/cpp.rb
CHANGED
@@ -48,15 +48,39 @@ module Rouge
|
|
48
48
|
ws = %r((?:\s|//.*?\n|/[*].*?[*]/)+)
|
49
49
|
id = /[a-zA-Z_][a-zA-Z0-9]*/
|
50
50
|
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
rule
|
56
|
-
|
51
|
+
start { push :bol }
|
52
|
+
|
53
|
+
state :bol do
|
54
|
+
mixin :inline_whitespace
|
55
|
+
rule /#if\s+0/ do
|
56
|
+
token 'Comment.Preproc'
|
57
|
+
pop!; push :if_0
|
58
|
+
end
|
59
|
+
|
60
|
+
rule /#/ do
|
61
|
+
token 'Comment.Preproc'
|
62
|
+
pop!; push :macro
|
63
|
+
end
|
64
|
+
|
65
|
+
rule(//) { pop! }
|
66
|
+
end
|
67
|
+
|
68
|
+
state :inline_whitespace do
|
69
|
+
rule /[ \t\r]+/, 'Text'
|
57
70
|
rule /\\\n/, 'Text'
|
58
|
-
rule %r(/(\\\n)
|
59
|
-
|
71
|
+
rule %r(/(\\\n)?[*].*?[*](\\\n)?/)m, 'Comment.Multiline'
|
72
|
+
end
|
73
|
+
|
74
|
+
state :whitespace do
|
75
|
+
mixin :inline_whitespace
|
76
|
+
rule %r(/(\\\n)?/(\n|(.|\n)*?[^\\]\n)), 'Comment.Single', :bol
|
77
|
+
rule /\n/, 'Text', :bol
|
78
|
+
end
|
79
|
+
|
80
|
+
state :multiline_comment do
|
81
|
+
rule %r([*](\\\n)?/), 'Comment.Multiline', :pop!
|
82
|
+
rule %r([*]), 'Comment.Multiline'
|
83
|
+
rule %r([^*]+), 'Comment.Multiline'
|
60
84
|
end
|
61
85
|
|
62
86
|
state :root do
|
@@ -117,7 +141,10 @@ module Rouge
|
|
117
141
|
rule %r(//.*$), 'Comment.Single'
|
118
142
|
rule %r(/), 'Comment.Preproc'
|
119
143
|
rule /(?<=\\)\n/, 'Comment.Preproc'
|
120
|
-
rule /\n
|
144
|
+
rule /\n/ do
|
145
|
+
token 'Comment.Preproc'
|
146
|
+
pop!; push :bol
|
147
|
+
end
|
121
148
|
end
|
122
149
|
|
123
150
|
state :if_0 do
|
data/lib/rouge/lexers/puppet.rb
CHANGED
@@ -55,10 +55,10 @@ module Rouge
|
|
55
55
|
rule cap_id, 'Name.Class'
|
56
56
|
|
57
57
|
rule /[+=|~-]>|<[|~-]/, 'Punctuation'
|
58
|
-
rule /[:
|
58
|
+
rule /[:}();\[\]]/, 'Punctuation'
|
59
59
|
|
60
60
|
# HACK for case statements and selectors
|
61
|
-
rule /
|
61
|
+
rule /{/, 'Punctuation', :regex_allowed
|
62
62
|
rule /,/, 'Punctuation', :regex_allowed
|
63
63
|
|
64
64
|
rule /(in|and|or)\b/, 'Operator.Word'
|
data/lib/rouge/lexers/ruby.rb
CHANGED
@@ -27,6 +27,7 @@ module Rouge
|
|
27
27
|
'Literal.String.Symbol'
|
28
28
|
|
29
29
|
rule /:'(\\\\|\\'|[^'])*'/, 'Literal.String.Symbol'
|
30
|
+
rule /\b[a-z_]\w*?:\s+/, 'Literal.String.Symbol'
|
30
31
|
rule /'(\\\\|\\'|[^'])*'/, 'Literal.String.Single'
|
31
32
|
rule /:"/, 'Literal.String.Symbol', :simple_sym
|
32
33
|
rule /"/, 'Literal.String.Double', :simple_string
|
@@ -35,10 +36,10 @@ module Rouge
|
|
35
36
|
# %-style delimiters
|
36
37
|
# %(abc), %[abc], %<abc>, %.abc., %r.abc., etc
|
37
38
|
delimiter_map = { '{' => '}', '[' => ']', '(' => ')', '<' => '>' }
|
38
|
-
rule /%([
|
39
|
+
rule /%([rqswQWxiI])?([^\w\s])/ do |m|
|
39
40
|
open = Regexp.escape(m[2])
|
40
41
|
close = Regexp.escape(delimiter_map[m[2]] || m[2])
|
41
|
-
interp = /[
|
42
|
+
interp = /[rQWxI]/ === m[1]
|
42
43
|
toktype = 'Literal.String.Other'
|
43
44
|
|
44
45
|
debug { " open: #{open.inspect}" }
|
@@ -154,8 +155,8 @@ module Rouge
|
|
154
155
|
group 'Name.Namespace'
|
155
156
|
end
|
156
157
|
|
157
|
-
rule /def\
|
158
|
-
rule /class\
|
158
|
+
rule /def\s+/, 'Keyword', :funcname
|
159
|
+
rule /class\s+/, 'Keyword', :classname
|
159
160
|
|
160
161
|
rule /(?:#{builtins_q.join('|')})\?/, 'Name.Builtin', :expr_start
|
161
162
|
rule /(?:#{builtins_b.join('|')})!/, 'Name.Builtin', :expr_start
|
@@ -331,7 +332,7 @@ module Rouge
|
|
331
332
|
|
332
333
|
# special case for using a single space. Ruby demands that
|
333
334
|
# these be in a single line, otherwise it would make no sense.
|
334
|
-
rule /(\s*)(%[
|
335
|
+
rule /(\s*)(%[rqswQWxiI]? \S* )/ do
|
335
336
|
group 'Text'
|
336
337
|
group 'Literal.String.Other'
|
337
338
|
pop!
|
@@ -0,0 +1,69 @@
|
|
1
|
+
module Rouge
|
2
|
+
module Themes
|
3
|
+
class Github < CSSTheme
|
4
|
+
name 'github'
|
5
|
+
|
6
|
+
style 'Comment.Multiline', :fg => '#999988', :italic => true
|
7
|
+
style 'Comment.Preproc', :fg => '#999999', :bold => true
|
8
|
+
style 'Comment.Single', :fg => '#999988', :italic => true
|
9
|
+
style 'Comment.Special', :fg => '#999999', :italic => true, :bold => true
|
10
|
+
style 'Comment', :fg => '#999988', :italic => true
|
11
|
+
style 'Error', :fg => '#a61717', :bg => '#e3d2d2'
|
12
|
+
style 'Generic.Deleted', :fg => '#000000', :bg => '#ffdddd'
|
13
|
+
style 'Generic.Emph', :fg => '#000000', :italic => true
|
14
|
+
style 'Generic.Error', :fg => '#aa0000'
|
15
|
+
style 'Generic.Heading', :fg => '#999999'
|
16
|
+
style 'Generic.Inserted', :fg => '#000000', :bg => '#ddffdd'
|
17
|
+
style 'Generic.Output', :fg => '#888888'
|
18
|
+
style 'Generic.Prompt', :fg => '#555555'
|
19
|
+
style 'Generic.Strong', :bold => true
|
20
|
+
style 'Generic.Subheading', :fg => '#aaaaaa'
|
21
|
+
style 'Generic.Traceback', :fg => '#aa0000'
|
22
|
+
style 'Keyword.Constant', :fg => '#000000', :bold => true
|
23
|
+
style 'Keyword.Declaration', :fg => '#000000', :bold => true
|
24
|
+
style 'Keyword.Namespace', :fg => '#000000', :bold => true
|
25
|
+
style 'Keyword.Pseudo', :fg => '#000000', :bold => true
|
26
|
+
style 'Keyword.Reserved', :fg => '#000000', :bold => true
|
27
|
+
style 'Keyword.Type', :fg => '#445588', :bold => true
|
28
|
+
style 'Keyword', :fg => '#000000', :bold => true
|
29
|
+
style 'Literal.Number.Float', :fg => '#009999'
|
30
|
+
style 'Literal.Number.Hex', :fg => '#009999'
|
31
|
+
style 'Literal.Number.Integer.Long', :fg => '#009999'
|
32
|
+
style 'Literal.Number.Integer', :fg => '#009999'
|
33
|
+
style 'Literal.Number.Oct', :fg => '#009999'
|
34
|
+
style 'Literal.Number', :fg => '#009999'
|
35
|
+
style 'Literal.String.Backtick', :fg => '#d14'
|
36
|
+
style 'Literal.String.Char', :fg => '#d14'
|
37
|
+
style 'Literal.String.Doc', :fg => '#d14'
|
38
|
+
style 'Literal.String.Double', :fg => '#d14'
|
39
|
+
style 'Literal.String.Escape', :fg => '#d14'
|
40
|
+
style 'Literal.String.Heredoc', :fg => '#d14'
|
41
|
+
style 'Literal.String.Interpol', :fg => '#d14'
|
42
|
+
style 'Literal.String.Other', :fg => '#d14'
|
43
|
+
style 'Literal.String.Regex', :fg => '#009926'
|
44
|
+
style 'Literal.String.Single', :fg => '#d14'
|
45
|
+
style 'Literal.String.Symbol', :fg => '#990073'
|
46
|
+
style 'Literal.String', :fg => '#d14'
|
47
|
+
style 'Name.Attribute', :fg => '#008080'
|
48
|
+
style 'Name.Builtin.Pseudo', :fg => '#999999'
|
49
|
+
style 'Name.Builtin', :fg => '#0086B3'
|
50
|
+
style 'Name.Class', :fg => '#445588', :bold => true
|
51
|
+
style 'Name.Constant', :fg => '#008080'
|
52
|
+
style 'Name.Decorator', :fg => '#3c5d5d', :bold => true
|
53
|
+
style 'Name.Entity', :fg => '#800080'
|
54
|
+
style 'Name.Exception', :fg => '#990000', :bold => true
|
55
|
+
style 'Name.Function', :fg => '#990000', :bold => true
|
56
|
+
style 'Name.Label', :fg => '#990000', :bold => true
|
57
|
+
style 'Name.Namespace', :fg => '#555555'
|
58
|
+
style 'Name.Tag', :fg => '#000080'
|
59
|
+
style 'Name.Variable.Class', :fg => '#008080'
|
60
|
+
style 'Name.Variable.Global', :fg => '#008080'
|
61
|
+
style 'Name.Variable.Instance', :fg => '#008080'
|
62
|
+
style 'Name.Variable', :fg => '#008080'
|
63
|
+
style 'Operator.Word', :fg => '#000000', :bold => true
|
64
|
+
style 'Operator', :fg => '#000000', :bold => true
|
65
|
+
style 'Text.Whitespace', :fg => '#bbbbbb'
|
66
|
+
style 'Text', :bg => '#f8f8f8'
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
data/lib/rouge/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rouge
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.5
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-05-
|
12
|
+
date: 2013-05-25 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
type: :runtime
|
@@ -50,6 +50,7 @@ files:
|
|
50
50
|
- lib/rouge/formatters/terminal256.rb
|
51
51
|
- lib/rouge/themes/thankful_eyes.rb
|
52
52
|
- lib/rouge/themes/base16.rb
|
53
|
+
- lib/rouge/themes/github.rb
|
53
54
|
- lib/rouge/themes/colorful.rb
|
54
55
|
- lib/rouge/text_analyzer.rb
|
55
56
|
- lib/rouge/regex_lexer.rb
|