jekyll-spaceship 0.4.0 → 0.4.1

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: f948e78348f6b74d101dff999356e1188dc973cdc7e1eb697f74777406755ce0
4
- data.tar.gz: cfae2fbfc444d4db48c1c68824c96fd6d8c4cf4ca1f3b01c5c987fff252673a0
3
+ metadata.gz: 94ea2a0d155352226a30c7eaa7be0f87e92b752fe476b70ce13a801e22c169ae
4
+ data.tar.gz: dcab68c9f4fb6a26a71184e2334ff05582b37a3c8df6c3fd4c5667bb0a42304a
5
5
  SHA512:
6
- metadata.gz: 65e2c45a6b175cb712c4900644537d53fa6fd73632c8a7f685dcd83d4e1a019adfcb5c7e3ee6f5b7053de16556cf5e73d9ffee0f07bd908a9f2565f1843dbc11
7
- data.tar.gz: 68f7e48bc2f10217c99a2bf7f75530dedceb1cf90a062d1bdfe80d6c0951af058ca5708059ceca03c9206a6c253eb71334ca11efa2fff4a69135101d5941b56b
6
+ metadata.gz: cfaba56224f643f69e3cd63690bb0c3c669d0a4c3db1cdf5bd04d21a4daea64f690fc47891ed617333bcde3bc305c4b433040d7c39816ccf4d7e8624dea2c99b
7
+ data.tar.gz: e471ed629819a3fc6ffbb783d2d9a22ee271c0510e1d3b9f1d5c6bc62053dc1fadbbf3af5abacfe907c35cb7682ed0b2514208e7e0e074957c278dce83ad7ac7
@@ -7,6 +7,7 @@ module Jekyll::Spaceship
7
7
  @@_hooks = {}
8
8
  @@_registers = []
9
9
  @@_processers = []
10
+ @@_exclusions = []
10
11
  @@_priority = nil
11
12
 
12
13
  attr_accessor :priority
@@ -40,6 +41,7 @@ module Jekyll::Spaceship
40
41
  def initialize()
41
42
  self.initialize_priority
42
43
  self.initialize_register
44
+ self.initialize_exclusions
43
45
  end
44
46
 
45
47
  def initialize_priority
@@ -71,6 +73,14 @@ module Jekyll::Spaceship
71
73
  @@_registers.clear
72
74
  end
73
75
 
76
+ def initialize_exclusions
77
+ if @@_exclusions.size.zero?
78
+ self.class.exclude :code, :block_quotes
79
+ end
80
+ @_exclusions = @@_exclusions.uniq
81
+ @@_exclusions.clear
82
+ end
83
+
74
84
  def self.priority(value)
75
85
  value = value.to_sym
76
86
  if PRIORITY_MAP.has_key? value
@@ -145,7 +155,9 @@ module Jekyll::Spaceship
145
155
  end
146
156
 
147
157
  if self.respond_to? method
158
+ @page.content = self.pre_exclude @page.content
148
159
  @page.content = self.send method, @page.content
160
+ @page.content = self.after_exclude @page.content
149
161
  end
150
162
  else
151
163
  if html? output_ext
@@ -162,6 +174,10 @@ module Jekyll::Spaceship
162
174
  end
163
175
  end
164
176
 
177
+ def self.exclude(*types)
178
+ @@_exclusions = types
179
+ end
180
+
165
181
  def html?(_ext)
166
182
  self.class.html? _ext
167
183
  end
@@ -217,6 +233,34 @@ module Jekyll::Spaceship
217
233
  html?(output_ext) or markdown?(ext)
218
234
  end
219
235
 
236
+ def pre_exclude(content)
237
+ @_exclusion_store = []
238
+ @_exclusions.each do |type|
239
+ regex = nil
240
+ if type == :code
241
+ regex = /(`{3}\s*(\w*)((?:.|\n)*?)`{3})/
242
+ end
243
+ next if regex.nil?
244
+ content.scan(regex) do |match_data|
245
+ match = match_data[0]
246
+ id = @_exclusion_store.size
247
+ content = content.gsub(match, "[//]: JEKYLL_EXCLUDE_##{id}")
248
+ @_exclusion_store.push match
249
+ end
250
+ end
251
+ content
252
+ end
253
+
254
+ def after_exclude(content)
255
+ while @_exclusion_store.size > 0
256
+ match = @_exclusion_store.pop
257
+ id = @_exclusion_store.size
258
+ content = content.gsub("[//]: JEKYLL_EXCLUDE_##{id}", match)
259
+ end
260
+ @_exclusion_store = []
261
+ content
262
+ end
263
+
220
264
  def on_handled
221
265
  processor = self.class.name.split('::').last
222
266
  file = page.path.gsub(/.*_posts\//, '')
@@ -251,7 +295,9 @@ module Jekyll::Spaceship
251
295
 
252
296
  # dispatch to other handlers
253
297
  if processor.respond_to? method
298
+ blk_content = processor.pre_exclude blk_content
254
299
  blk_content = processor.send method, blk_content
300
+ blk_content = processor.after_exclude blk_content
255
301
  end
256
302
  end
257
303
 
@@ -2,6 +2,8 @@
2
2
 
3
3
  module Jekyll::Spaceship
4
4
  class PlantUMLProcessor < Processor
5
+ exclude :none
6
+
5
7
  def on_handle_markdown(content)
6
8
  # match default plantuml block and code block
7
9
  pattern = Regexp.union(
@@ -75,6 +75,7 @@ module Jekyll::Spaceship
75
75
 
76
76
  data[:width] = 600 if data[:width].nil?
77
77
  data[:height] = 400 if data[:height].nil?
78
+ style = "max-width: 100%" if width.nil?
78
79
  width = data[:width] if width.nil?
79
80
  height = data[:height] if height.nil?
80
81
 
@@ -84,6 +85,7 @@ module Jekyll::Spaceship
84
85
  title=\"#{title}\" \
85
86
  width=\"#{width}\" \
86
87
  height=\"#{height}\" \
88
+ style=\"#{style}\" \
87
89
  frameborder=\"0\" \
88
90
  allowfullscreen=\"\">\
89
91
  </iframe>"
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Jekyll
4
4
  module Spaceship
5
- VERSION = "0.4.0"
5
+ VERSION = "0.4.1"
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.4.0
4
+ version: 0.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - jeffreytse
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-04-28 00:00:00.000000000 Z
11
+ date: 2020-04-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nokogiri