jekyll-spaceship 0.5.3 → 0.6.3
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/.travis.yml +1 -0
- data/README.md +72 -5
- data/jekyll-spaceship.gemspec +2 -1
- data/lib/jekyll-spaceship.rb +2 -6
- data/lib/jekyll-spaceship/cores/config.rb +55 -0
- data/lib/jekyll-spaceship/cores/manager.rb +3 -2
- data/lib/jekyll-spaceship/cores/processor.rb +35 -5
- data/lib/jekyll-spaceship/processors/emoji-processor.rb +19 -44
- data/lib/jekyll-spaceship/processors/mathjax-processor.rb +11 -7
- data/lib/jekyll-spaceship/processors/plantuml-processor.rb +22 -12
- data/lib/jekyll-spaceship/processors/table-processor.rb +9 -6
- data/lib/jekyll-spaceship/processors/video-processor.rb +33 -17
- data/lib/jekyll-spaceship/version.rb +1 -1
- metadata +18 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8df3e5c04610d7f6ae766303a8b884e1b3bd0047f72ac489275dd26d133d392a
|
4
|
+
data.tar.gz: '0728453eaace46c6d88aa0395f1d17ae88c17a727aa3be9b10236c222fc3d85e'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1b5e65d14b80d87ebb06b9e3c5cc7c71f6d654940d58034ab314d232d5ff6614bd3b22649259d3658690b5e94b5c4e6983214a0b3e4bdd91cd03e7702901a51e
|
7
|
+
data.tar.gz: f7a171a023c65ceb729ade833fe7193b05000aa24483c1bd0bc6201c28df47f69d503aa2612a866aba1627fc86626f63d38b7db41b8d75a616805b14f1d71fff
|
data/.travis.yml
CHANGED
data/README.md
CHANGED
@@ -64,8 +64,8 @@
|
|
64
64
|
|
65
65
|
<div align="center">
|
66
66
|
<h4>
|
67
|
-
<a href="#requirements">Requirements</a> |
|
68
67
|
<a href="#installation">Install</a> |
|
68
|
+
<a href="#configuration">Config</a> |
|
69
69
|
<a href="#usage">Usage</a> |
|
70
70
|
<a href="#credits">Credits</a> |
|
71
71
|
<a href="#license">License</a>
|
@@ -80,10 +80,10 @@
|
|
80
80
|
<br>
|
81
81
|
|
82
82
|
|
83
|
-
|
83
|
+
Spaceship is a minimalistic, powerful and extremely customizable [Jekyll](https://jekyllrb.com/) plugin. It combines everything you may need for convenient work, without unnecessary complications, like a real spaceship.
|
84
84
|
|
85
85
|
<p align="center">
|
86
|
-
<img alt="Jekyll Spaceship Demo" src="https://user-images.githubusercontent.com/9413601/82250463-15451780-997e-11ea-8809-f411586d9508.gif"
|
86
|
+
<img alt="Jekyll Spaceship Demo" src="https://user-images.githubusercontent.com/9413601/82250463-15451780-997e-11ea-8809-f411586d9508.gif" />
|
87
87
|
</p>
|
88
88
|
|
89
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!_
|
@@ -93,6 +93,7 @@ A Jekyll plugin to provide powerful supports for table, mathjax, plantuml, emoji
|
|
93
93
|
|
94
94
|
- [Requirements](#requirements)
|
95
95
|
- [Installation](#installation)
|
96
|
+
- [Configuration](#configuration)
|
96
97
|
- [Usage](#usage)
|
97
98
|
- [1. Table Usage](#1-table-usage)
|
98
99
|
- [1.1 Rowspan and Colspan](#rowspan-and-colspan)
|
@@ -108,10 +109,12 @@ A Jekyll plugin to provide powerful supports for table, mathjax, plantuml, emoji
|
|
108
109
|
- [4.1 Youtube Usage](#youtube-usage)
|
109
110
|
- [4.2 Vimeo Usage](#vimeo-usage)
|
110
111
|
- [4.3 DailyMotion Usage](#dailymotion-usage)
|
112
|
+
- [4.4 General Video Usage](#general-video-usage)
|
111
113
|
- [5. Hybrid HTML with Markdown](#5-hybrid-html-with-markdown)
|
112
114
|
- [6. Markdown Polyfill](#6-markdown-polyfill)
|
113
115
|
- [6.1 Escape Ordered List](#escape-ordered-list)
|
114
116
|
- [7. Emoji Usage](#7-emoji-usage)
|
117
|
+
- [7.1 Emoji Customizing](#71-emoji-customizing)
|
115
118
|
- [Credits](#credits)
|
116
119
|
- [Contributing](#contributing)
|
117
120
|
- [License](#license)
|
@@ -128,14 +131,41 @@ Add jekyll-spaceship plugin in your site's `Gemfile`, and run `bundle install`.
|
|
128
131
|
gem 'jekyll-spaceship'
|
129
132
|
```
|
130
133
|
|
131
|
-
Add jekyll-spaceship to the `
|
134
|
+
Add jekyll-spaceship to the `plugins:` section in your site's `_config.yml`.
|
132
135
|
|
133
136
|
```yml
|
134
137
|
plugins:
|
135
138
|
- jekyll-spaceship
|
136
139
|
```
|
137
140
|
|
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/)
|
141
|
+
**💡 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/) (e.g. [https://github.com/jeffreytse/jekyll-jeffreytse-blog](https://github.com/jeffreytse/jekyll-jeffreytse-blog))
|
142
|
+
|
143
|
+
## Configuration
|
144
|
+
|
145
|
+
This plugin runs with the following configuration options by default. Alternative settings for these options can be explicitly specified in the configuration file `_config.yml`.
|
146
|
+
|
147
|
+
```yml
|
148
|
+
# Where things are
|
149
|
+
jekyll-spaceship:
|
150
|
+
processors:
|
151
|
+
- table-processor
|
152
|
+
- mathjax-processor
|
153
|
+
- plantuml-processor
|
154
|
+
- polyfill-processor
|
155
|
+
- video-processor
|
156
|
+
- emoji-processor
|
157
|
+
mathjax-processor:
|
158
|
+
src: //cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML
|
159
|
+
config:
|
160
|
+
tex2jax:
|
161
|
+
inlineMath:
|
162
|
+
- ['$','$']
|
163
|
+
- ['\(','\)']
|
164
|
+
plantuml-processor:
|
165
|
+
src: http://www.plantuml.com/plantuml/png/
|
166
|
+
emoji-processor:
|
167
|
+
src: https://github.githubassets.com/images/icons/emoji/
|
168
|
+
```
|
139
169
|
|
140
170
|
## Usage
|
141
171
|
|
@@ -501,6 +531,10 @@ $ 2^{\frac{n-1}{3}} $
|
|
501
531
|
$ \int\_a^b f(x)\,dx. $
|
502
532
|
```
|
503
533
|
|
534
|
+
Code above would be parsed as:
|
535
|
+
|
536
|
+
<image alt="MathJax Expression" height="180" src="https://user-images.githubusercontent.com/9413601/82814245-5a5ed180-9ec9-11ea-9d5b-fba303c627ac.png"></image>
|
537
|
+
|
504
538
|
### 3. PlantUML Usage
|
505
539
|
|
506
540
|
[PlantUML](http://plantuml.sourceforge.net/) is a component that allows to quickly write:
|
@@ -529,6 +563,10 @@ Bob -> Alice : hello
|
|
529
563
|
@enduml
|
530
564
|
```
|
531
565
|
|
566
|
+
Code above would be parsed as:
|
567
|
+
|
568
|
+

|
569
|
+
|
532
570
|
### 4. Video Usage
|
533
571
|
|
534
572
|
How often did you find yourself googling "**How to embed a video in markdown?**"
|
@@ -540,6 +578,7 @@ While its not possible to embed a video in markdown, the best and easiest way is
|
|
540
578
|
- Youtube
|
541
579
|
- Vimeo
|
542
580
|
- DailyMotion
|
581
|
+
- General Video ( mp4 | avi | webm | ogg | ogv | 3gp | flv | mov ... )
|
543
582
|
|
544
583
|
There are two ways to embed a video in your Jekyll blog page:
|
545
584
|
|
@@ -598,6 +637,21 @@ the link as below:
|
|
598
637
|

|
599
638
|
```
|
600
639
|
|
640
|
+
#### General Video Usage
|
641
|
+
|
642
|
+
```markdown
|
643
|
+

|
644
|
+
```
|
645
|
+
|
646
|
+
```markdown
|
647
|
+

|
648
|
+
```
|
649
|
+
|
650
|
+
```markdown
|
651
|
+

|
652
|
+
```
|
653
|
+
|
654
|
+
|
601
655
|
### 5. Hybrid HTML with Markdown
|
602
656
|
|
603
657
|
As markdown is not only a lightweight markup language with plain-text-formatting syntax, but also an easy-to-read and easy-to-write plain text format, so writing a hybrid HTML with markdown is an awesome choice.
|
@@ -689,6 +743,19 @@ I give this plugin two :+1:!
|
|
689
743
|
|
690
744
|
I give this plugin two :+1:!
|
691
745
|
|
746
|
+
#### 7.1 Emoji Customizing
|
747
|
+
|
748
|
+
If you'd like to serve emoji images locally, or use a custom emoji source, you can specify so in your `_config.yml` file:
|
749
|
+
|
750
|
+
```yml
|
751
|
+
jekyll-spaceship:
|
752
|
+
emoji-processor:
|
753
|
+
src: "/assets/images/emoji"
|
754
|
+
```
|
755
|
+
|
756
|
+
See the [Gemoji](https://github.com/github/gemoji) documentation for generating image files.
|
757
|
+
|
758
|
+
|
692
759
|
## Credits
|
693
760
|
|
694
761
|
- [Jekyll](https://github.com/jekyll/jekyll) - A blog-aware static site generator in Ruby.
|
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, emoji, youtube, vimeo, dailymotion, etc."
|
12
|
+
spec.summary = "A Jekyll plugin to provide powerful supports for table, mathjax, plantuml, emoji, video, 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 "gemoji", "~> 3.0"
|
23
24
|
spec.add_dependency "rainbow", "~> 3.0"
|
24
25
|
|
25
26
|
spec.add_development_dependency "bundler"
|
data/lib/jekyll-spaceship.rb
CHANGED
@@ -1,16 +1,12 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require 'jekyll-spaceship/cores/logger'
|
4
|
+
require 'jekyll-spaceship/cores/config'
|
4
5
|
require 'jekyll-spaceship/cores/manager'
|
5
6
|
require 'jekyll-spaceship/cores/processor'
|
6
7
|
require 'jekyll-spaceship/cores/register'
|
7
8
|
|
8
9
|
module Jekyll::Spaceship
|
9
10
|
Logger.display_info
|
10
|
-
|
11
|
-
Register.use 'mathjax-processor'
|
12
|
-
Register.use 'plantuml-processor'
|
13
|
-
Register.use 'polyfill-processor'
|
14
|
-
Register.use 'video-processor'
|
15
|
-
Register.use 'emoji-processor'
|
11
|
+
Config.load
|
16
12
|
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'yaml'
|
4
|
+
|
5
|
+
module Jekyll::Spaceship
|
6
|
+
class Config
|
7
|
+
CONFIG_NAME = 'jekyll-spaceship'
|
8
|
+
DEFAULT_CONFIG = {
|
9
|
+
'processors' => [
|
10
|
+
'table-processor',
|
11
|
+
'mathjax-processor',
|
12
|
+
'plantuml-processor',
|
13
|
+
'polyfill-processor',
|
14
|
+
'video-processor',
|
15
|
+
'emoji-processor'
|
16
|
+
]
|
17
|
+
}
|
18
|
+
|
19
|
+
@@store = {}
|
20
|
+
|
21
|
+
def self.deep_merge(first, second)
|
22
|
+
merger = proc do |_, f, s|
|
23
|
+
if Hash === f && Hash === s
|
24
|
+
f.merge(s, &merger)
|
25
|
+
elsif Array === f && Array === s
|
26
|
+
s || f
|
27
|
+
else
|
28
|
+
[:undefined, nil, :nil].include?(s) ? f : s
|
29
|
+
end
|
30
|
+
end
|
31
|
+
first.merge(second.to_h, &merger)
|
32
|
+
end
|
33
|
+
|
34
|
+
def self.store(section, default)
|
35
|
+
return if @@store[section].nil?
|
36
|
+
return @@store[section] if default.nil?
|
37
|
+
@@store[section] = deep_merge(@@store[section], default)
|
38
|
+
end
|
39
|
+
|
40
|
+
def self.load(filename = '_config.yml')
|
41
|
+
config = deep_merge(
|
42
|
+
{ CONFIG_NAME => DEFAULT_CONFIG },
|
43
|
+
YAML.load_file(File.expand_path(filename))
|
44
|
+
)[CONFIG_NAME]
|
45
|
+
@@store = config
|
46
|
+
self.use_processors(config)
|
47
|
+
end
|
48
|
+
|
49
|
+
def self.use_processors(config)
|
50
|
+
config['processors'].each do |processor|
|
51
|
+
Register.use processor
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
@@ -69,7 +69,8 @@ module Jekyll::Spaceship
|
|
69
69
|
end
|
70
70
|
|
71
71
|
def self.ext(page)
|
72
|
-
page.
|
72
|
+
ext = page.path.match(/\.\S+$/)
|
73
|
+
ext.to_s.rstrip
|
73
74
|
end
|
74
75
|
|
75
76
|
def self.output_ext(page)
|
@@ -112,7 +113,7 @@ module Jekyll::Spaceship
|
|
112
113
|
end
|
113
114
|
node.replace Nokogiri::HTML.fragment content
|
114
115
|
end
|
115
|
-
page.output = doc.to_html
|
116
|
+
page.output = Processor.escape_html doc.to_html
|
116
117
|
end
|
117
118
|
end
|
118
119
|
end
|
@@ -18,6 +18,7 @@ module Jekyll::Spaceship
|
|
18
18
|
|
19
19
|
attr_reader :page
|
20
20
|
attr_reader :logger
|
21
|
+
attr_reader :config
|
21
22
|
attr_reader :priority
|
22
23
|
attr_reader :registers
|
23
24
|
attr_reader :exclusions
|
@@ -27,11 +28,21 @@ module Jekyll::Spaceship
|
|
27
28
|
self.class.name.split('::').last
|
28
29
|
end
|
29
30
|
|
31
|
+
def filename
|
32
|
+
self.name
|
33
|
+
.gsub(/([A-Z]+)([A-Z][a-z])/,'\1-\2')
|
34
|
+
.gsub(/([a-z\d])([A-Z])/,'\1-\2')
|
35
|
+
.tr("_", "-")
|
36
|
+
.downcase
|
37
|
+
end
|
38
|
+
|
30
39
|
def initialize()
|
31
40
|
self.initialize_priority
|
32
41
|
self.initialize_register
|
33
42
|
self.initialize_exclusions
|
34
43
|
@logger = Logger.new(self.name)
|
44
|
+
@config = Config.store(self.filename, self.class.config)
|
45
|
+
@handled_files = {}
|
35
46
|
end
|
36
47
|
|
37
48
|
def initialize_priority
|
@@ -46,7 +57,7 @@ module Jekyll::Spaceship
|
|
46
57
|
def initialize_register
|
47
58
|
if @@_registers.size.zero?
|
48
59
|
self.class.register :pages, :pre_render, :post_render
|
49
|
-
self.class.register :
|
60
|
+
self.class.register :documents, :pre_render, :post_render
|
50
61
|
end
|
51
62
|
@registers = Array.new @@_registers
|
52
63
|
@@_registers.clear
|
@@ -72,6 +83,9 @@ module Jekyll::Spaceship
|
|
72
83
|
@@_exclusions = types
|
73
84
|
end
|
74
85
|
|
86
|
+
def self.config
|
87
|
+
end
|
88
|
+
|
75
89
|
def process?
|
76
90
|
Type.html?(output_ext) or Type.markdown?(ext)
|
77
91
|
end
|
@@ -112,6 +126,9 @@ module Jekyll::Spaceship
|
|
112
126
|
end
|
113
127
|
if self.respond_to? method
|
114
128
|
@page.output = self.send method, @page.output
|
129
|
+
if Type.html? output_ext
|
130
|
+
@page.output = self.class.escape_html(@page.output)
|
131
|
+
end
|
115
132
|
end
|
116
133
|
end
|
117
134
|
end
|
@@ -127,7 +144,10 @@ module Jekyll::Spaceship
|
|
127
144
|
end
|
128
145
|
|
129
146
|
def on_handled
|
130
|
-
|
147
|
+
source = page.site.source
|
148
|
+
file = page.path.sub(/^#{source}\//, '')
|
149
|
+
return if @handled_files.has_key? file
|
150
|
+
@handled_files[file] = true
|
131
151
|
logger.log file
|
132
152
|
end
|
133
153
|
|
@@ -136,13 +156,13 @@ module Jekyll::Spaceship
|
|
136
156
|
@exclusions.each do |type|
|
137
157
|
regex = nil
|
138
158
|
if type == :code
|
139
|
-
regex = /(
|
159
|
+
regex = /((`+)\s*(\w*)((?:.|\n)*?)\2)/
|
140
160
|
end
|
141
161
|
next if regex.nil?
|
142
162
|
content.scan(regex) do |match_data|
|
143
163
|
match = match_data[0]
|
144
164
|
id = @exclusion_store.size
|
145
|
-
content = content.
|
165
|
+
content = content.sub(match, "[JEKYLL@#{object_id}@#{id}]")
|
146
166
|
@exclusion_store.push match
|
147
167
|
end
|
148
168
|
end
|
@@ -153,10 +173,20 @@ module Jekyll::Spaceship
|
|
153
173
|
while @exclusion_store.size > 0
|
154
174
|
match = @exclusion_store.pop
|
155
175
|
id = @exclusion_store.size
|
156
|
-
content = content.
|
176
|
+
content = content.sub("[JEKYLL@#{object_id}@#{id}]", match)
|
157
177
|
end
|
158
178
|
@exclusion_store = []
|
159
179
|
content
|
160
180
|
end
|
181
|
+
|
182
|
+
def self.escape_html(content)
|
183
|
+
# escape link
|
184
|
+
content.scan(/((https?:)?\/\/\S+\?[a-zA-Z0-9%\-_=\.&;]+)/) do |result|
|
185
|
+
result = result[0]
|
186
|
+
link = result.gsub('&', '&')
|
187
|
+
content = content.gsub(result, link)
|
188
|
+
end
|
189
|
+
content
|
190
|
+
end
|
161
191
|
end
|
162
192
|
end
|
@@ -1,65 +1,40 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require 'net/http'
|
4
|
-
require 'uri'
|
5
4
|
require 'json'
|
5
|
+
require 'gemoji'
|
6
6
|
|
7
7
|
module Jekyll::Spaceship
|
8
8
|
class EmojiProcessor < Processor
|
9
|
-
|
10
|
-
|
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
|
9
|
+
def self.config
|
10
|
+
{ 'src' => 'https://github.githubassets.com/images/icons/emoji/' }
|
19
11
|
end
|
20
12
|
|
21
13
|
def on_handle_html(content)
|
22
|
-
return content if EMOJI_MARKUP_DATA.size.zero?
|
23
14
|
# handle emoji markup
|
24
|
-
content.scan(/:([\w+-]+):/) do |
|
25
|
-
|
26
|
-
|
27
|
-
next if emoji_image.nil?
|
15
|
+
content.scan(/:([\w\d+-]+):/) do |match|
|
16
|
+
emoji = Emoji.find_by_alias match[0]
|
17
|
+
next if emoji.nil?
|
28
18
|
self.handled = true
|
29
19
|
|
30
|
-
#
|
31
|
-
|
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?
|
20
|
+
# escape plus sign
|
21
|
+
emoji_name = emoji.name.gsub('+', '\\\+')
|
37
22
|
|
38
23
|
content = content.gsub(
|
39
|
-
"
|
40
|
-
"<
|
41
|
-
title=\"
|
42
|
-
alt=\"
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
24
|
+
/(?<!\=")\s*:#{emoji_name}:\s*(?!"\s)/,
|
25
|
+
"<img class=\"emoji\""\
|
26
|
+
" title=\":#{emoji.name}:\""\
|
27
|
+
" alt=\":#{emoji.name}:\""\
|
28
|
+
" raw=\"#{emoji.raw}\""\
|
29
|
+
" src=\"#{config['src']}#{emoji.image_filename}\""\
|
30
|
+
" style=\"vertical-align: middle;"\
|
31
|
+
" max-width: 1em; visibility: hidden;\""\
|
32
|
+
" onload=\"this.style.visibility='visible'\""\
|
33
|
+
" onerror=\"this.replaceWith(this.getAttribute('raw'))\">"\
|
34
|
+
"</img>"
|
49
35
|
)
|
50
36
|
end
|
51
37
|
content
|
52
38
|
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
39
|
end
|
65
40
|
end
|
@@ -4,6 +4,15 @@ require "nokogiri"
|
|
4
4
|
|
5
5
|
module Jekyll::Spaceship
|
6
6
|
class MathjaxProcessor < Processor
|
7
|
+
def self.config
|
8
|
+
{
|
9
|
+
'src' => '//cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML',
|
10
|
+
'config' => {
|
11
|
+
'tex2jax' => { 'inlineMath' => [['$','$'], ['\\(','\\)']] }
|
12
|
+
}
|
13
|
+
}
|
14
|
+
end
|
15
|
+
|
7
16
|
def process?
|
8
17
|
return true if Type.html?(output_ext)
|
9
18
|
end
|
@@ -18,13 +27,8 @@ module Jekyll::Spaceship
|
|
18
27
|
|
19
28
|
self.handled = true
|
20
29
|
|
21
|
-
|
22
|
-
src
|
23
|
-
config = "MathJax.Hub.Config({ \
|
24
|
-
tex2jax: { inlineMath: [['$','$'], ['\\\\(','\\\\)']] } \
|
25
|
-
});"
|
26
|
-
|
27
|
-
head.add_child("<script src=\"#{src}\">#{config}</script>")
|
30
|
+
cfg = "MathJax.Hub.Config(#{config['config'].to_json});"
|
31
|
+
head.add_child("<script src=\"#{config['src']}\">#{cfg}</script>")
|
28
32
|
|
29
33
|
doc.to_html
|
30
34
|
end
|
@@ -1,24 +1,36 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require "net/http"
|
3
4
|
require "base64"
|
4
5
|
|
5
6
|
module Jekyll::Spaceship
|
6
|
-
class
|
7
|
+
class PlantumlProcessor < Processor
|
7
8
|
exclude :none
|
8
9
|
|
9
|
-
|
10
|
+
PLANTUML_PATTERNS = [
|
11
|
+
/(\\?(@startuml)((?:.|\n)*?)@enduml)/,
|
12
|
+
/((`{3,})\s*plantuml((?:.|\n)*?)\2)/
|
13
|
+
]
|
14
|
+
|
15
|
+
def self.config
|
16
|
+
{ 'src' => 'http://www.plantuml.com/plantuml/png/' }
|
17
|
+
end
|
10
18
|
|
11
19
|
def on_handle_markdown(content)
|
12
20
|
# match default plantuml block and code block
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
21
|
+
PLANTUML_PATTERNS.each do |pattern|
|
22
|
+
content = handle_plantuml_block(pattern, content)
|
23
|
+
end
|
24
|
+
|
25
|
+
# handle escape default plantuml block
|
26
|
+
content.gsub(/\\(@startuml|@enduml)/, '\1')
|
27
|
+
end
|
17
28
|
|
29
|
+
def handle_plantuml_block(pattern, content)
|
18
30
|
content.scan pattern do |match|
|
19
31
|
match = match.select { |m| not m.nil? }
|
20
32
|
block = match[0]
|
21
|
-
code = match[
|
33
|
+
code = match[2]
|
22
34
|
|
23
35
|
# skip escape default plantuml block
|
24
36
|
if block.match(/(^\\@startuml|\\@enduml$)/)
|
@@ -32,9 +44,7 @@ module Jekyll::Spaceship
|
|
32
44
|
handle_plantuml(code)
|
33
45
|
)
|
34
46
|
end
|
35
|
-
|
36
|
-
# handle escape default plantuml block
|
37
|
-
content.gsub(/\\(@startuml|@enduml)/, '\1')
|
47
|
+
content
|
38
48
|
end
|
39
49
|
|
40
50
|
def handle_plantuml(code)
|
@@ -46,12 +56,12 @@ module Jekyll::Spaceship
|
|
46
56
|
data = self.get_plantuml_img_data(code)
|
47
57
|
|
48
58
|
# return img tag
|
49
|
-
"<img src=\"#{data}\">"
|
59
|
+
"<img class=\"plantuml\" src=\"#{data}\">"
|
50
60
|
end
|
51
61
|
|
52
62
|
def get_plantuml_img_data(code)
|
53
63
|
data = ''
|
54
|
-
url = "#{
|
64
|
+
url = "#{config['src']}#{code}"
|
55
65
|
begin
|
56
66
|
data = Net::HTTP.get URI(url)
|
57
67
|
data = Base64.encode64(data)
|
@@ -157,7 +157,7 @@ module Jekyll::Spaceship
|
|
157
157
|
if scope.table.multi_row_cells != cells and scope.table.multi_row_start
|
158
158
|
for i in 0...scope.table.multi_row_cells.count do
|
159
159
|
multi_row_cell = scope.table.multi_row_cells[i]
|
160
|
-
multi_row_cell.
|
160
|
+
multi_row_cell.inner_html += "<br>#{cells[i].inner_html}"
|
161
161
|
end
|
162
162
|
row.remove
|
163
163
|
end
|
@@ -182,7 +182,7 @@ module Jekyll::Spaceship
|
|
182
182
|
span_cell = scope.table.span_row_cells[scope.row.col_index]
|
183
183
|
if span_cell and cell.content.match(/^\s*\^{2}/)
|
184
184
|
cell.content = cell.content.gsub(/^\s*\^{2}/, '')
|
185
|
-
span_cell.
|
185
|
+
span_cell.inner_html += "<br>#{cell.inner_html}"
|
186
186
|
rowspan = span_cell.get_attribute('rowspan') || 1
|
187
187
|
rowspan = rowspan.to_i + 1
|
188
188
|
span_cell.set_attribute('rowspan', "#{rowspan}")
|
@@ -207,11 +207,12 @@ module Jekyll::Spaceship
|
|
207
207
|
align += 2
|
208
208
|
end
|
209
209
|
|
210
|
+
# handle text align
|
211
|
+
return if align == 0
|
212
|
+
|
210
213
|
# handle escape colon
|
211
214
|
cell.content = cell.content.gsub(/\\:/, ':')
|
212
215
|
|
213
|
-
# handle text align
|
214
|
-
return if align == 0
|
215
216
|
style = cell.get_attribute('style')
|
216
217
|
if align == 1
|
217
218
|
align = 'text-align: left'
|
@@ -234,8 +235,10 @@ module Jekyll::Spaceship
|
|
234
235
|
cell = data.cell
|
235
236
|
cvter = self.converter('markdown')
|
236
237
|
return if cvter.nil?
|
237
|
-
content = cell.
|
238
|
-
|
238
|
+
content = cell.inner_html
|
239
|
+
.gsub(/(?<!\\)\|/, '\\|')
|
240
|
+
.gsub(/^\s+|\s+$/, '')
|
241
|
+
content = cvter.convert(content)
|
239
242
|
cell.inner_html = Nokogiri::HTML.fragment(content)
|
240
243
|
end
|
241
244
|
end
|
@@ -5,11 +5,23 @@ require 'uri'
|
|
5
5
|
module Jekyll::Spaceship
|
6
6
|
class VideoProcessor < Processor
|
7
7
|
def on_handle_markdown(content)
|
8
|
+
content = handle_normal_video(content)
|
8
9
|
content = handle_youtube(content)
|
9
10
|
content = handle_vimeo(content)
|
10
11
|
content = handle_dailymotion(content)
|
11
12
|
end
|
12
13
|
|
14
|
+
# Examples:
|
15
|
+
# 
|
16
|
+
# 
|
17
|
+
# 
|
18
|
+
def handle_normal_video(content)
|
19
|
+
handle_video(content, {
|
20
|
+
host: '(https?:)?\\/\\/.*\\/',
|
21
|
+
id: '(.+?\\.(avi|mp4|webm|ogg|ogv|flv|mkv|mov|wmv|3gp|rmvb|asf))',
|
22
|
+
})
|
23
|
+
end
|
24
|
+
|
13
25
|
# Examples:
|
14
26
|
# 
|
15
27
|
# 
|
@@ -29,9 +41,7 @@ module Jekyll::Spaceship
|
|
29
41
|
handle_video(content, {
|
30
42
|
host: '(https?:)?\\/\\/vimeo\\.com\\/',
|
31
43
|
id: '([0-9]+)',
|
32
|
-
iframe_url: "https://player.vimeo.com/video/"
|
33
|
-
width: 600,
|
34
|
-
height: 350
|
44
|
+
iframe_url: "https://player.vimeo.com/video/"
|
35
45
|
})
|
36
46
|
end
|
37
47
|
|
@@ -77,24 +87,30 @@ module Jekyll::Spaceship
|
|
77
87
|
next true if v == id or v == ''
|
78
88
|
end
|
79
89
|
|
80
|
-
|
81
|
-
|
82
|
-
|
90
|
+
css_id = qs['id'] || "video-#{id}"
|
91
|
+
css_class = qs['class'] || 'video'
|
92
|
+
width = qs['width'] || data[:width] || "100%"
|
93
|
+
height = qs['height'] || data[:height] || 350
|
94
|
+
frameborder = qs['frameborder'] || 0
|
95
|
+
style = qs['style'] || 'max-width: 600px'
|
96
|
+
allow = qs['allow'] || "encrypted-media; picture-in-picture"
|
83
97
|
|
84
|
-
url = URI("#{iframe_url}#{id}").tap do |v|
|
98
|
+
url = URI(iframe_url ? "#{iframe_url}#{id}" : url).tap do |v|
|
85
99
|
v.query = URI.encode_www_form(qs) if qs.size > 0
|
86
100
|
end
|
87
101
|
|
88
|
-
html = "<iframe
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
102
|
+
html = "<iframe"\
|
103
|
+
" id=\"#{css_id}\""\
|
104
|
+
" class=\"#{css_class}\""\
|
105
|
+
" src=\"#{url}\""\
|
106
|
+
" title=\"#{title}\""\
|
107
|
+
" width=\"#{width}\""\
|
108
|
+
" height=\"#{height}\""\
|
109
|
+
" style=\"#{style}\""\
|
110
|
+
" allow=\"#{allow}\""\
|
111
|
+
" frameborder=\"#{frameborder}\""\
|
112
|
+
" allowfullscreen>" \
|
113
|
+
"</iframe>"
|
98
114
|
|
99
115
|
content = content.gsub(match_data[0], html)
|
100
116
|
self.handled = true
|
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.6.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-
|
11
|
+
date: 2020-06-13 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: gemoji
|
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: rainbow
|
49
63
|
requirement: !ruby/object:Gem::Requirement
|
@@ -117,6 +131,7 @@ files:
|
|
117
131
|
- Rakefile
|
118
132
|
- jekyll-spaceship.gemspec
|
119
133
|
- lib/jekyll-spaceship.rb
|
134
|
+
- lib/jekyll-spaceship/cores/config.rb
|
120
135
|
- lib/jekyll-spaceship/cores/logger.rb
|
121
136
|
- lib/jekyll-spaceship/cores/manager.rb
|
122
137
|
- lib/jekyll-spaceship/cores/processor.rb
|
@@ -157,5 +172,5 @@ rubygems_version: 2.7.7
|
|
157
172
|
signing_key:
|
158
173
|
specification_version: 4
|
159
174
|
summary: A Jekyll plugin to provide powerful supports for table, mathjax, plantuml,
|
160
|
-
emoji, youtube, vimeo, dailymotion, etc.
|
175
|
+
emoji, video, youtube, vimeo, dailymotion, etc.
|
161
176
|
test_files: []
|