jekyll-spaceship 0.8.5 → 0.8.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +56 -0
- data/lib/jekyll-spaceship/processors/table-processor.rb +67 -2
- 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: 5f3d45fd1335dcec7d9c05900219920869adaa418fd72b29b3fde3fcdfafc14d
|
4
|
+
data.tar.gz: 2e1fc457586b11bfa8d9fc215ba6c870a3f09ea85a78872d72a8692eeb12abcf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5c2b6900e10b029dbedad643eeb19c4d7a8332003e0bf8079af7c792bef622bc04ff550194e82d1dde365fd54fcd3f4f3997e25c357fac149db1f7eaca6cb414
|
7
|
+
data.tar.gz: 9a3b141d78a7d22aceea2e7ca8545c44a070303e4241db7f56adc301917d34bc91ff6dfb5e09df7dbf8a1739cb6c2f4a1c36c5f73fbc1a9884667350789c9bba
|
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)
|
@@ -534,6 +535,61 @@ Rowspan is 4
|
|
534
535
|
</tbody>
|
535
536
|
</table>
|
536
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
|
+
{:font-style: style="font-weight: 800;" }
|
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 font-weight} |||
|
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
|
+
|
537
593
|
### 2. MathJax Usage
|
538
594
|
|
539
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.
|
@@ -5,6 +5,9 @@ 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 = {}
|
@@ -42,6 +45,19 @@ module Jekyll::Spaceship
|
|
42
45
|
next if result == replace
|
43
46
|
content = content.gsub(result, replace)
|
44
47
|
end
|
48
|
+
|
49
|
+
# pre-handle attribute list (AL)
|
50
|
+
ATTR_LIST_REFS.clear()
|
51
|
+
content.scan(ATTR_LIST_PATTERN) do |result|
|
52
|
+
ref = result[1]
|
53
|
+
list = result[2]
|
54
|
+
next if ref.nil?
|
55
|
+
if ATTR_LIST_REFS.has_key? ref
|
56
|
+
ATTR_LIST_REFS[ref] += list
|
57
|
+
else
|
58
|
+
ATTR_LIST_REFS[ref] = list
|
59
|
+
end
|
60
|
+
end
|
45
61
|
content
|
46
62
|
end
|
47
63
|
|
@@ -69,6 +85,7 @@ module Jekyll::Spaceship
|
|
69
85
|
handle_multi_rows(data)
|
70
86
|
handle_text_align(data)
|
71
87
|
handle_rowspan(data)
|
88
|
+
handle_attr_list(data)
|
72
89
|
end
|
73
90
|
end
|
74
91
|
rows.each do |row|
|
@@ -161,7 +178,7 @@ module Jekyll::Spaceship
|
|
161
178
|
if scope.table.multi_row_cells != cells and scope.table.multi_row_start
|
162
179
|
for i in 0...scope.table.multi_row_cells.count do
|
163
180
|
multi_row_cell = scope.table.multi_row_cells[i]
|
164
|
-
multi_row_cell.inner_html += "<br
|
181
|
+
multi_row_cell.inner_html += "\n<br>\n#{cells[i].inner_html}"
|
165
182
|
end
|
166
183
|
row.remove
|
167
184
|
end
|
@@ -186,7 +203,7 @@ module Jekyll::Spaceship
|
|
186
203
|
span_cell = scope.table.span_row_cells[scope.row.col_index]
|
187
204
|
if span_cell and cell.content.match(/^\s*\^{2}/)
|
188
205
|
cell.content = cell.content.gsub(/^\s*\^{2}/, '')
|
189
|
-
span_cell.inner_html += "<br
|
206
|
+
span_cell.inner_html += "\n<br>\n#{cell.inner_html}"
|
190
207
|
rowspan = span_cell.get_attribute('rowspan') || 1
|
191
208
|
rowspan = rowspan.to_i + 1
|
192
209
|
span_cell.set_attribute('rowspan', "#{rowspan}")
|
@@ -235,6 +252,52 @@ module Jekyll::Spaceship
|
|
235
252
|
cell.set_attribute('style', style)
|
236
253
|
end
|
237
254
|
|
255
|
+
# Examples:
|
256
|
+
# {:ref-name: .cls1 title="hello" }
|
257
|
+
# {: #id ref-name data="world" }
|
258
|
+
# {: #id title="hello" }
|
259
|
+
# {: .cls style="color: #333" }
|
260
|
+
def handle_attr_list(data)
|
261
|
+
cell = data.cell
|
262
|
+
content = cell.inner_html
|
263
|
+
# inline attribute list(IAL) handler
|
264
|
+
ial_handler = ->(list) do
|
265
|
+
list.scan(/(\S+)=("|')(.*?)\2|(\S+)/) do |attr|
|
266
|
+
key = attr[0]
|
267
|
+
val = attr[2]
|
268
|
+
single = attr[3]
|
269
|
+
if !key.nil?
|
270
|
+
val = (cell.get_attribute(key) || '') + val
|
271
|
+
cell.set_attribute(key, val)
|
272
|
+
elsif !single.nil?
|
273
|
+
if single.start_with? '#'
|
274
|
+
key = 'id'
|
275
|
+
val = single[1..-1]
|
276
|
+
elsif single.start_with? '.'
|
277
|
+
key = 'class'
|
278
|
+
val = cell.get_attribute(key) || ''
|
279
|
+
val += (val.size.zero? ? '' : ' ') + single[1..-1]
|
280
|
+
elsif ATTR_LIST_REFS.has_key? single
|
281
|
+
ial_handler.call ATTR_LIST_REFS[single]
|
282
|
+
end
|
283
|
+
unless key.nil?
|
284
|
+
cell.set_attribute(key, val)
|
285
|
+
end
|
286
|
+
end
|
287
|
+
end
|
288
|
+
end
|
289
|
+
# handle attribute list
|
290
|
+
content.scan(ATTR_LIST_PATTERN) do |result|
|
291
|
+
ref = result[1]
|
292
|
+
list = result[2]
|
293
|
+
# handle inline attribute list
|
294
|
+
ial_handler.call list if ref.nil?
|
295
|
+
# remove attr_list
|
296
|
+
content = content.sub(result[0], '')
|
297
|
+
end
|
298
|
+
cell.inner_html = content
|
299
|
+
end
|
300
|
+
|
238
301
|
def handle_format(data)
|
239
302
|
cell = data.cell
|
240
303
|
cvter = self.converter('markdown')
|
@@ -242,6 +305,8 @@ module Jekyll::Spaceship
|
|
242
305
|
content = cell.inner_html
|
243
306
|
.gsub(/(?<!\\)\|/, '\\|')
|
244
307
|
.gsub(/^\s+|\s+$/, '')
|
308
|
+
.gsub(/</, '<')
|
309
|
+
.gsub(/>/, '>')
|
245
310
|
content = cvter.convert(content)
|
246
311
|
content = Nokogiri::HTML.fragment(content)
|
247
312
|
if content.children.first&.name == 'p'
|
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.6
|
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-25 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,
|