jekyll-spaceship 0.8.2 → 0.8.7
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 +62 -1
- data/lib/jekyll-spaceship/cores/manager.rb +1 -1
- data/lib/jekyll-spaceship/cores/processor.rb +8 -6
- data/lib/jekyll-spaceship/processors/emoji-processor.rb +3 -2
- data/lib/jekyll-spaceship/processors/table-processor.rb +81 -7
- data/lib/jekyll-spaceship/version.rb +1 -1
- metadata +3 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c04f1aada8ea0a1dde37b51418f843e1d163e1dd7230cf602a0f7caf5d787b19
|
4
|
+
data.tar.gz: 263b035717beeedaad26f42c896a2265b3be4e9bf977b2883e23d8b678f280db
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 566854587a4dea0b991d755467dd402cc39a86235636c9e95c1fbd042ae6ee7bc28bd26ffd99b0d12a8e56ffcff469193bab5008d319e8408949382dec162bdb
|
7
|
+
data.tar.gz: c79139b158834943705be273a533beef706d028fcbff9f339f08aba027ec85a872c73a522679ab2b69d09c82f6c7bd8f8f551f33bfd369040b510b3db36859c5
|
data/README.md
CHANGED
@@ -101,6 +101,7 @@ Spaceship is a minimalistic, powerful and extremely customizable [Jekyll](https:
|
|
101
101
|
- [1.3 Headerless](#headerless)
|
102
102
|
- [1.4 Cell Alignment](#cell-alignment)
|
103
103
|
- [1.5 Cell Markdown](#cell-markdown)
|
104
|
+
- [1.6 Cell Inline Attributes](#cell-inline-attributes)
|
104
105
|
- [2. MathJax Usage](#2-mathjax-usage)
|
105
106
|
- [2.1 Performance Optimization](#21-performance-optimization)
|
106
107
|
- [2.2 How to use?](#22-how-to-use)
|
@@ -140,7 +141,12 @@ plugins:
|
|
140
141
|
- jekyll-spaceship
|
141
142
|
```
|
142
143
|
|
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
|
+
**💡 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.
|
145
|
+
|
146
|
+
### Additions
|
147
|
+
|
148
|
+
* Here is a GitHub Action named [jekyll-deploy-action](https://github.com/jeffreytse/jekyll-deploy-action) for Jekyll site deployment conveniently. 👍
|
149
|
+
* 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
150
|
|
145
151
|
## Configuration
|
146
152
|
|
@@ -529,6 +535,61 @@ Rowspan is 4
|
|
529
535
|
</tbody>
|
530
536
|
</table>
|
531
537
|
|
538
|
+
#### Cell Inline Attributes
|
539
|
+
|
540
|
+
This feature is very useful for custom cell such as using inline style. (e.g., background, color, font)
|
541
|
+
The idea and syntax comes from the [Maruku](http://maruku.rubyforge.org/) package.
|
542
|
+
|
543
|
+
[](https://kramdown.gettalong.org/syntax.html#block-ials)
|
544
|
+
|
545
|
+
Following are some examples of attributes definitions (ALDs) and afterwards comes the syntax explanation:
|
546
|
+
|
547
|
+
```markdown
|
548
|
+
{:ref-name: #id .cls1 .cls2}
|
549
|
+
{:second: ref-name #id-of-other title="hallo you"}
|
550
|
+
{:other: ref-name second}
|
551
|
+
```
|
552
|
+
|
553
|
+
An ALD line has the following structure:
|
554
|
+
|
555
|
+
- a left brace, optionally preceded by up to three spaces,
|
556
|
+
- followed by a colon, the id and another colon,
|
557
|
+
- followed by attribute definitions (allowed characters are backslash-escaped closing braces or any character except a not escaped closing brace),
|
558
|
+
- followed by a closing brace and optional spaces until the end of the line.
|
559
|
+
|
560
|
+
If there is more than one ALD with the same reference name, the attribute definitions of all the ALDs are processed like they are defined in one ALD.
|
561
|
+
|
562
|
+
An inline attribute list (IAL) is used to attach attributes to another element.
|
563
|
+
Here are some examples for span IALs:
|
564
|
+
|
565
|
+
```markdown
|
566
|
+
{: #id .cls1 .cls2} <!-- #id <=> id="id", .cls1 .cls2 <=> class="cls1 cls2" -->
|
567
|
+
{: ref-name title="hallo you"}
|
568
|
+
{: ref-name class='.cls3' .cls4}
|
569
|
+
```
|
570
|
+
|
571
|
+
Here is an example for custom table cell with IAL:
|
572
|
+
|
573
|
+
```markdown
|
574
|
+
{:color-style: style="background: black;"}
|
575
|
+
{:color-style: style="color: white;"}
|
576
|
+
{:text-style: style="font-weight: 800; text-decoration: underline;"}
|
577
|
+
|
578
|
+
|: Here's an Inline Attribute Lists example :||||
|
579
|
+
| ------- | ------------------ | -------------------- | ------------------ |
|
580
|
+
|: :|: <div style="color: red;"> < Normal HTML Block > </div> :|||
|
581
|
+
| ^^ | Red {: .cls style="background: orange" } |||
|
582
|
+
| ^^ IALs | Green {: #id style="background: green; color: white" } |||
|
583
|
+
| ^^ | Blue {: style="background: blue; color: white" } |||
|
584
|
+
| ^^ | Black {: color-style text-style } |||
|
585
|
+
```
|
586
|
+
|
587
|
+
Code above would be parsed as:
|
588
|
+
|
589
|
+
<img width="580px" src="https://user-images.githubusercontent.com/9413601/88461592-738afb00-ced7-11ea-9aac-3179023742b0.png" alt="IALs">
|
590
|
+
|
591
|
+
Additionally, [here](https://kramdown.gettalong.org/syntax.html#block-ials) you can learn more details about IALs.
|
592
|
+
|
532
593
|
### 2. MathJax Usage
|
533
594
|
|
534
595
|
[MathJax](http://www.mathjax.org/) is an open-source JavaScript display engine for LaTeX, MathML, and AsciiMath notation that works in all modern browsers.
|
@@ -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, :math
|
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,15 +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
160
|
elsif type == :math
|
161
|
-
regex = /(
|
161
|
+
regex = /(((?<!\\)\${1,2})[^\n]*?\1)/
|
162
|
+
elsif type == :liquid_filter
|
163
|
+
regex = /((?<!\\)\{\{[^\n]*?\}\})/
|
162
164
|
end
|
163
165
|
next if regex.nil?
|
164
166
|
content.scan(regex) do |match_data|
|
165
167
|
match = match_data[0]
|
166
168
|
id = @exclusion_store.size
|
167
|
-
content = content.sub(match, "
|
169
|
+
content = content.sub(match, "<!JEKYLL@#{object_id}@#{id}>")
|
168
170
|
@exclusion_store.push match
|
169
171
|
end
|
170
172
|
end
|
@@ -175,7 +177,7 @@ module Jekyll::Spaceship
|
|
175
177
|
while @exclusion_store.size > 0
|
176
178
|
match = @exclusion_store.pop
|
177
179
|
id = @exclusion_store.size
|
178
|
-
content = content.sub("
|
180
|
+
content = content.sub("<!JEKYLL@#{object_id}@#{id}>", match)
|
179
181
|
end
|
180
182
|
@exclusion_store = []
|
181
183
|
content
|
@@ -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'))\">"\
|
@@ -5,10 +5,13 @@ require "nokogiri"
|
|
5
5
|
|
6
6
|
module Jekyll::Spaceship
|
7
7
|
class TableProcessor < Processor
|
8
|
+
ATTR_LIST_PATTERN = /((?<!\\)\{:(?:([A-Za-z]\S*):)?(.*?)(?<!\\)\})/
|
9
|
+
ATTR_LIST_REFS = {}
|
10
|
+
|
8
11
|
def on_handle_markdown(content)
|
9
12
|
# pre-handle reference-style links
|
10
13
|
references = {}
|
11
|
-
content.scan(
|
14
|
+
content.scan(/\n\s*(\[(.*)\]:\s*(\S+(\s+".*?")?))/) do |match_data|
|
12
15
|
ref_name = match_data[1]
|
13
16
|
ref_value = match_data[2]
|
14
17
|
references[ref_name] = ref_value
|
@@ -16,7 +19,9 @@ module Jekyll::Spaceship
|
|
16
19
|
if references.size > 0
|
17
20
|
content.scan(/[^\n]*(?<!\\)\|[^\n]*/) do |result|
|
18
21
|
references.each do |key, val|
|
19
|
-
replace = result.gsub(
|
22
|
+
replace = result.gsub(
|
23
|
+
/\[([^\n\]]*?)\]\s*\[#{key}\]/,
|
24
|
+
"[\1](#{val})")
|
20
25
|
next if result == replace
|
21
26
|
content = content.gsub(result, replace)
|
22
27
|
end
|
@@ -33,12 +38,28 @@ module Jekyll::Spaceship
|
|
33
38
|
|
34
39
|
# escape * and _ and $ etc.
|
35
40
|
content.scan(/[^\n]*(?<!\\)\|[^\n]*/) do |result|
|
41
|
+
# skip for math expression within pipeline
|
42
|
+
next unless result
|
43
|
+
.gsub(/((?<!\\)\${1,2})[^\n]*?\1/, '')
|
44
|
+
.match(/(?<!\\)\|/)
|
36
45
|
replace = result.gsub(
|
37
|
-
/(?<!(?<!\\)\\)(\*|\$|\[|\(|\"|_)/,
|
38
|
-
'\\\\\\\\\1')
|
46
|
+
/(?<!(?<!\\)\\)(\*|\$|\[|\(|\"|_)/, '\\\\\\\\\1')
|
39
47
|
next if result == replace
|
40
48
|
content = content.gsub(result, replace)
|
41
49
|
end
|
50
|
+
|
51
|
+
# pre-handle attribute list (AL)
|
52
|
+
ATTR_LIST_REFS.clear()
|
53
|
+
content.scan(ATTR_LIST_PATTERN) do |result|
|
54
|
+
ref = result[1]
|
55
|
+
list = result[2]
|
56
|
+
next if ref.nil?
|
57
|
+
if ATTR_LIST_REFS.has_key? ref
|
58
|
+
ATTR_LIST_REFS[ref] += list
|
59
|
+
else
|
60
|
+
ATTR_LIST_REFS[ref] = list
|
61
|
+
end
|
62
|
+
end
|
42
63
|
content
|
43
64
|
end
|
44
65
|
|
@@ -66,6 +87,7 @@ module Jekyll::Spaceship
|
|
66
87
|
handle_multi_rows(data)
|
67
88
|
handle_text_align(data)
|
68
89
|
handle_rowspan(data)
|
90
|
+
handle_attr_list(data)
|
69
91
|
end
|
70
92
|
end
|
71
93
|
rows.each do |row|
|
@@ -158,7 +180,7 @@ module Jekyll::Spaceship
|
|
158
180
|
if scope.table.multi_row_cells != cells and scope.table.multi_row_start
|
159
181
|
for i in 0...scope.table.multi_row_cells.count do
|
160
182
|
multi_row_cell = scope.table.multi_row_cells[i]
|
161
|
-
multi_row_cell.inner_html += "<br
|
183
|
+
multi_row_cell.inner_html += "\n<br>\n#{cells[i].inner_html}"
|
162
184
|
end
|
163
185
|
row.remove
|
164
186
|
end
|
@@ -183,7 +205,7 @@ module Jekyll::Spaceship
|
|
183
205
|
span_cell = scope.table.span_row_cells[scope.row.col_index]
|
184
206
|
if span_cell and cell.content.match(/^\s*\^{2}/)
|
185
207
|
cell.content = cell.content.gsub(/^\s*\^{2}/, '')
|
186
|
-
span_cell.inner_html += "<br
|
208
|
+
span_cell.inner_html += "\n<br>\n#{cell.inner_html}"
|
187
209
|
rowspan = span_cell.get_attribute('rowspan') || 1
|
188
210
|
rowspan = rowspan.to_i + 1
|
189
211
|
span_cell.set_attribute('rowspan', "#{rowspan}")
|
@@ -232,6 +254,52 @@ module Jekyll::Spaceship
|
|
232
254
|
cell.set_attribute('style', style)
|
233
255
|
end
|
234
256
|
|
257
|
+
# Examples:
|
258
|
+
# {:ref-name: .cls1 title="hello" }
|
259
|
+
# {: #id ref-name data="world" }
|
260
|
+
# {: #id title="hello" }
|
261
|
+
# {: .cls style="color: #333" }
|
262
|
+
def handle_attr_list(data)
|
263
|
+
cell = data.cell
|
264
|
+
content = cell.inner_html
|
265
|
+
# inline attribute list(IAL) handler
|
266
|
+
ial_handler = ->(list) do
|
267
|
+
list.scan(/(\S+)=("|')(.*?)\2|(\S+)/) do |attr|
|
268
|
+
key = attr[0]
|
269
|
+
val = attr[2]
|
270
|
+
single = attr[3]
|
271
|
+
if !key.nil?
|
272
|
+
val = (cell.get_attribute(key) || '') + val
|
273
|
+
cell.set_attribute(key, val)
|
274
|
+
elsif !single.nil?
|
275
|
+
if single.start_with? '#'
|
276
|
+
key = 'id'
|
277
|
+
val = single[1..-1]
|
278
|
+
elsif single.start_with? '.'
|
279
|
+
key = 'class'
|
280
|
+
val = cell.get_attribute(key) || ''
|
281
|
+
val += (val.size.zero? ? '' : ' ') + single[1..-1]
|
282
|
+
elsif ATTR_LIST_REFS.has_key? single
|
283
|
+
ial_handler.call ATTR_LIST_REFS[single]
|
284
|
+
end
|
285
|
+
unless key.nil?
|
286
|
+
cell.set_attribute(key, val)
|
287
|
+
end
|
288
|
+
end
|
289
|
+
end
|
290
|
+
end
|
291
|
+
# handle attribute list
|
292
|
+
content.scan(ATTR_LIST_PATTERN) do |result|
|
293
|
+
ref = result[1]
|
294
|
+
list = result[2]
|
295
|
+
# handle inline attribute list
|
296
|
+
ial_handler.call list if ref.nil?
|
297
|
+
# remove attr_list
|
298
|
+
content = content.sub(result[0], '')
|
299
|
+
end
|
300
|
+
cell.inner_html = content
|
301
|
+
end
|
302
|
+
|
235
303
|
def handle_format(data)
|
236
304
|
cell = data.cell
|
237
305
|
cvter = self.converter('markdown')
|
@@ -239,8 +307,14 @@ module Jekyll::Spaceship
|
|
239
307
|
content = cell.inner_html
|
240
308
|
.gsub(/(?<!\\)\|/, '\\|')
|
241
309
|
.gsub(/^\s+|\s+$/, '')
|
310
|
+
.gsub(/</, '<')
|
311
|
+
.gsub(/>/, '>')
|
242
312
|
content = cvter.convert(content)
|
243
|
-
|
313
|
+
content = Nokogiri::HTML.fragment(content)
|
314
|
+
if content.children.first&.name == 'p'
|
315
|
+
content = content.children
|
316
|
+
end
|
317
|
+
cell.inner_html = content.inner_html
|
244
318
|
end
|
245
319
|
end
|
246
320
|
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.8.
|
4
|
+
version: 0.8.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- jeffreytse
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-07-
|
11
|
+
date: 2020-07-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: jekyll
|
@@ -169,8 +169,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
169
169
|
- !ruby/object:Gem::Version
|
170
170
|
version: '0'
|
171
171
|
requirements: []
|
172
|
-
|
173
|
-
rubygems_version: 2.7.7
|
172
|
+
rubygems_version: 3.0.8
|
174
173
|
signing_key:
|
175
174
|
specification_version: 4
|
176
175
|
summary: A Jekyll plugin to provide powerful supports for table, mathjax, plantuml,
|