jekyll-spaceship 0.9.9 → 0.10.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/jekyll-spaceship/cores/config.rb +3 -0
- data/lib/jekyll-spaceship/cores/manager.rb +5 -0
- data/lib/jekyll-spaceship/cores/processor.rb +47 -1
- data/lib/jekyll-spaceship/processors/emoji-processor.rb +19 -6
- data/lib/jekyll-spaceship/processors/table-processor.rb +2 -2
- data/lib/jekyll-spaceship/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0e78e90266b5520e8f2779dea8af5f83b3bb4107d5666eac6dae98d2f754c88e
|
4
|
+
data.tar.gz: 2a485a89f512d3c1da45b52ba679f76575de7c91be34d687f2104984f286fb5f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6268083908d3ec0ff4420b13efd4b35acde48329d2339d7e793f29f0c2a8311f5d7aef36ec5fa95a5e2d94fe3cc04db8fb540f00a0e10f26335dcedb8da236de
|
7
|
+
data.tar.gz: 0b5d5950a8a446429cf4a00c3ebba32cde6068f4d3856e00f2868933cfa8031ef3af0b1bee0c5d40e28ea1abd19530a87b3addfd184a543ad27a3684ee10cb01
|
@@ -64,7 +64,10 @@ module Jekyll::Spaceship
|
|
64
64
|
def self.load_config
|
65
65
|
# post load site config for `group :jekyll_plugin`
|
66
66
|
Jekyll::Hooks.register :site, :after_init do |site|
|
67
|
+
# load config
|
67
68
|
self.load(site.config)
|
69
|
+
# dispatch site after_init event
|
70
|
+
Manager.dispatch(site, :site, :after_init)
|
68
71
|
end
|
69
72
|
end
|
70
73
|
end
|
@@ -14,6 +14,7 @@ module Jekyll::Spaceship
|
|
14
14
|
container = _register.first
|
15
15
|
events = _register.last.uniq
|
16
16
|
events = events.select do |event|
|
17
|
+
next true if event.match(/^after/)
|
17
18
|
next true if event.match(/^post/)
|
18
19
|
next events.index(event.to_s.gsub(/^pre/, 'post').to_sym).nil?
|
19
20
|
end
|
@@ -59,21 +60,25 @@ module Jekyll::Spaceship
|
|
59
60
|
def self.dispatch(page, container, event)
|
60
61
|
@@_processors.each do |processor|
|
61
62
|
processor.dispatch page, container, event
|
63
|
+
break unless processor.next?
|
62
64
|
end
|
63
65
|
if event.to_s.start_with?('post') and Type.html? output_ext(page)
|
64
66
|
self.dispatch_html_block(page)
|
65
67
|
end
|
66
68
|
@@_processors.each do |processor|
|
67
69
|
processor.on_handled if processor.handled
|
70
|
+
break unless processor.next?
|
68
71
|
end
|
69
72
|
end
|
70
73
|
|
71
74
|
def self.ext(page)
|
75
|
+
return unless page.respond_to? :path
|
72
76
|
ext = page.path.match(/\.[^.]+$/)
|
73
77
|
ext.to_s.rstrip
|
74
78
|
end
|
75
79
|
|
76
80
|
def self.output_ext(page)
|
81
|
+
return unless page.respond_to? :url_placeholders
|
77
82
|
page.url_placeholders[:output_ext]
|
78
83
|
end
|
79
84
|
|
@@ -90,6 +90,10 @@ module Jekyll::Spaceship
|
|
90
90
|
def self.config
|
91
91
|
end
|
92
92
|
|
93
|
+
def next?
|
94
|
+
true
|
95
|
+
end
|
96
|
+
|
93
97
|
def process?
|
94
98
|
Type.html?(output_ext) or Type.markdown?(ext)
|
95
99
|
end
|
@@ -188,12 +192,28 @@ module Jekyll::Spaceship
|
|
188
192
|
while @exclusion_store.size > 0
|
189
193
|
match = @exclusion_store.pop
|
190
194
|
id = @exclusion_store.size
|
191
|
-
content = content.sub(
|
195
|
+
content = content.sub(
|
196
|
+
"<!JEKYLL@#{object_id}@#{id}>"
|
197
|
+
) { match }
|
192
198
|
end
|
193
199
|
@exclusion_store = []
|
194
200
|
content
|
195
201
|
end
|
196
202
|
|
203
|
+
def get_exclusion(id)
|
204
|
+
result = nil
|
205
|
+
match_data = id.match /<!JEKYLL@(.+)@(.+)>/
|
206
|
+
unless match_data.nil?
|
207
|
+
id = match_data[2].to_i
|
208
|
+
result = {
|
209
|
+
:id => id,
|
210
|
+
:marker => match_data[0],
|
211
|
+
:content => @exclusion_store[id]
|
212
|
+
}
|
213
|
+
end
|
214
|
+
result
|
215
|
+
end
|
216
|
+
|
197
217
|
def self.escape_html(content)
|
198
218
|
# escape link
|
199
219
|
content.scan(/((https?:)?\/\/\S+\?[a-zA-Z0-9%\-_=\.&;]+)/) do |result|
|
@@ -237,5 +257,31 @@ module Jekyll::Spaceship
|
|
237
257
|
"<img class=\"#{css_class}\" src=\"#{body}\">"
|
238
258
|
end
|
239
259
|
end
|
260
|
+
|
261
|
+
def self.handle_bang_link(
|
262
|
+
content,
|
263
|
+
url = '(https?:)?\\/\\/.*',
|
264
|
+
title = '("(.*)".*){0,1}',
|
265
|
+
&block
|
266
|
+
)
|
267
|
+
# pre-handle reference-style links
|
268
|
+
regex = /(\[(.*)\]:\s*(#{url}\s*#{title}))/
|
269
|
+
content.scan regex do |match_data|
|
270
|
+
match = match_data[0]
|
271
|
+
ref_name = match_data[1]
|
272
|
+
ref_value = match_data[2]
|
273
|
+
content = content.gsub(match, '')
|
274
|
+
.gsub(/\!\[(.*)\]\s*\[#{ref_name}\]/,
|
275
|
+
"![\1](#{ref_value})")
|
276
|
+
end
|
277
|
+
|
278
|
+
# handle inline-style links
|
279
|
+
regex = /(\!\[(.*)\]\(.*#{url}\s*#{title}\))/
|
280
|
+
content.scan regex do |match_data|
|
281
|
+
url = match_data[2]
|
282
|
+
title = match_data[6]
|
283
|
+
block.call(url, title)
|
284
|
+
end
|
285
|
+
end
|
240
286
|
end
|
241
287
|
end
|
@@ -44,13 +44,24 @@ module Jekyll::Spaceship
|
|
44
44
|
# page's layout field of front matter is nil or unavailable
|
45
45
|
return content if body.nil?
|
46
46
|
|
47
|
+
# Count for restoration
|
48
|
+
escaped_count = 0
|
49
|
+
|
47
50
|
# filter nodes (pre, code)
|
48
|
-
|
49
|
-
|
51
|
+
body.css(selector).each do |node|
|
52
|
+
count = escaped_count
|
53
|
+
|
50
54
|
# handle emoji markup
|
51
|
-
|
52
|
-
|
53
|
-
)
|
55
|
+
inner_html = node.inner_html.gsub(
|
56
|
+
/(?<!\\):([\w\d+-]+?)(?<!\\):/
|
57
|
+
) do |match|
|
58
|
+
escaped_count += 1
|
59
|
+
"\\:#{match[1..-2]}\\:"
|
60
|
+
end
|
61
|
+
|
62
|
+
if escaped_count > count
|
63
|
+
node.inner_html = inner_html
|
64
|
+
end
|
54
65
|
end
|
55
66
|
|
56
67
|
# parse the emoji
|
@@ -73,8 +84,10 @@ module Jekyll::Spaceship
|
|
73
84
|
|
74
85
|
body.inner_html = content
|
75
86
|
|
87
|
+
return doc.to_html if escaped_count.zero?
|
88
|
+
|
76
89
|
# restore nodes (pre, code)
|
77
|
-
|
90
|
+
body.css(selector).each do |node|
|
78
91
|
# handle emoji markup
|
79
92
|
node.inner_html = node.inner_html.gsub(
|
80
93
|
/\\:([\w\d+-]+?)\\:/, ':\1:'
|
@@ -95,7 +95,6 @@ module Jekyll::Spaceship
|
|
95
95
|
handle_multi_rows(data)
|
96
96
|
handle_text_align(data)
|
97
97
|
handle_rowspan(data)
|
98
|
-
handle_attr_list(data)
|
99
98
|
end
|
100
99
|
end
|
101
100
|
rows.each do |row|
|
@@ -103,6 +102,7 @@ module Jekyll::Spaceship
|
|
103
102
|
cells.each do |cell|
|
104
103
|
data.cell = cell
|
105
104
|
handle_format(data)
|
105
|
+
handle_attr_list(data)
|
106
106
|
end
|
107
107
|
end
|
108
108
|
self.handled = true
|
@@ -272,7 +272,7 @@ module Jekyll::Spaceship
|
|
272
272
|
content = cell.inner_html
|
273
273
|
# inline attribute list(IAL) handler
|
274
274
|
ial_handler = ->(list) do
|
275
|
-
list.scan(/(\S+)=("|')(.*?)\2|(\S+)/) do |attr|
|
275
|
+
list.scan(/(\S+)=(”|"|')(.*?)\2|(\S+)/) do |attr|
|
276
276
|
key = attr[0]
|
277
277
|
val = attr[2]
|
278
278
|
single = attr[3]
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jekyll-spaceship
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.10.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- jeffreytse
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-08-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: jekyll
|