jekyll-spaceship 0.4.3 → 0.5.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/FUNDING.yml +12 -0
- data/.travis.yml +1 -0
- data/README.md +117 -8
- data/jekyll-spaceship.gemspec +2 -1
- data/lib/jekyll-spaceship.rb +1 -0
- data/lib/jekyll-spaceship/cores/logger.rb +19 -4
- data/lib/jekyll-spaceship/cores/manager.rb +8 -8
- data/lib/jekyll-spaceship/cores/processor.rb +7 -3
- data/lib/jekyll-spaceship/cores/register.rb +2 -2
- data/lib/jekyll-spaceship/processors/emoji-processor.rb +65 -0
- data/lib/jekyll-spaceship/processors/plantuml-processor.rb +23 -9
- data/lib/jekyll-spaceship/processors/table-processor.rb +14 -11
- data/lib/jekyll-spaceship/processors/video-processor.rb +13 -7
- data/lib/jekyll-spaceship/utils/.keep +0 -0
- data/lib/jekyll-spaceship/version.rb +1 -1
- data/logos/jekyll-spaceship-logo.png +0 -0
- metadata +21 -4
- data/lib/jekyll-spaceship/utils/plantuml/plantuml.jar +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 732fde7e5574c855d85c10741f24c63a1ba695c707772f35fe7d4fba5c4f8826
|
4
|
+
data.tar.gz: 72ec0732f4e9cf9ca469a71585ce54c6aca4d10b5964184277ca14d1abcc97ad
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4cfc08bf4dd2eb0ead97a61b2a6396b8ce79f2c56ac390c2a9cedbd28648d4b51193eaf36a3a005722bb0362245468c66f64b4f5d75f649b0c4bc0d640d5432b
|
7
|
+
data.tar.gz: 8dfcae47fdc9250c4ea68acfe13adecfd348b4e00a24855a6989a6922db959679948ac26d621820d033de2306d2cf8e2973e17eea5aa09f91f77174a7b070f65
|
data/.github/FUNDING.yml
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
# These are supported funding model platforms
|
2
|
+
|
3
|
+
github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
|
4
|
+
patreon: jeffreytse
|
5
|
+
open_collective: # Replace with a single Open Collective username
|
6
|
+
ko_fi: jeffreytse
|
7
|
+
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
|
8
|
+
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
|
9
|
+
liberapay: jeffreytse
|
10
|
+
issuehunt: # Replace with a single IssueHunt username
|
11
|
+
otechie: # Replace with a single Otechie username
|
12
|
+
custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']
|
data/.travis.yml
CHANGED
@@ -27,6 +27,7 @@ deploy:
|
|
27
27
|
secure: AqjHemFJsIxFuudjWzYbUGBpA5wpAB9Ate6oDZMGMnpaoSD2VgfkBDklyFfEh5uuHrh+rU6U9MPv4wknXVIV7gTTY18ATgzciLa+JCVjhAaSoPGSkORT15/kKpVp4IXIoEytj5T9D+8Wc8czd/B1+lMGGu7n7d7gMvg0HsjOLzJtAOYPrRUTaTXDLeIA+rPnsI1IzbvfHzcZvuD70XkBJWN9kiu0djlI6o51XQNumWMJrFAD/NDD3h3tZ0kkI0TalAYbWVRkZ/ZeABKAod3IRAXGt4L2MM2eYqE5KaXb/GE5wISib3I/iTCjjwrNlM+wM9a+mnOkC+elaCJm1LENqP5Ocy9wbOLYmC8i1VpPDXm2bskbj32oy1wf5zeQUf6bnPB+wDmwgCirYb7z2jQlV4BzRRkDCTftfNTa8FIi03kf+i7phjHuj18j/JC3Ww1ApRq71JAuqEnUY0wBaaN3M5abrJsYOxCRnYVPcBn/w8gfkXuhv9xvDG2OgwqIjDiECPjmbeK8Apo9kgKSrfjBQ43q62Ore6SuVCS+PZOOxVnHmfphfT4xc1atyVeMLkSvnWOa/sWTwgOSXqt1TYAEEhb734AsfXeRMzxU/LN1Y4nZ0otuEv+HVHA/XeHLA1Skq9vHhtZaORhJ58Jmwv5oMwA8KC/wPrn0gGtSBPe8zxw=
|
28
28
|
gem: jekyll-spaceship
|
29
29
|
on:
|
30
|
+
rvm: 2.3
|
30
31
|
tags: true
|
31
32
|
repo: jeffreytse/jekyll-spaceship
|
32
33
|
cleanup: false
|
data/README.md
CHANGED
@@ -1,11 +1,93 @@
|
|
1
|
-
|
1
|
+
<h1 align="center">
|
2
|
+
<a href="https://github.com/jeffreytse/jekyll-spaceship">
|
3
|
+
<img alt="spaceship →~ jekyll" src="https://raw.githubusercontent.com/jeffreytse/jekyll-spaceship/master/logos/jekyll-spaceship-logo.png" width="400">
|
4
|
+
</a>
|
5
|
+
<br> 🚀 Jekyll Spaceship 🚀 <br>
|
6
|
+
</h1>
|
2
7
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
8
|
+
<h4 align="center">
|
9
|
+
<a href="https://jekyllrb.org" target="_blank"><code>Jekyll</code></a> plugin for Astronauts.
|
10
|
+
</h4>
|
11
|
+
|
12
|
+
<p align="center">
|
13
|
+
|
14
|
+
<a href="https://travis-ci.org/jeffreytse/jekyll-spaceship">
|
15
|
+
<img src="https://travis-ci.org/jeffreytse/jekyll-spaceship.svg?branch=master"
|
16
|
+
alt="CI Status" />
|
17
|
+
</a>
|
18
|
+
|
19
|
+
<a href="http://badge.fury.io/rb/jekyll-spaceship">
|
20
|
+
<img src="https://badge.fury.io/rb/jekyll-spaceship.svg"
|
21
|
+
alt="Gem Version" />
|
22
|
+
</a>
|
23
|
+
|
24
|
+
<a href="https://codeclimate.com/github/jeffreytse/jekyll-spaceship">
|
25
|
+
<img src="https://codeclimate.com/github/jeffreytse/jekyll-spaceship/badges/gpa.svg"
|
26
|
+
alt="Code Climate" />
|
27
|
+
</a>
|
28
|
+
|
29
|
+
<a href="https://codeclimate.com/github/jeffreytse/jekyll-spaceship/test_coverage">
|
30
|
+
<img src="https://api.codeclimate.com/v1/badges/cd56b207f327603662a1/test_coverage"
|
31
|
+
alt="Test Coverage" />
|
32
|
+
</a>
|
33
|
+
|
34
|
+
<a href="https://github.com/jeffreytse/jekyll-spaceship/blob/master/LICENSE.txt">
|
35
|
+
<img src="https://img.shields.io/badge/License-MIT-brightgreen.svg"
|
36
|
+
alt="License" />
|
37
|
+
</a>
|
38
|
+
|
39
|
+
<a href="http://badge.fury.io/rb/jekyll-spaceship">
|
40
|
+
<img src="https://img.shields.io/gem/dt/jekyll-spaceship"
|
41
|
+
alt="Download Data" />
|
42
|
+
</a>
|
43
|
+
|
44
|
+
</p>
|
45
|
+
|
46
|
+
<p align="center">
|
47
|
+
|
48
|
+
<a href="https://liberapay.com/jeffreytse">
|
49
|
+
<img src="http://img.shields.io/liberapay/goal/jeffreytse.svg?logo=liberapay"
|
50
|
+
alt="Donate (Liberapay)" />
|
51
|
+
</a>
|
52
|
+
|
53
|
+
<a href="https://patreon.com/jeffreytse">
|
54
|
+
<img src="https://img.shields.io/badge/support-patreon-F96854.svg?style=flat-square"
|
55
|
+
alt="Donate (Patreon)" />
|
56
|
+
</a>
|
57
|
+
|
58
|
+
<a href="https://ko-fi.com/jeffreytse">
|
59
|
+
<img height="20" src="https://www.ko-fi.com/img/githubbutton_sm.svg"
|
60
|
+
alt="Donate (Ko-fi)" />
|
61
|
+
</a>
|
62
|
+
|
63
|
+
</p>
|
64
|
+
|
65
|
+
<div align="center">
|
66
|
+
<h4>
|
67
|
+
<a href="#requirements">Requirements</a> |
|
68
|
+
<a href="#installation">Install</a> |
|
69
|
+
<a href="#usage">Usage</a> |
|
70
|
+
<a href="#credits">Credits</a> |
|
71
|
+
<a href="#license">License</a>
|
72
|
+
</h4>
|
73
|
+
</div>
|
74
|
+
|
75
|
+
<div align="center">
|
76
|
+
<sub>Built with ❤︎ by
|
77
|
+
<a href="https://jeffreytse.net">jeffreytse</a> and
|
78
|
+
<a href="https://github.com/jeffreytse/jekyll-spaceship/graphs/contributors">contributors </a>
|
79
|
+
</div>
|
80
|
+
<br>
|
81
|
+
|
82
|
+
|
83
|
+
A Jekyll plugin to provide powerful supports for table, mathjax, plantuml, emoji, youtube, vimeo, dailymotion, etc.
|
84
|
+
|
85
|
+
<p align="center">
|
86
|
+
<img alt="Jekyll Spaceship Demo" src="https://user-images.githubusercontent.com/9413601/82250463-15451780-997e-11ea-8809-f411586d9508.gif" alt="Donate (Ko-fi)" />
|
87
|
+
</p>
|
88
|
+
|
89
|
+
**💡 Tip:** I hope you enjoy using this plugin. If you like this project, **a little star** for it is your way make a clear statement: **My work is valued**. I would appreciate your support! _Thank you!_
|
7
90
|
|
8
|
-
A Jekyll plugin to provide powerful supports for table, mathjax, plantuml, youtube, etc.
|
9
91
|
|
10
92
|
## Table of Contents
|
11
93
|
|
@@ -19,6 +101,8 @@ A Jekyll plugin to provide powerful supports for table, mathjax, plantuml, youtu
|
|
19
101
|
- [1.4 Cell Alignment](#cell-alignment)
|
20
102
|
- [1.5 Cell Markdown](#cell-markdown)
|
21
103
|
- [2. MathJax Usage](#2-mathjax-usage)
|
104
|
+
- [2.1 Performance Optimization](#21-performance-optimization)
|
105
|
+
- [2.2 How to use?](#22-how-to-use)
|
22
106
|
- [3. PlantUML Usage](#3-plantuml-usage)
|
23
107
|
- [4. Video Usage](#4-video-usage)
|
24
108
|
- [4.1 Youtube Usage](#youtube-usage)
|
@@ -27,6 +111,7 @@ A Jekyll plugin to provide powerful supports for table, mathjax, plantuml, youtu
|
|
27
111
|
- [5. Hybrid HTML with Markdown](#5-hybrid-html-with-markdown)
|
28
112
|
- [6. Markdown Polyfill](#6-markdown-polyfill)
|
29
113
|
- [6.1 Escape Ordered List](#escape-ordered-list)
|
114
|
+
- [7. Emoji Usage](#7-emoji-usage)
|
30
115
|
- [Credits](#credits)
|
31
116
|
- [Contributing](#contributing)
|
32
117
|
- [License](#license)
|
@@ -50,6 +135,8 @@ plugins:
|
|
50
135
|
- jekyll-spaceship
|
51
136
|
```
|
52
137
|
|
138
|
+
**💡 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. [Click here for more information.](https://jekyllrb.com/docs/continuous-integration/github-actions/)
|
139
|
+
|
53
140
|
## Usage
|
54
141
|
|
55
142
|
### 1. Table Usage
|
@@ -384,7 +471,7 @@ Rowspan is 4
|
|
384
471
|
|
385
472
|
[MathJax](http://www.mathjax.org/) is an open-source JavaScript display engine for LaTeX, MathML, and AsciiMath notation that works in all modern browsers.
|
386
473
|
|
387
|
-
|
474
|
+
Some of the main features of MathJax include:
|
388
475
|
|
389
476
|
- High-quality display of LaTeX, MathML, and AsciiMath notation in HTML pages
|
390
477
|
- Supported in most browsers with no plug-ins, extra fonts, or special
|
@@ -394,6 +481,12 @@ Rowspan is 4
|
|
394
481
|
advanced functionality
|
395
482
|
- Powerful API for integration with other web applications
|
396
483
|
|
484
|
+
#### 2.1 Performance optimization
|
485
|
+
|
486
|
+
At building stage, the MathJax engine script will be added by automatically checking whether there is a math expression in the page, this feature can help you improve the page performance on loading speed.
|
487
|
+
|
488
|
+
#### 2.2 How to use?
|
489
|
+
|
397
490
|
Put your math expression within \$...\$
|
398
491
|
|
399
492
|
```markdown
|
@@ -472,7 +565,7 @@ the link as below:
|
|
472
565
|
```
|
473
566
|
|
474
567
|
```markdown
|
475
|
-
![](https://www.dailymotion.com/video/x7tfyq3?width=100%&height=400)
|
568
|
+
![](https://www.dailymotion.com/video/x7tfyq3?width=100%&height=400&autoplay=1)
|
476
569
|
```
|
477
570
|
|
478
571
|
#### Youtube Usage
|
@@ -581,11 +674,27 @@ Escaped:
|
|
581
674
|
10. List item Cafe.
|
582
675
|
```
|
583
676
|
|
677
|
+
### 7. Emoji Usage
|
678
|
+
GitHub-flavored emoji images and names would allow emojifying content such as: it's raining :cat:s and :dog:s!
|
679
|
+
|
680
|
+
Noted that emoji images are served from the GitHub.com CDN, with a base URL of [https://github.githubassets.com](https://github.githubassets.com), which results in emoji image URLs like [https://github.githubassets.com/images/icons/emoji/unicode/1f604.png](https://github.githubassets.com/images/icons/emoji/unicode/1f604.png).
|
681
|
+
|
682
|
+
In any page or post, use emoji as you would normally, e.g.
|
683
|
+
|
684
|
+
```
|
685
|
+
I give this plugin two :+1:!
|
686
|
+
```
|
687
|
+
|
688
|
+
**Code above would be parsed as:**
|
689
|
+
|
690
|
+
I give this plugin two :+1:!
|
691
|
+
|
584
692
|
## Credits
|
585
693
|
|
586
694
|
- [Jekyll](https://github.com/jekyll/jekyll) - A blog-aware static site generator in Ruby.
|
587
695
|
- [MultiMarkdown](https://fletcher.github.io/MultiMarkdown-6) - Lightweight markup processor to produce HTML, LaTeX, and more.
|
588
696
|
- [markdown-it-multimd-table](https://github.com/RedBug312/markdown-it-multimd-table) - Multimarkdown table syntax plugin for markdown-it markdown parser.
|
697
|
+
- [jmoji](https://github.com/jekyll/jemoji) - GitHub-flavored emoji plugin for Jekyll.
|
589
698
|
|
590
699
|
## Contributing
|
591
700
|
|
data/jekyll-spaceship.gemspec
CHANGED
@@ -9,7 +9,7 @@ Gem::Specification.new do |spec|
|
|
9
9
|
spec.version = Jekyll::Spaceship::VERSION
|
10
10
|
spec.authors = ["jeffreytse"]
|
11
11
|
spec.email = ["jeffreytse.mail@gmail.com"]
|
12
|
-
spec.summary = "A Jekyll plugin to provide powerful supports for table, mathjax, plantuml, youtube, vimeo, dailymotion, etc."
|
12
|
+
spec.summary = "A Jekyll plugin to provide powerful supports for table, mathjax, plantuml, emoji, youtube, vimeo, dailymotion, etc."
|
13
13
|
spec.homepage = "https://github.com/jeffreytse/jekyll-spaceship"
|
14
14
|
spec.license = "MIT"
|
15
15
|
|
@@ -20,6 +20,7 @@ Gem::Specification.new do |spec|
|
|
20
20
|
|
21
21
|
spec.add_dependency "jekyll", ">= 3.6", "< 5.0"
|
22
22
|
spec.add_dependency "nokogiri", "~> 1.6"
|
23
|
+
spec.add_dependency "rainbow", "~> 3.0"
|
23
24
|
|
24
25
|
spec.add_development_dependency "bundler"
|
25
26
|
spec.add_development_dependency "rake", "~> 12.0"
|
data/lib/jekyll-spaceship.rb
CHANGED
@@ -1,21 +1,36 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require 'jekyll-spaceship/version'
|
4
|
+
require 'rainbow/refinement'
|
5
|
+
|
6
|
+
using Rainbow
|
4
7
|
|
5
8
|
module Jekyll::Spaceship
|
6
9
|
class Logger
|
10
|
+
def initialize(namespace)
|
11
|
+
@namespace = namespace
|
12
|
+
end
|
13
|
+
|
7
14
|
def self.display_info
|
8
|
-
self.log "Jekyll-Spaceship #{Jekyll::Spaceship::VERSION}"
|
9
|
-
self.log 'A Jekyll plugin to provide powerful supports.'
|
10
|
-
self.log 'https://github.com/jeffreytse/jekyll-spaceship'
|
15
|
+
self.log "🚀 Jekyll-Spaceship #{Jekyll::Spaceship::VERSION}"
|
16
|
+
self.log '🎉 A Jekyll plugin to provide powerful supports.'
|
17
|
+
self.log '👉 ' + 'https://github.com/jeffreytse/jekyll-spaceship'.underline
|
11
18
|
end
|
12
19
|
|
13
20
|
def self.log(content)
|
14
|
-
self.output 'Jekyll Spaceship', content
|
21
|
+
self.output 'Jekyll Spaceship', content.bright
|
15
22
|
end
|
16
23
|
|
17
24
|
def self.output(title, content)
|
18
25
|
puts "#{title.rjust(18)}: #{content}"
|
19
26
|
end
|
27
|
+
|
28
|
+
def log(content)
|
29
|
+
if @namespace.nil?
|
30
|
+
self.class.log content
|
31
|
+
else
|
32
|
+
self.class.log "[#{@namespace}] #{content}"
|
33
|
+
end
|
34
|
+
end
|
20
35
|
end
|
21
36
|
end
|
@@ -6,7 +6,7 @@ require __dir__ + '/type'
|
|
6
6
|
module Jekyll::Spaceship
|
7
7
|
class Manager
|
8
8
|
@@_hooks = {}
|
9
|
-
@@
|
9
|
+
@@_processors = []
|
10
10
|
|
11
11
|
def self.add(processor)
|
12
12
|
# register for listening event
|
@@ -15,14 +15,14 @@ module Jekyll::Spaceship
|
|
15
15
|
events = _register.last.uniq
|
16
16
|
events = events.select do |event|
|
17
17
|
next true if event.match(/^post/)
|
18
|
-
next
|
18
|
+
next events.index(event.to_s.gsub(/^pre/, 'post').to_sym).nil?
|
19
19
|
end
|
20
20
|
events.each do |event|
|
21
21
|
self.hook container, event
|
22
22
|
end
|
23
23
|
end
|
24
|
-
@@
|
25
|
-
@@
|
24
|
+
@@_processors.push(processor)
|
25
|
+
@@_processors = @@_processors.sort { |a, b| b.priority <=> a.priority }
|
26
26
|
end
|
27
27
|
|
28
28
|
def self.hook(container, event, &block)
|
@@ -57,13 +57,13 @@ module Jekyll::Spaceship
|
|
57
57
|
end
|
58
58
|
|
59
59
|
def self.dispatch(page, container, event)
|
60
|
-
@@
|
60
|
+
@@_processors.each do |processor|
|
61
61
|
processor.dispatch page, container, event
|
62
62
|
end
|
63
63
|
if event.to_s.start_with?('post') and Type.html? output_ext(page)
|
64
64
|
self.dispatch_html_block(page)
|
65
65
|
end
|
66
|
-
@@
|
66
|
+
@@_processors.each do |processor|
|
67
67
|
processor.on_handled if processor.handled
|
68
68
|
end
|
69
69
|
end
|
@@ -91,7 +91,7 @@ module Jekyll::Spaceship
|
|
91
91
|
next if type.nil?
|
92
92
|
|
93
93
|
# dispatch to on_handle_html_block
|
94
|
-
@@
|
94
|
+
@@_processors.each do |processor|
|
95
95
|
next unless processor.process?
|
96
96
|
content = processor.on_handle_html_block content, type
|
97
97
|
# dispatch to type handlers
|
@@ -106,7 +106,7 @@ module Jekyll::Spaceship
|
|
106
106
|
content = cvter.convert content unless cvter.nil?
|
107
107
|
|
108
108
|
# dispatch to on_handle_html
|
109
|
-
@@
|
109
|
+
@@_processors.each do |processor|
|
110
110
|
next unless processor.process?
|
111
111
|
content = processor.on_handle_html content
|
112
112
|
end
|
@@ -17,16 +17,21 @@ module Jekyll::Spaceship
|
|
17
17
|
@@_priority = nil
|
18
18
|
|
19
19
|
attr_reader :page
|
20
|
+
attr_reader :logger
|
20
21
|
attr_reader :priority
|
21
22
|
attr_reader :registers
|
22
23
|
attr_reader :exclusions
|
23
24
|
attr_accessor :handled
|
24
25
|
|
26
|
+
def name
|
27
|
+
self.class.name.split('::').last
|
28
|
+
end
|
29
|
+
|
25
30
|
def initialize()
|
26
31
|
self.initialize_priority
|
27
32
|
self.initialize_register
|
28
33
|
self.initialize_exclusions
|
29
|
-
|
34
|
+
@logger = Logger.new(self.name)
|
30
35
|
end
|
31
36
|
|
32
37
|
def initialize_priority
|
@@ -122,9 +127,8 @@ module Jekyll::Spaceship
|
|
122
127
|
end
|
123
128
|
|
124
129
|
def on_handled
|
125
|
-
processor = self.class.name.split('::').last
|
126
130
|
file = page.path.gsub(/.*_posts\//, '')
|
127
|
-
|
131
|
+
logger.log file
|
128
132
|
end
|
129
133
|
|
130
134
|
def pre_exclude(content)
|
@@ -24,7 +24,7 @@ module Jekyll::Spaceship
|
|
24
24
|
filename = File.basename(path, '.rb')
|
25
25
|
next if filename.gsub(/-/, '').downcase != name
|
26
26
|
|
27
|
-
Logger.log "use #{filename}"
|
27
|
+
Logger.log "🗂 use #{filename}"
|
28
28
|
require path
|
29
29
|
constants = Jekyll::Spaceship.constants.select do |c|
|
30
30
|
c.downcase.to_s == name
|
@@ -34,7 +34,7 @@ module Jekyll::Spaceship
|
|
34
34
|
_class = Jekyll::Spaceship.const_get(constants.first)
|
35
35
|
next unless _class.is_a? Class
|
36
36
|
|
37
|
-
_class.new
|
37
|
+
Manager.add _class.new
|
38
38
|
end
|
39
39
|
end
|
40
40
|
end
|
@@ -0,0 +1,65 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'net/http'
|
4
|
+
require 'uri'
|
5
|
+
require 'json'
|
6
|
+
|
7
|
+
module Jekyll::Spaceship
|
8
|
+
class EmojiProcessor < Processor
|
9
|
+
EMOJI_MARKUP_HOST = 'https://api.github.com/emojis'
|
10
|
+
EMOJI_MARKUP_DATA = {}
|
11
|
+
|
12
|
+
def initialize
|
13
|
+
super()
|
14
|
+
self.initialize_emoji_data
|
15
|
+
end
|
16
|
+
|
17
|
+
def initialize_emoji_data
|
18
|
+
EMOJI_MARKUP_DATA.update get_emoji_markup_data
|
19
|
+
end
|
20
|
+
|
21
|
+
def on_handle_html(content)
|
22
|
+
return content if EMOJI_MARKUP_DATA.size.zero?
|
23
|
+
# handle emoji markup
|
24
|
+
content.scan(/:([\w+-]+):/) do |match_data|
|
25
|
+
emoji_markup = match_data[0]
|
26
|
+
emoji_image = EMOJI_MARKUP_DATA[emoji_markup]
|
27
|
+
next if emoji_image.nil?
|
28
|
+
self.handled = true
|
29
|
+
|
30
|
+
# convert hex string to unicode
|
31
|
+
unicode = emoji_image.match(/unicode\/([\d\w]+)/)
|
32
|
+
if unicode[1]
|
33
|
+
unicode = "0x#{unicode[1]}".to_i(16)
|
34
|
+
alt = [unicode].pack('U*')
|
35
|
+
end
|
36
|
+
alt = emoji_markup if alt.nil?
|
37
|
+
|
38
|
+
content = content.gsub(
|
39
|
+
":#{emoji_markup}:",
|
40
|
+
"<image class=\"emoji\" \
|
41
|
+
title=\"#{emoji_markup}\" \
|
42
|
+
alt=\"#{alt}\" \
|
43
|
+
src=\"#{emoji_image}\" \
|
44
|
+
style=\"vertical-align: middle; \
|
45
|
+
max-width: 1em; visibility: hidden;\" \
|
46
|
+
onload=\"this.style.visibility='visible'\" \
|
47
|
+
onerror=\"this.replaceWith(this.alt)\"> \
|
48
|
+
</image>"
|
49
|
+
)
|
50
|
+
end
|
51
|
+
content
|
52
|
+
end
|
53
|
+
|
54
|
+
def get_emoji_markup_data
|
55
|
+
data = {}
|
56
|
+
begin
|
57
|
+
source = Net::HTTP.get URI(EMOJI_MARKUP_HOST)
|
58
|
+
data = JSON.parse(source)
|
59
|
+
rescue StandardError => msg
|
60
|
+
logger.log msg
|
61
|
+
end
|
62
|
+
data
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
@@ -1,9 +1,13 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require "base64"
|
4
|
+
|
3
5
|
module Jekyll::Spaceship
|
4
6
|
class PlantUMLProcessor < Processor
|
5
7
|
exclude :none
|
6
8
|
|
9
|
+
PLANT_UML_HOST = 'http://www.plantuml.com/plantuml/png/'
|
10
|
+
|
7
11
|
def on_handle_markdown(content)
|
8
12
|
# match default plantuml block and code block
|
9
13
|
pattern = Regexp.union(
|
@@ -35,18 +39,28 @@ module Jekyll::Spaceship
|
|
35
39
|
|
36
40
|
def handle_plantuml(code)
|
37
41
|
# wrap plantuml code
|
38
|
-
|
39
|
-
|
40
|
-
dir = File.dirname(__FILE__)
|
41
|
-
jar = dir + "/../utils/plantuml/plantuml.jar"
|
42
|
-
echo = "echo -e \"#{uml.gsub('"', '\"')}\""
|
43
|
-
plantuml = "java -jar \"#{jar}\" -pipe 2>/dev/null"
|
42
|
+
code = "@startuml#{code}@enduml".encode('UTF-8')
|
44
43
|
|
45
|
-
#
|
46
|
-
|
44
|
+
# encode to hex string
|
45
|
+
code = '~h' + code.unpack("H*").first
|
46
|
+
data = self.get_plantuml_img_data(code)
|
47
47
|
|
48
48
|
# return img tag
|
49
|
-
"<img src=\"
|
49
|
+
"<img src=\"#{data}\">"
|
50
|
+
end
|
51
|
+
|
52
|
+
def get_plantuml_img_data(code)
|
53
|
+
data = ''
|
54
|
+
url = "#{PLANT_UML_HOST}#{code}"
|
55
|
+
begin
|
56
|
+
data = Net::HTTP.get URI(url)
|
57
|
+
data = Base64.encode64(data)
|
58
|
+
data = "data:image/png;base64, #{data}"
|
59
|
+
rescue StandardError => msg
|
60
|
+
data = url
|
61
|
+
logger.log msg
|
62
|
+
end
|
63
|
+
data
|
50
64
|
end
|
51
65
|
end
|
52
66
|
end
|
@@ -112,19 +112,22 @@ module Jekyll::Spaceship
|
|
112
112
|
end
|
113
113
|
|
114
114
|
# handle colspan
|
115
|
-
result = cell.content.match(/(\s*\|)+$/)
|
116
115
|
if cell == cells.last and scope.row.colspan > 0
|
117
|
-
|
118
|
-
|
119
|
-
|
116
|
+
cells.count.downto(cells.count - scope.row.colspan + 1) do |i|
|
117
|
+
c = cells[i - 1]
|
118
|
+
return unless c.get_attribute('colspan').nil?
|
119
|
+
c.remove
|
120
120
|
end
|
121
121
|
end
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
122
|
+
|
123
|
+
result = cell.content.match(/(\|)+$/)
|
124
|
+
return if result.nil?
|
125
|
+
|
126
|
+
cell.content = cell.content.gsub(/(\|)+$/, '')
|
127
|
+
result = result[0]
|
128
|
+
colspan = result.scan(/\|/).count
|
129
|
+
scope.row.colspan += colspan
|
130
|
+
cell.set_attribute('colspan', colspan + 1)
|
128
131
|
end
|
129
132
|
|
130
133
|
def handle_multi_rows(data)
|
@@ -187,7 +190,7 @@ module Jekyll::Spaceship
|
|
187
190
|
else
|
188
191
|
scope.table.span_row_cells[scope.row.col_index] = cell
|
189
192
|
end
|
190
|
-
scope.row.col_index += 1
|
193
|
+
scope.row.col_index += [cell.get_attribute('colspan').to_i, 1].max
|
191
194
|
end
|
192
195
|
|
193
196
|
def handle_text_align(data)
|
@@ -1,5 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require 'uri'
|
4
|
+
|
3
5
|
module Jekyll::Spaceship
|
4
6
|
class VideoProcessor < Processor
|
5
7
|
def on_handle_markdown(content)
|
@@ -70,22 +72,26 @@ module Jekyll::Spaceship
|
|
70
72
|
url = match_data[2]
|
71
73
|
id = match_data[4]
|
72
74
|
title = match_data[6]
|
73
|
-
|
74
|
-
|
75
|
+
qs = url.match(/(?<=\?)(\S*?)$/)
|
76
|
+
qs = Hash[URI.decode_www_form(qs.to_s)].reject do |k, v|
|
77
|
+
next true if v == id or v == ''
|
78
|
+
end
|
75
79
|
|
76
|
-
|
77
|
-
|
80
|
+
width = qs['width'] || data[:width] || 600
|
81
|
+
height = qs['height'] || data[:height] || 400
|
78
82
|
style = "max-width: 100%" if width.nil?
|
79
|
-
width = data[:width] if width.nil?
|
80
|
-
height = data[:height] if height.nil?
|
81
83
|
|
82
|
-
url = "#{iframe_url}#{id}"
|
84
|
+
url = URI("#{iframe_url}#{id}").tap do |v|
|
85
|
+
v.query = URI.encode_www_form(qs) if qs.size > 0
|
86
|
+
end
|
87
|
+
|
83
88
|
html = "<iframe \
|
84
89
|
src=\"#{url}\" \
|
85
90
|
title=\"#{title}\" \
|
86
91
|
width=\"#{width}\" \
|
87
92
|
height=\"#{height}\" \
|
88
93
|
style=\"#{style}\" \
|
94
|
+
allow=\"autoplay; encrypted-media\" \
|
89
95
|
frameborder=\"0\" \
|
90
96
|
allowfullscreen=\"\">\
|
91
97
|
</iframe>"
|
File without changes
|
Binary file
|
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
|
+
version: 0.5.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- jeffreytse
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-05-
|
11
|
+
date: 2020-05-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: jekyll
|
@@ -44,6 +44,20 @@ dependencies:
|
|
44
44
|
- - "~>"
|
45
45
|
- !ruby/object:Gem::Version
|
46
46
|
version: '1.6'
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: rainbow
|
49
|
+
requirement: !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
51
|
+
- - "~>"
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '3.0'
|
54
|
+
type: :runtime
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
requirements:
|
58
|
+
- - "~>"
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: '3.0'
|
47
61
|
- !ruby/object:Gem::Dependency
|
48
62
|
name: bundler
|
49
63
|
requirement: !ruby/object:Gem::Requirement
|
@@ -94,6 +108,7 @@ extensions: []
|
|
94
108
|
extra_rdoc_files: []
|
95
109
|
files:
|
96
110
|
- ".codeclimate.yml"
|
111
|
+
- ".github/FUNDING.yml"
|
97
112
|
- ".gitignore"
|
98
113
|
- ".travis.yml"
|
99
114
|
- Gemfile
|
@@ -107,13 +122,15 @@ files:
|
|
107
122
|
- lib/jekyll-spaceship/cores/processor.rb
|
108
123
|
- lib/jekyll-spaceship/cores/register.rb
|
109
124
|
- lib/jekyll-spaceship/cores/type.rb
|
125
|
+
- lib/jekyll-spaceship/processors/emoji-processor.rb
|
110
126
|
- lib/jekyll-spaceship/processors/mathjax-processor.rb
|
111
127
|
- lib/jekyll-spaceship/processors/plantuml-processor.rb
|
112
128
|
- lib/jekyll-spaceship/processors/polyfill-processor.rb
|
113
129
|
- lib/jekyll-spaceship/processors/table-processor.rb
|
114
130
|
- lib/jekyll-spaceship/processors/video-processor.rb
|
115
|
-
- lib/jekyll-spaceship/utils
|
131
|
+
- lib/jekyll-spaceship/utils/.keep
|
116
132
|
- lib/jekyll-spaceship/version.rb
|
133
|
+
- logos/jekyll-spaceship-logo.png
|
117
134
|
- script/cibuild
|
118
135
|
- script/test
|
119
136
|
homepage: https://github.com/jeffreytse/jekyll-spaceship
|
@@ -140,5 +157,5 @@ rubygems_version: 2.7.7
|
|
140
157
|
signing_key:
|
141
158
|
specification_version: 4
|
142
159
|
summary: A Jekyll plugin to provide powerful supports for table, mathjax, plantuml,
|
143
|
-
youtube, vimeo, dailymotion, etc.
|
160
|
+
emoji, youtube, vimeo, dailymotion, etc.
|
144
161
|
test_files: []
|
Binary file
|