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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 51f0576137305906368ec086aba6c9c11d45799d10dc8a22abd5598a4026251a
4
- data.tar.gz: 1a52f85350f6d2b3e128b637ec040108d993534ec554296cdd2b998e26551aec
3
+ metadata.gz: 0e78e90266b5520e8f2779dea8af5f83b3bb4107d5666eac6dae98d2f754c88e
4
+ data.tar.gz: 2a485a89f512d3c1da45b52ba679f76575de7c91be34d687f2104984f286fb5f
5
5
  SHA512:
6
- metadata.gz: 1445456d3974c347367ae35c8b8b2ceec320f523931620d3ad4f19f3982ddefff2f9426f9f47318b6e548da9c0b25b0b370733a472250065579c27296785ce49
7
- data.tar.gz: f78d6fd69910ea7350b77a6d0c8702214d097e8813032fb4254fa53f4521805c5f2b74c3f1ea8c763cb305b145929d6e12810653952ef57c4c32765048ccaffe
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("<!JEKYLL@#{object_id}@#{id}>", match)
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
- nodes = body.css(selector)
49
- nodes.each do |node|
51
+ body.css(selector).each do |node|
52
+ count = escaped_count
53
+
50
54
  # handle emoji markup
51
- node.inner_html = node.inner_html.gsub(
52
- /:([\w\d+-]+?):/, '\:\1\:'
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
- nodes.each do |node|
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]
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Jekyll
4
4
  module Spaceship
5
- VERSION = "0.9.9"
5
+ VERSION = "0.10.0"
6
6
  end
7
7
  end
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.9.9
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-04-18 00:00:00.000000000 Z
11
+ date: 2021-08-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jekyll