rouge 1.6.2 → 1.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/rouge/lexer.rb +1 -1
- data/lib/rouge/lexers/html.rb +2 -2
- data/lib/rouge/lexers/java.rb +1 -1
- data/lib/rouge/lexers/ruby.rb +15 -16
- data/lib/rouge/lexers/swift.rb +56 -86
- data/lib/rouge/plugins/redcarpet.rb +4 -7
- data/lib/rouge/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 93796c1d767a05a20dba729e4a35759571e8fe79
|
4
|
+
data.tar.gz: ad2c926cffb004c214e4d285c57c19a2b5c4e2e3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8f39f87c0fbc32086f5de2668e73bb41083505d25d638691bccfa569baebbf9384f9cfa6997a100dd989e54df095f65250edba317d0541a126dd754077358c72
|
7
|
+
data.tar.gz: c8093c3490d759fc9363744ee4fa34896bc4785da2a7bb797aa48b6e74eb225cce4dbb5d890e06a72374cc9c1f00d4c3b48b706d09c4cc0d4181bee5178eb8d5
|
data/lib/rouge/lexer.rb
CHANGED
@@ -292,7 +292,7 @@ module Rouge
|
|
292
292
|
|
293
293
|
# @private
|
294
294
|
def assert_utf8!(str)
|
295
|
-
return if %w(US-ASCII UTF-8).include? str.encoding.name
|
295
|
+
return if %w(US-ASCII UTF-8 ASCII-8BIT).include? str.encoding.name
|
296
296
|
raise EncodingError.new(
|
297
297
|
"Bad encoding: #{str.encoding.names.join(',')}. " +
|
298
298
|
"Please convert your string to UTF-8."
|
data/lib/rouge/lexers/html.rb
CHANGED
@@ -33,8 +33,8 @@ module Rouge
|
|
33
33
|
push :tag
|
34
34
|
end
|
35
35
|
|
36
|
-
rule %r(<\s*[a-zA-Z0-9
|
37
|
-
rule %r(<\s*/\s*[a-zA-Z0-9
|
36
|
+
rule %r(<\s*[a-zA-Z0-9:-]+), Name::Tag, :tag # opening tags
|
37
|
+
rule %r(<\s*/\s*[a-zA-Z0-9:-]+\s*>), Name::Tag # closing tags
|
38
38
|
end
|
39
39
|
|
40
40
|
state :comment do
|
data/lib/rouge/lexers/java.rb
CHANGED
@@ -42,7 +42,7 @@ module Rouge
|
|
42
42
|
rule /@#{id}/, Name::Decorator
|
43
43
|
rule /(?:#{keywords.join('|')})\b/, Keyword
|
44
44
|
rule /(?:#{declarations.join('|')})\b/, Keyword::Declaration
|
45
|
-
rule /(?:#{types.join('|')})/, Keyword::Type
|
45
|
+
rule /(?:#{types.join('|')})\b/, Keyword::Type
|
46
46
|
rule /package\b/, Keyword::Namespace
|
47
47
|
rule /(?:true|false|null)\b/, Keyword::Constant
|
48
48
|
rule /(?:class|interface)\b/, Keyword::Declaration, :class
|
data/lib/rouge/lexers/ruby.rb
CHANGED
@@ -110,22 +110,21 @@ module Rouge
|
|
110
110
|
)
|
111
111
|
|
112
112
|
builtins_g = %w(
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
untrace_var warn
|
113
|
+
__id__ __send__ abort ancestors at_exit autoload binding callcc
|
114
|
+
caller catch chomp chop class_eval class_variables clone
|
115
|
+
const_defined\? const_get const_missing const_set constants
|
116
|
+
display dup eval exec exit extend fail fork format freeze
|
117
|
+
getc gets global_variables gsub hash id included_modules
|
118
|
+
inspect instance_eval instance_method instance_methods
|
119
|
+
instance_variable_get instance_variable_set instance_variables
|
120
|
+
lambda load local_variables loop method method_missing
|
121
|
+
methods module_eval name object_id open p print printf
|
122
|
+
private_class_method private_instance_methods private_methods proc
|
123
|
+
protected_instance_methods protected_methods public_class_method
|
124
|
+
public_instance_methods public_methods putc puts raise rand
|
125
|
+
readline readlines require scan select self send set_trace_func
|
126
|
+
singleton_methods sleep split sprintf srand sub syscall system
|
127
|
+
taint test throw to_a to_s trace_var trap untaint untrace_var warn
|
129
128
|
)
|
130
129
|
|
131
130
|
builtins_q = %w(
|
data/lib/rouge/lexers/swift.rb
CHANGED
@@ -11,44 +11,26 @@ module Rouge
|
|
11
11
|
id_head = /_|(?!\p{Mc})\p{Alpha}|[^\u0000-\uFFFF]/
|
12
12
|
id_rest = /[\p{Alnum}_]|[^\u0000-\uFFFF]/
|
13
13
|
id = /#{id_head}#{id_rest}*/
|
14
|
+
|
15
|
+
keywords = Set.new %w(
|
16
|
+
break case continue default do else fallthrough if in for return switch where while
|
14
17
|
|
15
|
-
|
16
|
-
@keywords ||= Set.new %w(
|
17
|
-
break case continue default do else fallthrough if in for return switch where while
|
18
|
+
as dynamicType is new super self Self Type __COLUMN__ __FILE__ __FUNCTION__ __LINE__
|
18
19
|
|
19
|
-
|
20
|
+
associativity didSet get infix inout left mutating none nonmutating operator override postfix precedence prefix right set unowned weak willSet
|
21
|
+
)
|
20
22
|
|
21
|
-
|
22
|
-
|
23
|
-
|
23
|
+
declarations = Set.new %w(
|
24
|
+
class deinit enum extension final func import init internal lazy let optional private protocol public required static struct subscript typealias var dynamic
|
25
|
+
)
|
24
26
|
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
)
|
29
|
-
end
|
27
|
+
attributes = Set.new %w(
|
28
|
+
autoclosure IBAction IBDesignable IBInspectable IBOutlet noreturn NSCopying NSManaged objc UIApplicationMain NSApplicationMain
|
29
|
+
)
|
30
30
|
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
)
|
35
|
-
end
|
36
|
-
|
37
|
-
def self.types
|
38
|
-
@types ||= Set.new %w(
|
39
|
-
Int8 Int16 Int32 Int64 UInt8 UInt16 UInt32 UInt64 Int
|
40
|
-
Double Float
|
41
|
-
Bool
|
42
|
-
String Character
|
43
|
-
AnyObject Any
|
44
|
-
)
|
45
|
-
end
|
46
|
-
|
47
|
-
def self.constants
|
48
|
-
@constants ||= Set.new %w(
|
49
|
-
true false nil
|
50
|
-
)
|
51
|
-
end
|
31
|
+
constants = Set.new %w(
|
32
|
+
true false nil
|
33
|
+
)
|
52
34
|
|
53
35
|
state :whitespace do
|
54
36
|
rule /\s+/m, Text
|
@@ -70,67 +52,66 @@ module Rouge
|
|
70
52
|
rule /0x[0-9A-Fa-f]+(?:_[0-9A-Fa-f]+)*/, Num::Hex
|
71
53
|
rule /0b[01]+(?:_[01]+)*/, Num::Bin
|
72
54
|
rule %r{[\d]+(?:_\d+)*}, Num::Integer
|
55
|
+
|
56
|
+
rule /@availability[(][^)]+[)]/, Keyword::Declaration
|
73
57
|
|
74
|
-
rule /(
|
75
|
-
|
76
|
-
rule /(#?#{id})(\s*)(:)/ do
|
77
|
-
groups Name::Variable, Text, Punctuation
|
78
|
-
end
|
79
|
-
|
80
|
-
rule /(let|var)\b(\s*)(#{id})/ do
|
81
|
-
groups Keyword, Text, Name::Variable
|
58
|
+
rule /(@objc[(])([^)]+)([)])/ do
|
59
|
+
groups Keyword::Declaration, Name::Class, Keyword::Declaration
|
82
60
|
end
|
83
61
|
|
84
62
|
rule /@(#{id})/ do |m|
|
85
|
-
if m[1]
|
86
|
-
token Keyword::Declaration
|
87
|
-
push :objc_setting
|
88
|
-
elsif self.class.at_keywords.include? m[1]
|
63
|
+
if attributes.include? m[1]
|
89
64
|
token Keyword
|
90
65
|
else
|
91
66
|
token Error
|
92
67
|
end
|
93
68
|
end
|
94
69
|
|
95
|
-
rule
|
96
|
-
if
|
97
|
-
token Keyword
|
98
|
-
elsif self.class.declarations.include? m[0]
|
70
|
+
rule /(private|internal)(\([ ]*)(\w+)([ ]*\))/ do |m|
|
71
|
+
if m[3] == 'set'
|
99
72
|
token Keyword::Declaration
|
100
|
-
if %w(private internal).include? m[0]
|
101
|
-
push :access_control_setting
|
102
|
-
elsif %w(protocol class extension).include? m[0]
|
103
|
-
push :type_definition
|
104
|
-
end
|
105
|
-
elsif self.class.types.include? m[0]
|
106
|
-
token Keyword::Type
|
107
|
-
elsif self.class.constants.include? m[0]
|
108
|
-
token Keyword::Constant
|
109
73
|
else
|
110
|
-
|
74
|
+
groups Keyword::Declaration, Keyword::Declaration, Error, Keyword::Declaration
|
111
75
|
end
|
112
76
|
end
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
state :access_control_setting do
|
117
|
-
rule /\( *(\w+) *\)/ do |m|
|
118
|
-
if m[1] == 'set'
|
77
|
+
|
78
|
+
rule /(unowned\([ ]*)(\w+)([ ]*\))/ do |m|
|
79
|
+
if m[2] == 'safe' || m[2] == 'unsafe'
|
119
80
|
token Keyword::Declaration
|
120
81
|
else
|
121
|
-
|
82
|
+
groups Keyword::Declaration, Error, Keyword::Declaration
|
122
83
|
end
|
123
84
|
end
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
85
|
+
|
86
|
+
rule /(let|var)\b(\s*)(#{id})/ do
|
87
|
+
groups Keyword, Text, Name::Variable
|
88
|
+
end
|
89
|
+
|
90
|
+
rule /(?!\b(if|while|for|private|internal|unowned|switch|case)\b)\b#{id}(?=(\?|!)?\s*[(])/ do |m|
|
91
|
+
if m[0] =~ /^[[:upper:]]/
|
92
|
+
token Keyword::Type
|
93
|
+
else
|
94
|
+
token Name::Function
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
rule /(#?(?!default)(?![[:upper:]])#{id})(\s*)(:)/ do
|
99
|
+
groups Name::Variable, Text, Punctuation
|
100
|
+
end
|
101
|
+
|
102
|
+
rule id do |m|
|
103
|
+
if keywords.include? m[0]
|
104
|
+
token Keyword
|
105
|
+
elsif declarations.include? m[0]
|
106
|
+
token Keyword::Declaration
|
107
|
+
elsif constants.include? m[0]
|
108
|
+
token Keyword::Constant
|
109
|
+
elsif m[0] =~ /^[[:upper:]]/
|
110
|
+
token Keyword::Type
|
111
|
+
else
|
112
|
+
token Name
|
113
|
+
end
|
132
114
|
end
|
133
|
-
rule //, Keyword::Declaration, :pop!
|
134
115
|
end
|
135
116
|
|
136
117
|
state :dq do
|
@@ -152,17 +133,6 @@ module Rouge
|
|
152
133
|
rule /[)]/, Punctuation, :pop!
|
153
134
|
mixin :root
|
154
135
|
end
|
155
|
-
|
156
|
-
state :type_definition do
|
157
|
-
mixin :whitespace
|
158
|
-
rule id, Name::Class, :pop!
|
159
|
-
end
|
160
|
-
|
161
|
-
state :namespace do
|
162
|
-
mixin :whitespace
|
163
|
-
rule /(?=[(])/, Text, :pop!
|
164
|
-
rule /(#{id}|[.])+/, Name::Namespace, :pop!
|
165
|
-
end
|
166
136
|
end
|
167
137
|
end
|
168
138
|
end
|
@@ -17,16 +17,13 @@ module Rouge
|
|
17
17
|
code.gsub! /^ /, "\t"
|
18
18
|
end
|
19
19
|
|
20
|
-
formatter = rouge_formatter(
|
21
|
-
:css_class => "highlight #{lexer.tag}"
|
22
|
-
)
|
23
|
-
|
20
|
+
formatter = rouge_formatter(lexer)
|
24
21
|
formatter.format(lexer.lex(code))
|
25
22
|
end
|
26
23
|
|
27
|
-
|
28
|
-
def rouge_formatter(
|
29
|
-
Formatters::HTML.new(
|
24
|
+
# override this method for custom formatting behavior
|
25
|
+
def rouge_formatter(lexer)
|
26
|
+
Formatters::HTML.new(:css_class => "highlight #{lexer.tag}")
|
30
27
|
end
|
31
28
|
end
|
32
29
|
end
|
data/lib/rouge/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rouge
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jeanine Adkisson
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-09-18 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Rouge aims to a be a simple, easy-to-extend drop-in replacement for pygments.
|
14
14
|
email:
|