jekyll-spaceship 0.9.8 → 0.9.9
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 +1 -1
- data/lib/jekyll-spaceship/processors/emoji-processor.rb +5 -0
- data/lib/jekyll-spaceship/processors/mathjax-processor.rb +15 -10
- data/lib/jekyll-spaceship/processors/media-processor.rb +36 -11
- data/lib/jekyll-spaceship/processors/table-processor.rb +17 -9
- 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: 51f0576137305906368ec086aba6c9c11d45799d10dc8a22abd5598a4026251a
|
4
|
+
data.tar.gz: 1a52f85350f6d2b3e128b637ec040108d993534ec554296cdd2b998e26551aec
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1445456d3974c347367ae35c8b8b2ceec320f523931620d3ad4f19f3982ddefff2f9426f9f47318b6e548da9c0b25b0b370733a472250065579c27296785ce49
|
7
|
+
data.tar.gz: f78d6fd69910ea7350b77a6d0c8702214d097e8813032fb4254fa53f4521805c5f2b74c3f1ea8c763cb305b145929d6e12810653952ef57c4c32765048ccaffe
|
data/README.md
CHANGED
@@ -441,7 +441,7 @@ Code above would be parsed as:
|
|
441
441
|
#### Cell Alignment
|
442
442
|
|
443
443
|
Markdown table syntax use colons ":" for forcing column alignment.
|
444
|
-
Therefore, here we also use it for
|
444
|
+
Therefore, here we also use it for forcing cell alignment.
|
445
445
|
|
446
446
|
Table cell can be set alignment separately.
|
447
447
|
|
@@ -37,8 +37,13 @@ module Jekyll::Spaceship
|
|
37
37
|
def emoji_filter(content, selector)
|
38
38
|
# use nokogiri to parse html
|
39
39
|
doc = Nokogiri::HTML(content)
|
40
|
+
|
40
41
|
body = doc.at('body')
|
41
42
|
|
43
|
+
# in case of a page has no the body node, especially when your
|
44
|
+
# page's layout field of front matter is nil or unavailable
|
45
|
+
return content if body.nil?
|
46
|
+
|
42
47
|
# filter nodes (pre, code)
|
43
48
|
nodes = body.css(selector)
|
44
49
|
nodes.each do |node|
|
@@ -107,17 +107,22 @@ module Jekyll::Spaceship
|
|
107
107
|
|
108
108
|
def scan_mathjax_expression(doc, &block)
|
109
109
|
patterns = get_math_patterns()
|
110
|
-
doc
|
111
|
-
|
112
|
-
|
113
|
-
|
110
|
+
doc = doc.clone
|
111
|
+
|
112
|
+
# remove code, pre, figure nodes
|
113
|
+
doc.css('body code, body pre, body figure').each do |node|
|
114
|
+
node.remove
|
115
|
+
end
|
116
|
+
|
117
|
+
# remove scripting mathjax expression
|
118
|
+
doc.css('body script').each do |node|
|
119
|
+
next if node['type']&.match(/math\/tex/)
|
120
|
+
node.remove
|
121
|
+
end
|
122
|
+
|
123
|
+
# scan mathjax expressions
|
124
|
+
doc.css('body *').each do |node|
|
114
125
|
patterns['include'].each do |pattern|
|
115
|
-
# check scripting mathjax expression
|
116
|
-
if node.name == 'script'
|
117
|
-
type = node['type']
|
118
|
-
next unless type
|
119
|
-
next unless type.match(/math\/tex/)
|
120
|
-
end
|
121
126
|
# check normal mathjax expression
|
122
127
|
node.content.scan(pattern) do |result|
|
123
128
|
expr = result[0]
|
@@ -42,7 +42,7 @@ module Jekyll::Spaceship
|
|
42
42
|
handle_media(element, {
|
43
43
|
media_type: 'audio',
|
44
44
|
host: '(https?:\\/\\/)?.*\\/',
|
45
|
-
id: '(.+?\\.(mp3|wav|ogg|mid|midi|aac|wma))'
|
45
|
+
id: '(.+?\\.(mp3|wav|ogg|mid|midi|aac|wma))'
|
46
46
|
})
|
47
47
|
end
|
48
48
|
|
@@ -53,7 +53,7 @@ module Jekyll::Spaceship
|
|
53
53
|
# 
|
54
54
|
def handle_normal_video(element)
|
55
55
|
handle_media(element, {
|
56
|
-
media_type: '
|
56
|
+
media_type: 'video',
|
57
57
|
host: '(https?:\\/\\/)?.*\\/',
|
58
58
|
id: '(.+?\\.(avi|mp4|webm|ogg|ogv|flv|mkv|mov|wmv|3gp|rmvb|asf))'
|
59
59
|
})
|
@@ -90,8 +90,8 @@ module Jekyll::Spaceship
|
|
90
90
|
def handle_dailymotion(element)
|
91
91
|
handle_media(element, {
|
92
92
|
media_type: 'iframe',
|
93
|
-
host: '(https?:)
|
94
|
-
id: '(
|
93
|
+
host: '(https?:)?\\/\\/(?>www\\.)?dai\\.?ly(?>motion\\.com\\/video)?\\/',
|
94
|
+
id: '([a-zA-Z0-9\\_\\-]+)',
|
95
95
|
base_url: "https://www.dailymotion.com/embed/video/"
|
96
96
|
})
|
97
97
|
end
|
@@ -128,7 +128,7 @@ module Jekyll::Spaceship
|
|
128
128
|
src = element.get_attribute('src')
|
129
129
|
title = element.get_attribute('title')
|
130
130
|
id = data[:id_from] === 'html' ? '()' : data[:id]
|
131
|
-
match_data = src
|
131
|
+
match_data = src&.match(/#{host}#{id}\S*/)
|
132
132
|
return if match_data.nil?
|
133
133
|
|
134
134
|
media_type = data[:media_type]
|
@@ -158,6 +158,10 @@ module Jekyll::Spaceship
|
|
158
158
|
cfg['loop'] = qs['loop'] || data[:loop] || cfg['loop']
|
159
159
|
cfg['style'] += ';display: none;' if qs['hidden']
|
160
160
|
handle_audio(element, { cfg: cfg })
|
161
|
+
when 'video'
|
162
|
+
cfg['autoplay'] = qs['autoplay'] || data[:autoplay] || cfg['autoplay']
|
163
|
+
cfg['loop'] = qs['loop'] || data[:loop] || cfg['loop']
|
164
|
+
handle_video(element, { cfg: cfg })
|
161
165
|
when 'iframe'
|
162
166
|
cfg['title'] = title
|
163
167
|
cfg['width'] = qs['width'] || data[:width] || cfg['width']
|
@@ -179,12 +183,32 @@ module Jekyll::Spaceship
|
|
179
183
|
" src=\"#{cfg['src']}\""\
|
180
184
|
" style=\"#{cfg['style']}\""\
|
181
185
|
" controls>" \
|
182
|
-
"
|
186
|
+
" Your browser doesn't support HTML5 audio."\
|
183
187
|
" Here is a <a href=\"#{cfg['src']}\">link to download the audio</a>"\
|
184
|
-
"instead.
|
188
|
+
" instead."\
|
185
189
|
"</audio>"
|
186
|
-
doc = Nokogiri::
|
187
|
-
element.
|
190
|
+
doc = Nokogiri::HTML(html)
|
191
|
+
return if element.parent.nil?
|
192
|
+
element.replace(doc.at('body').children.first)
|
193
|
+
end
|
194
|
+
|
195
|
+
def handle_video(element, data)
|
196
|
+
cfg = data[:cfg]
|
197
|
+
html = "<video"\
|
198
|
+
" id=\"#{cfg['id']}\""\
|
199
|
+
" class=\"#{cfg['class']}\""\
|
200
|
+
" style=\"#{cfg['style']}\""\
|
201
|
+
" #{cfg['autoplay'] ? 'autoplay' : ''}"\
|
202
|
+
" #{cfg['loop'] ? 'loop' : ''}"\
|
203
|
+
" controls>" \
|
204
|
+
" <source src=\"#{cfg['src']}\">" \
|
205
|
+
" Your browser doesn't support HTML5 video."\
|
206
|
+
" Here is a <a href=\"#{cfg['src']}\">link to download the video</a>"\
|
207
|
+
" instead."\
|
208
|
+
"</video>"
|
209
|
+
doc = Nokogiri::HTML(html)
|
210
|
+
return if element.parent.nil?
|
211
|
+
element.replace(doc.at('body').children.first)
|
188
212
|
end
|
189
213
|
|
190
214
|
def handle_iframe(element, data)
|
@@ -201,8 +225,9 @@ module Jekyll::Spaceship
|
|
201
225
|
" frameborder=\"#{cfg['frameborder']}\""\
|
202
226
|
" allowfullscreen>"\
|
203
227
|
"</iframe>"
|
204
|
-
doc = Nokogiri::
|
205
|
-
element.
|
228
|
+
doc = Nokogiri::HTML(html)
|
229
|
+
return if element.parent.nil?
|
230
|
+
element.replace(doc.at('body').children.first)
|
206
231
|
end
|
207
232
|
|
208
233
|
def get_id_from_html(url, pattern)
|
@@ -18,13 +18,21 @@ module Jekyll::Spaceship
|
|
18
18
|
end
|
19
19
|
if references.size > 0
|
20
20
|
content.scan(/[^\n]*(?<!\\)\|[^\n]*/) do |result|
|
21
|
+
replace = result
|
21
22
|
references.each do |key, val|
|
22
|
-
replace =
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
content = content.gsub(result, replace)
|
23
|
+
replace = replace.gsub(
|
24
|
+
/\[([^\n\]]*?)\]\s*\[#{Regexp.escape(key)}\]/,
|
25
|
+
"[\\1](#{val})"
|
26
|
+
)
|
27
27
|
end
|
28
|
+
references.each do |key, val|
|
29
|
+
replace = replace.gsub(
|
30
|
+
/\[#{Regexp.escape(key)}\](?!\s*\(.*?\))/,
|
31
|
+
"[#{key}](#{val})"
|
32
|
+
)
|
33
|
+
end
|
34
|
+
next if result == replace
|
35
|
+
content = content.gsub(result, replace)
|
28
36
|
end
|
29
37
|
end
|
30
38
|
|
@@ -143,10 +151,10 @@ module Jekyll::Spaceship
|
|
143
151
|
end
|
144
152
|
end
|
145
153
|
|
146
|
-
result = cell.
|
154
|
+
result = cell.inner_html.match(/(\|)+$/)
|
147
155
|
return if result.nil?
|
148
156
|
|
149
|
-
cell.
|
157
|
+
cell.inner_html = cell.inner_html.gsub(/(\|)+$/, '')
|
150
158
|
result = result[0]
|
151
159
|
colspan = result.scan(/\|/).count
|
152
160
|
scope.row.colspan += colspan
|
@@ -203,8 +211,8 @@ module Jekyll::Spaceship
|
|
203
211
|
|
204
212
|
# handle rowspan
|
205
213
|
span_cell = scope.table.span_row_cells[scope.row.col_index]
|
206
|
-
if span_cell and cell.
|
207
|
-
cell.
|
214
|
+
if span_cell and cell.inner_html.match(/^\s*\^{2}/)
|
215
|
+
cell.inner_html = cell.inner_html.gsub(/^\s*\^{2}/, '')
|
208
216
|
span_cell.inner_html += "\n<br>\n#{cell.inner_html}"
|
209
217
|
rowspan = span_cell.get_attribute('rowspan') || 1
|
210
218
|
rowspan = rowspan.to_i + 1
|
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.
|
4
|
+
version: 0.9.9
|
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-04-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: jekyll
|