shoes-highlighter 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/shoes/highlighter/markup.rb +29 -37
- data/lib/shoes/highlighter/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 17121d48a9b7cd4917902d1a31c8dcaeece4bbd1
|
4
|
+
data.tar.gz: 66910b8f22dbf4f7265a97ac561980960d775e8a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4b8959e9c7ecf530852855b7b899e5852239213d006426a074964c1dfb55c251537864806718c6f9af4b767a17b392d3dc3b3a9432ec6e200e3a993b9f9787ea
|
7
|
+
data.tar.gz: 29ec2c6c1f00ae89a5ad45a7186d04ffde0cb142971465ba7874ca355608718d7b5609e1a61b0d0c0a2b7710029a8c2e6658724734827b688f9eac61ea33b204
|
@@ -5,25 +5,25 @@ class Shoes
|
|
5
5
|
module Markup
|
6
6
|
TOKENIZER = Shoes::Highlighter::Syntax.load "ruby"
|
7
7
|
COLORS = {
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
8
|
+
comment: { stroke: "#887" },
|
9
|
+
keyword: { stroke: "#111" },
|
10
|
+
method: { stroke: "#C09", weight: "bold" },
|
11
|
+
# :class => {:stroke => "#0c4", :weight => "bold"},
|
12
|
+
# :module => {:stroke => "#050"},
|
13
|
+
# :punct => {:stroke => "#668", :weight => "bold"},
|
14
|
+
symbol: { stroke: "#C30" },
|
15
|
+
string: { stroke: "#C90" },
|
16
|
+
number: { stroke: "#396" },
|
17
|
+
regex: { stroke: "#000", fill: "#FFC" },
|
18
|
+
# :char => {:stroke => "#f07"},
|
19
|
+
attribute: { stroke: "#369" },
|
20
|
+
# :global => {:stroke => "#7FB" },
|
21
|
+
expr: { stroke: "#722" },
|
22
|
+
# :escape => {:stroke => "#277" }
|
23
|
+
ident: { stroke: "#994c99" },
|
24
|
+
constant: { stroke: "#630", weight: "bold" },
|
25
|
+
class: { stroke: "#630", weight: "bold" },
|
26
|
+
matching: { stroke: "#ff0", weight: "bold" },
|
27
27
|
}
|
28
28
|
|
29
29
|
def highlight(str, pos = nil, colors = COLORS)
|
@@ -43,13 +43,9 @@ class Shoes
|
|
43
43
|
tokens.each do |token|
|
44
44
|
res <<
|
45
45
|
if colors[token.group]
|
46
|
-
|
47
|
-
tmp = fg(token, colors[token.group][:stroke])
|
48
|
-
colors[token.group][:fill] ? bg(tmp, colors[token.group][:fill]) : tmp
|
46
|
+
span(token, colors[token.group])
|
49
47
|
elsif colors[:any]
|
50
|
-
|
51
|
-
tmp = fg(token, colors[:any][:stroke])
|
52
|
-
colors[:any][:fill] ? bg(tmp, colors[:any][:fill]) : tmp
|
48
|
+
span(token, colors[:any])
|
53
49
|
else
|
54
50
|
token
|
55
51
|
end
|
@@ -62,13 +58,9 @@ class Shoes
|
|
62
58
|
token_index, matching_index = matching_token(tokens, pos)
|
63
59
|
|
64
60
|
if token_index
|
65
|
-
|
66
|
-
tmp = fg(tokens[token_index], colors[:matching][:stroke])
|
67
|
-
res[token_index] = colors[:matching][:fill] ? bg(tmp, colors[:matching][:fill]) : tmp
|
61
|
+
res[token_index] = span(tokens[token_index], colors[:matching])
|
68
62
|
if matching_index
|
69
|
-
|
70
|
-
tmp = fg(tokens[matching_index], colors[:matching][:stroke])
|
71
|
-
res[matching_index] = colors[:matching][:fill] ? bg(tmp, colors[:matching][:fill]) : tmp
|
63
|
+
res[matching_index] = span(tokens[matching_index], colors[:matching])
|
72
64
|
end
|
73
65
|
end
|
74
66
|
|
@@ -182,9 +174,9 @@ class Shoes
|
|
182
174
|
end
|
183
175
|
|
184
176
|
OPEN_BRACKETS = {
|
185
|
-
|
186
|
-
|
187
|
-
|
177
|
+
'{' => '}',
|
178
|
+
'(' => ')',
|
179
|
+
'[' => ']',
|
188
180
|
}
|
189
181
|
|
190
182
|
# close_bracket = {}
|
@@ -192,9 +184,9 @@ class Shoes
|
|
192
184
|
# CLOSE_BRACKETS = opens_bracket
|
193
185
|
# the following is more readable :)
|
194
186
|
CLOSE_BRACKETS = {
|
195
|
-
|
196
|
-
|
197
|
-
|
187
|
+
'}' => '{',
|
188
|
+
')' => '(',
|
189
|
+
']' => '[',
|
198
190
|
}
|
199
191
|
|
200
192
|
BRACKETS = CLOSE_BRACKETS.keys + OPEN_BRACKETS.keys
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: shoes-highlighter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Team Shoes
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-04-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -77,7 +77,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
77
77
|
version: '0'
|
78
78
|
requirements: []
|
79
79
|
rubyforge_project:
|
80
|
-
rubygems_version: 2.4.
|
80
|
+
rubygems_version: 2.4.5
|
81
81
|
signing_key:
|
82
82
|
specification_version: 4
|
83
83
|
summary: A syntax highlighting library used by Shoes
|