jekyll-spaceship 0.8.0 β 0.8.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +21 -10
- data/lib/jekyll-spaceship/cores/processor.rb +9 -5
- data/lib/jekyll-spaceship/processors/element-processor.rb +71 -53
- data/lib/jekyll-spaceship/processors/emoji-processor.rb +3 -2
- data/lib/jekyll-spaceship/processors/table-processor.rb +18 -10
- data/lib/jekyll-spaceship/processors/video-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: 5310871597e6232b96116549a1ea824054fe68572ced4bb2a14238bb3b7098fd
|
4
|
+
data.tar.gz: 41461f5eb94fda09064bdd21126d0b505c84232bec5a51a309b5954ffa5ba2b6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9a081bcfb8bcdaed430eeb456cae89172e55de4654ae81412fdf2749b8cb793f2c9cb702b829d1c80aa48db86f8bd5b445bde91cd1d07fdd57d717861e561642
|
7
|
+
data.tar.gz: e98d3a810ba88e430f9cddfcfafc4e6f7d5cd77b4b91ed9ad2b073b02332af915059b195fbace35f02dddc88415466405eefc11b0e4c9485633f77d5fc1b0415
|
data/README.md
CHANGED
@@ -140,7 +140,12 @@ plugins:
|
|
140
140
|
- jekyll-spaceship
|
141
141
|
```
|
142
142
|
|
143
|
-
**π‘ Tip:** Note that GitHub Pages runs in `safe` mode and only allows [a set of whitelisted plugins](https://pages.github.com/versions/). To use the gem in GitHub Pages, you need to build locally or use CI (e.g. [travis](https://travis-ci.org/), [github workflow](https://help.github.com/en/actions/configuring-and-managing-workflows/configuring-a-workflow)) and deploy to your `gh-pages` branch.
|
143
|
+
**π‘ Tip:** Note that GitHub Pages runs in `safe` mode and only allows [a set of whitelisted plugins](https://pages.github.com/versions/). To use the gem in GitHub Pages, you need to build locally or use CI (e.g. [travis](https://travis-ci.org/), [github workflow](https://help.github.com/en/actions/configuring-and-managing-workflows/configuring-a-workflow)) and deploy to your `gh-pages` branch.
|
144
|
+
|
145
|
+
### Additions
|
146
|
+
|
147
|
+
* Here is a GitHub Action named [jekyll-deploy-action](https://github.com/jeffreytse/jekyll-deploy-action) for Jekyll site deployment conveniently. π
|
148
|
+
* Here is a [Jekyll site](https://github.com/jeffreytse/jekyll-jeffreytse-blog) using Travis to build and deploy to GitHub Pages for your references.
|
144
149
|
|
145
150
|
## Configuration
|
146
151
|
|
@@ -167,7 +172,7 @@ jekyll-spaceship:
|
|
167
172
|
- ['$','$']
|
168
173
|
- ['\(','\)']
|
169
174
|
plantuml-processor:
|
170
|
-
mode: default # mode value 'pre-fetch' for
|
175
|
+
mode: default # mode value 'pre-fetch' for fetching image at building stage
|
171
176
|
css:
|
172
177
|
class: plantuml
|
173
178
|
syntax:
|
@@ -175,7 +180,7 @@ jekyll-spaceship:
|
|
175
180
|
custom: ['@startuml', '@enduml']
|
176
181
|
src: http://www.plantuml.com/plantuml/png/
|
177
182
|
mermaid-processor:
|
178
|
-
mode: default # mode value 'pre-fetch' for
|
183
|
+
mode: default # mode value 'pre-fetch' for fetching image at building stage
|
179
184
|
css:
|
180
185
|
class: mermaid
|
181
186
|
syntax:
|
@@ -221,13 +226,13 @@ This feature is contributed by [pmccloghrylaing](https://github.com/pmccloghryla
|
|
221
226
|
```markdown
|
222
227
|
| Stage | Direct Products | ATP Yields |
|
223
228
|
| -----------------: | --------------: | ---------: |
|
224
|
-
| Glycolysis |
|
225
|
-
|
|
229
|
+
| Glycolysis | 2 ATP ||
|
230
|
+
| ^^ | 2 NADH | 3--5 ATP |
|
226
231
|
| Pyruvaye oxidation | 2 NADH | 5 ATP |
|
227
232
|
| Citric acid cycle | 2 ATP ||
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
233
|
+
| ^^ | 6 NADH | 15 ATP |
|
234
|
+
| ^^ | 2 FADH | 3 ATP |
|
235
|
+
| 30--32 ATP |||
|
231
236
|
```
|
232
237
|
|
233
238
|
Code above would be parsed as:
|
@@ -428,7 +433,7 @@ Table cell can be set alignment separately.
|
|
428
433
|
```markdown
|
429
434
|
| : Fruits \|\| Food : |||
|
430
435
|
| :--------- | :-------- | :-------- |
|
431
|
-
| Apple | :
|
436
|
+
| Apple | : Apple : | Apple \
|
432
437
|
| Banana | Banana | Banana \
|
433
438
|
| Orange | Orange | Orange |
|
434
439
|
| : Rowspan is 4 : || How's it? |
|
@@ -727,7 +732,7 @@ It's easy to write markdown inside HTML:
|
|
727
732
|
|
728
733
|
| : Fruits \|\| Food : |||
|
729
734
|
| :--------- | :-------- | :-------- |
|
730
|
-
| Apple | :
|
735
|
+
| Apple | : Apple : | Apple \
|
731
736
|
| Banana | Banana | Banana \
|
732
737
|
| Orange | Orange | Orange |
|
733
738
|
| : Rowspan is 4 : || How's it? |
|
@@ -903,6 +908,12 @@ jekyll-spaceship:
|
|
903
908
|
loading: eager # Replace `loading` value to `eager`
|
904
909
|
```
|
905
910
|
|
911
|
+
There are three options when using this method to lazy load images. Here are the supported values for the loading attribute:
|
912
|
+
|
913
|
+
- auto: Default lazy-loading behavior of the browser, which is the same as not including the attribute.
|
914
|
+
- lazy: Defer loading of the resource until it reaches a calculated distance from the viewport.
|
915
|
+
- eager: Load the resource immediately, regardless of where itβs located on the page.
|
916
|
+
|
906
917
|
|
907
918
|
## Credits
|
908
919
|
|
@@ -65,7 +65,7 @@ module Jekyll::Spaceship
|
|
65
65
|
|
66
66
|
def initialize_exclusions
|
67
67
|
if @@_exclusions.size.zero?
|
68
|
-
self.class.exclude :code, :
|
68
|
+
self.class.exclude :code, :math, :liquid_filter
|
69
69
|
end
|
70
70
|
@exclusions = @@_exclusions.uniq
|
71
71
|
@@_exclusions.clear
|
@@ -121,7 +121,7 @@ module Jekyll::Spaceship
|
|
121
121
|
else
|
122
122
|
if Type.html? output_ext
|
123
123
|
method = 'on_handle_html'
|
124
|
-
elsif css? output_ext
|
124
|
+
elsif Type.css? output_ext
|
125
125
|
method = 'on_handle_css'
|
126
126
|
end
|
127
127
|
if self.respond_to? method
|
@@ -156,13 +156,17 @@ module Jekyll::Spaceship
|
|
156
156
|
@exclusions.each do |type|
|
157
157
|
regex = nil
|
158
158
|
if type == :code
|
159
|
-
regex = /((`+)\s*(\w*)((?:.|\n)*?)\2)/
|
159
|
+
regex = /(((?<!\\)`+)\s*(\w*)((?:.|\n)*?)\2)/
|
160
|
+
elsif type == :math
|
161
|
+
regex = /(((?<!\\)\${1,2})[^\n]*?\1)/
|
162
|
+
elsif type == :liquid_filter
|
163
|
+
regex = /((?<!\\)\{\{[^\n]*?\}\})/
|
160
164
|
end
|
161
165
|
next if regex.nil?
|
162
166
|
content.scan(regex) do |match_data|
|
163
167
|
match = match_data[0]
|
164
168
|
id = @exclusion_store.size
|
165
|
-
content = content.sub(match, "
|
169
|
+
content = content.sub(match, "<!JEKYLL@#{object_id}@#{id}>")
|
166
170
|
@exclusion_store.push match
|
167
171
|
end
|
168
172
|
end
|
@@ -173,7 +177,7 @@ module Jekyll::Spaceship
|
|
173
177
|
while @exclusion_store.size > 0
|
174
178
|
match = @exclusion_store.pop
|
175
179
|
id = @exclusion_store.size
|
176
|
-
content = content.sub("
|
180
|
+
content = content.sub("<!JEKYLL@#{object_id}@#{id}>", match)
|
177
181
|
end
|
178
182
|
@exclusion_store = []
|
179
183
|
content
|
@@ -45,61 +45,11 @@ module Jekyll::Spaceship
|
|
45
45
|
if data.kind_of? String
|
46
46
|
element.replace Nokogiri::HTML.fragment(data)
|
47
47
|
elsif data.kind_of? Hash
|
48
|
-
|
49
|
-
element.name = data['name'] unless data['name'].nil?
|
50
|
-
|
51
|
-
# set props
|
52
|
-
data['props']&.each do |prop, val|
|
53
|
-
next element.remove_attribute if val.nil?
|
54
|
-
if val.kind_of? Array
|
55
|
-
next if val.size != 2
|
56
|
-
v = element[prop]
|
57
|
-
v = '' if v.nil?
|
58
|
-
val = v.sub(/#{val[0]}/, val[1])
|
59
|
-
elsif val.kind_of? Hash
|
60
|
-
result = []
|
61
|
-
val.each { |k, v| result.push "#{k}: #{v}" }
|
62
|
-
val = result.join(";")
|
63
|
-
end
|
64
|
-
element.set_attribute(prop, val)
|
65
|
-
end
|
66
|
-
|
67
|
-
# processing children
|
68
|
-
return unless data.has_key?('children')
|
69
|
-
return element.inner_html = "" if data['children'].nil?
|
70
|
-
children = self.create_children({
|
48
|
+
handle_hash_element({
|
71
49
|
:doc => doc,
|
72
|
-
:
|
50
|
+
:element => element,
|
51
|
+
:data => data,
|
73
52
|
})
|
74
|
-
|
75
|
-
# replace whole inner html
|
76
|
-
unless data['children'].kind_of? Array
|
77
|
-
return element.inner_html = children
|
78
|
-
end
|
79
|
-
|
80
|
-
if element.children.size.zero?
|
81
|
-
return element.inner_html = children
|
82
|
-
end
|
83
|
-
|
84
|
-
index = data['children'].index(nil)
|
85
|
-
if index.nil?
|
86
|
-
return element.inner_html = children
|
87
|
-
end
|
88
|
-
|
89
|
-
# insert to the end of children
|
90
|
-
if index == 0
|
91
|
-
return element.children.last.after(children)
|
92
|
-
end
|
93
|
-
|
94
|
-
# insert to the begin of children
|
95
|
-
rindex = data['children'].rindex { |item| !item.nil? }
|
96
|
-
if index == rindex + 1
|
97
|
-
return element.children.first.before children
|
98
|
-
end
|
99
|
-
|
100
|
-
# wrap the children
|
101
|
-
element.children.first.before children[0..index]
|
102
|
-
element.children.last.after children[index..children.size]
|
103
53
|
end
|
104
54
|
end
|
105
55
|
|
@@ -126,6 +76,45 @@ module Jekyll::Spaceship
|
|
126
76
|
root.children
|
127
77
|
end
|
128
78
|
|
79
|
+
def handle_hash_element(data)
|
80
|
+
doc = data[:doc]
|
81
|
+
element = data[:element]
|
82
|
+
data = data[:data]
|
83
|
+
|
84
|
+
# set name
|
85
|
+
element.name = data['name'] unless data['name'].nil?
|
86
|
+
|
87
|
+
# set props
|
88
|
+
data['props']&.each do |prop, val|
|
89
|
+
next element.remove_attribute if val.nil?
|
90
|
+
if val.kind_of? Array
|
91
|
+
next if val.size != 2
|
92
|
+
v = element[prop]
|
93
|
+
v = '' if v.nil?
|
94
|
+
val = v.sub(/#{val[0]}/, val[1])
|
95
|
+
elsif val.kind_of? Hash
|
96
|
+
result = []
|
97
|
+
val.each { |k, v| result.push "#{k}: #{v}" }
|
98
|
+
val = result.join(";")
|
99
|
+
end
|
100
|
+
element.set_attribute(prop, val)
|
101
|
+
end
|
102
|
+
|
103
|
+
# processing children
|
104
|
+
return unless data.has_key?('children')
|
105
|
+
return element.inner_html = "" if data['children'].nil?
|
106
|
+
children = self.create_children({
|
107
|
+
:doc => doc,
|
108
|
+
:data => data['children']
|
109
|
+
})
|
110
|
+
|
111
|
+
handle_element_placement({
|
112
|
+
:data => data,
|
113
|
+
:element => element,
|
114
|
+
:children => children,
|
115
|
+
})
|
116
|
+
end
|
117
|
+
|
129
118
|
def create_element(data)
|
130
119
|
doc = data[:doc]
|
131
120
|
data = data[:data]
|
@@ -148,5 +137,34 @@ module Jekyll::Spaceship
|
|
148
137
|
end
|
149
138
|
node
|
150
139
|
end
|
140
|
+
|
141
|
+
def handle_element_placement(data)
|
142
|
+
element = data[:element]
|
143
|
+
children = data[:children]
|
144
|
+
data = data[:data]
|
145
|
+
|
146
|
+
# replace whole inner html
|
147
|
+
unless data['children'].kind_of? Array
|
148
|
+
return element.inner_html = children
|
149
|
+
end
|
150
|
+
|
151
|
+
if element.children.size.zero?
|
152
|
+
return element.inner_html = children
|
153
|
+
end
|
154
|
+
|
155
|
+
index = data['children'].index(nil)
|
156
|
+
rindex = data['children'].rindex { |item| !item.nil? }
|
157
|
+
|
158
|
+
if index.nil?
|
159
|
+
element.inner_html = children
|
160
|
+
elsif index == 0 # insert to the end of children
|
161
|
+
element.children.last.after(children)
|
162
|
+
elsif index == rindex + 1 # insert to the begin of children
|
163
|
+
element.children.first.before children
|
164
|
+
else # wrap the children
|
165
|
+
element.children.first.before children[0..index]
|
166
|
+
element.children.last.after children[index..children.size]
|
167
|
+
end
|
168
|
+
end
|
151
169
|
end
|
152
170
|
end
|
@@ -24,15 +24,16 @@ module Jekyll::Spaceship
|
|
24
24
|
|
25
25
|
# escape plus sign
|
26
26
|
emoji_name = emoji.name.gsub('+', '\\\+')
|
27
|
+
css_class = self.config['css']['class']
|
27
28
|
|
28
29
|
content = content.gsub(
|
29
30
|
/(?<!\=")\s*:#{emoji_name}:\s*(?!"\s)/,
|
30
|
-
"<img class=\"\""\
|
31
|
+
"<img class=\"#{css_class}\""\
|
31
32
|
" title=\":#{emoji.name}:\""\
|
32
33
|
" alt=\":#{emoji.name}:\""\
|
33
34
|
" raw=\"#{emoji.raw}\""\
|
34
35
|
" src=\"#{config['src']}#{emoji.image_filename}\""\
|
35
|
-
" style=\"vertical-align: middle;"\
|
36
|
+
" style=\"vertical-align: middle; display: inline;"\
|
36
37
|
" max-width: 1em; visibility: hidden;\""\
|
37
38
|
" onload=\"this.style.visibility='visible'\""\
|
38
39
|
" onerror=\"this.replaceWith(this.getAttribute('raw'))\">"\
|
@@ -8,15 +8,15 @@ module Jekyll::Spaceship
|
|
8
8
|
def on_handle_markdown(content)
|
9
9
|
# pre-handle reference-style links
|
10
10
|
references = {}
|
11
|
-
content.scan(
|
11
|
+
content.scan(/\n\s*(\[(.*)\]:\s*(\S+(\s+".*?")?))/) do |match_data|
|
12
12
|
ref_name = match_data[1]
|
13
13
|
ref_value = match_data[2]
|
14
14
|
references[ref_name] = ref_value
|
15
15
|
end
|
16
16
|
if references.size > 0
|
17
|
-
content.scan(
|
17
|
+
content.scan(/[^\n]*(?<!\\)\|[^\n]*/) do |result|
|
18
18
|
references.each do |key, val|
|
19
|
-
replace = result.gsub(/\[(
|
19
|
+
replace = result.gsub(/\[([^\n]*)\]\s*\[#{key}\]/, "[\1](#{val})")
|
20
20
|
next if result == replace
|
21
21
|
content = content.gsub(result, replace)
|
22
22
|
end
|
@@ -24,18 +24,21 @@ module Jekyll::Spaceship
|
|
24
24
|
end
|
25
25
|
|
26
26
|
# pre-handle row-span
|
27
|
-
content = content.gsub(/(?<!\\)(
|
27
|
+
content = content.gsub(/(?<!\\)(\|[^\n]*\\\s*)\|\s*\n/, "\\1\n")
|
28
28
|
|
29
29
|
# escape | and :
|
30
30
|
content = content.gsub(/\|(?=\|)/, '\\|')
|
31
|
-
.gsub(/\\:(
|
32
|
-
.gsub(/((?<!\\)
|
31
|
+
.gsub(/\\:(?=[^\n]*?(?<!\\)\|)/, '\\\\\\\\:')
|
32
|
+
.gsub(/((?<!\\)\|[^\n]*?)(\\:)/, '\1\\\\\\\\:')
|
33
33
|
|
34
34
|
# escape * and _ and $ etc.
|
35
|
-
content.scan(
|
35
|
+
content.scan(/[^\n]*(?<!\\)\|[^\n]*/) do |result|
|
36
|
+
# skip for math expression within pipeline
|
37
|
+
next unless result
|
38
|
+
.gsub(/((?<!\\)\${1,2})[^\n]*?\1/, '')
|
39
|
+
.match(/(?<!\\)\|/)
|
36
40
|
replace = result.gsub(
|
37
|
-
/(?<!(?<!\\)\\)(\*|\$|\[|\(|\"|_)/,
|
38
|
-
'\\\\\\\\\1')
|
41
|
+
/(?<!(?<!\\)\\)(\*|\$|\[|\(|\"|_)/, '\\\\\\\\\1')
|
39
42
|
next if result == replace
|
40
43
|
content = content.gsub(result, replace)
|
41
44
|
end
|
@@ -50,6 +53,7 @@ module Jekyll::Spaceship
|
|
50
53
|
|
51
54
|
# handle each table
|
52
55
|
doc.css('table').each do |table|
|
56
|
+
next if table.ancestors('code, pre').size > 0
|
53
57
|
rows = table.css('tr')
|
54
58
|
data.table = table
|
55
59
|
data.rows = rows
|
@@ -239,7 +243,11 @@ module Jekyll::Spaceship
|
|
239
243
|
.gsub(/(?<!\\)\|/, '\\|')
|
240
244
|
.gsub(/^\s+|\s+$/, '')
|
241
245
|
content = cvter.convert(content)
|
242
|
-
|
246
|
+
content = Nokogiri::HTML.fragment(content)
|
247
|
+
if content.children.first&.name == 'p'
|
248
|
+
content = content.children
|
249
|
+
end
|
250
|
+
cell.inner_html = content.inner_html
|
243
251
|
end
|
244
252
|
end
|
245
253
|
end
|
@@ -110,8 +110,8 @@ module Jekyll::Spaceship
|
|
110
110
|
style = qs['style'] || default['style']
|
111
111
|
allow = qs['allow'] || default['allow']
|
112
112
|
|
113
|
-
css_id.gsub('{id}', id)
|
114
|
-
css_class.gsub('{id}', id)
|
113
|
+
css_id = css_id.gsub('{id}', id)
|
114
|
+
css_class = css_class.gsub('{id}', id)
|
115
115
|
|
116
116
|
url = URI(iframe_url ? "#{iframe_url}#{id}" : url).tap do |v|
|
117
117
|
v.query = URI.encode_www_form(qs) if qs.size > 0
|
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.8.
|
4
|
+
version: 0.8.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- jeffreytse
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-07-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: jekyll
|