jekyll-spaceship 0.5.4 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +10 -2
- data/lib/jekyll-spaceship.rb +2 -6
- data/lib/jekyll-spaceship/cores/config.rb +65 -0
- data/lib/jekyll-spaceship/cores/processor.rb +10 -0
- data/lib/jekyll-spaceship/processors/emoji-processor.rb +1 -3
- data/lib/jekyll-spaceship/processors/mathjax-processor.rb +2 -7
- data/lib/jekyll-spaceship/processors/plantuml-processor.rb +2 -4
- data/lib/jekyll-spaceship/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2abfd1cf82bdc535d470ecc9e5397dca1e1e82456897fdf7ee2035bb62ae19f4
|
4
|
+
data.tar.gz: bab5a4df56d4ac49a1f9b2838b9a05d1ef5e720e9a0cb7838cc9db23a0a211a0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ddb2c1c75889ada85e605ee06db3f67aa11392c2774d8db3115ced6fafecd4dcdb3d60bef85677502f511926cfaf358227bfe12aad10d622a0726e7e9d3802a2
|
7
|
+
data.tar.gz: 00c0d8b4656c3c14db2a78742033cb7cb9d0b41d86bce8a45b7f332175ce1ec24a55aa32c3bf811d506b4ba07a354ae391ac46f06f71d2e5a790f0025648eae1
|
data/README.md
CHANGED
@@ -128,14 +128,14 @@ Add jekyll-spaceship plugin in your site's `Gemfile`, and run `bundle install`.
|
|
128
128
|
gem 'jekyll-spaceship'
|
129
129
|
```
|
130
130
|
|
131
|
-
Add jekyll-spaceship to the `
|
131
|
+
Add jekyll-spaceship to the `plugins:` section in your site's `_config.yml`.
|
132
132
|
|
133
133
|
```yml
|
134
134
|
plugins:
|
135
135
|
- jekyll-spaceship
|
136
136
|
```
|
137
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/)
|
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/) (e.g. [https://github.com/jeffreytse/jekyll-jeffreytse-blog](https://github.com/jeffreytse/jekyll-jeffreytse-blog))
|
139
139
|
|
140
140
|
## Usage
|
141
141
|
|
@@ -501,6 +501,10 @@ $ 2^{\frac{n-1}{3}} $
|
|
501
501
|
$ \int\_a^b f(x)\,dx. $
|
502
502
|
```
|
503
503
|
|
504
|
+
Code above would be parsed as:
|
505
|
+
|
506
|
+
<image alt="MathJax Expression" height="180" src="https://user-images.githubusercontent.com/9413601/82814245-5a5ed180-9ec9-11ea-9d5b-fba303c627ac.png"></image>
|
507
|
+
|
504
508
|
### 3. PlantUML Usage
|
505
509
|
|
506
510
|
[PlantUML](http://plantuml.sourceforge.net/) is a component that allows to quickly write:
|
@@ -529,6 +533,10 @@ Bob -> Alice : hello
|
|
529
533
|
@enduml
|
530
534
|
```
|
531
535
|
|
536
|
+
Code above would be parsed as:
|
537
|
+
|
538
|
+
![PlantUML Diagram](https://user-images.githubusercontent.com/9413601/82813883-9180b300-9ec8-11ea-8778-f450e0056938.png)
|
539
|
+
|
532
540
|
### 4. Video Usage
|
533
541
|
|
534
542
|
How often did you find yourself googling "**How to embed a video in markdown?**"
|
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,65 @@
|
|
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
|
+
'mathjax-processor' => {
|
18
|
+
'src' => '//cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML',
|
19
|
+
'config' => {
|
20
|
+
'tex2jax' => { 'inlineMath' => [['$','$'], ['\\(','\\)']] }
|
21
|
+
}
|
22
|
+
},
|
23
|
+
'plantuml-processor' => {
|
24
|
+
'src' => 'http://www.plantuml.com/plantuml/png/'
|
25
|
+
},
|
26
|
+
'emoji-processor' => {
|
27
|
+
'src' => 'https://github.githubassets.com/images/icons/emoji/'
|
28
|
+
}
|
29
|
+
}
|
30
|
+
|
31
|
+
@@store = {}
|
32
|
+
|
33
|
+
def self.deep_merge(first, second)
|
34
|
+
merger = proc do |_, f, s|
|
35
|
+
if Hash === f && Hash === s
|
36
|
+
f.merge(s, &merger)
|
37
|
+
elsif Array === f && Array === s
|
38
|
+
s || f
|
39
|
+
else
|
40
|
+
[:undefined, nil, :nil].include?(s) ? f : s
|
41
|
+
end
|
42
|
+
end
|
43
|
+
first.merge(second.to_h, &merger)
|
44
|
+
end
|
45
|
+
|
46
|
+
def self.store(section)
|
47
|
+
@@store[section]
|
48
|
+
end
|
49
|
+
|
50
|
+
def self.load(filename = '_config.yml')
|
51
|
+
config = deep_merge(
|
52
|
+
{ CONFIG_NAME => DEFAULT_CONFIG },
|
53
|
+
YAML.load_file(File.expand_path(filename))
|
54
|
+
)[CONFIG_NAME]
|
55
|
+
@@store = config
|
56
|
+
self.use_processors(config)
|
57
|
+
end
|
58
|
+
|
59
|
+
def self.use_processors(config)
|
60
|
+
config['processors'].each do |processor|
|
61
|
+
Register.use processor
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
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,20 @@ 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)
|
35
45
|
end
|
36
46
|
|
37
47
|
def initialize_priority
|
@@ -6,8 +6,6 @@ require 'gemoji'
|
|
6
6
|
|
7
7
|
module Jekyll::Spaceship
|
8
8
|
class EmojiProcessor < Processor
|
9
|
-
EMOJI_MARKUP_HOST = 'https://github.githubassets.com/images/icons/emoji/'
|
10
|
-
|
11
9
|
def on_handle_html(content)
|
12
10
|
# handle emoji markup
|
13
11
|
content.scan(/:([\w\d+-]+):/) do |match|
|
@@ -24,7 +22,7 @@ module Jekyll::Spaceship
|
|
24
22
|
title=\":#{emoji.name}:\" \
|
25
23
|
alt=\":#{emoji.name}:\" \
|
26
24
|
raw=\"#{emoji.raw}\" \
|
27
|
-
src=\"#{
|
25
|
+
src=\"#{config['src']}#{emoji.image_filename}\" \
|
28
26
|
style=\"vertical-align: middle; \
|
29
27
|
max-width: 1em; visibility: hidden;\" \
|
30
28
|
onload=\"this.style.visibility='visible'\" \
|
@@ -18,13 +18,8 @@ module Jekyll::Spaceship
|
|
18
18
|
|
19
19
|
self.handled = true
|
20
20
|
|
21
|
-
|
22
|
-
src
|
23
|
-
config = "MathJax.Hub.Config({ \
|
24
|
-
tex2jax: { inlineMath: [['$','$'], ['\\\\(','\\\\)']] } \
|
25
|
-
});"
|
26
|
-
|
27
|
-
head.add_child("<script src=\"#{src}\">#{config}</script>")
|
21
|
+
cfg = "MathJax.Hub.Config(#{config['config'].to_json});"
|
22
|
+
head.add_child("<script src=\"#{config['src']}\">#{cfg}</script>")
|
28
23
|
|
29
24
|
doc.to_html
|
30
25
|
end
|
@@ -4,11 +4,9 @@ require "net/http"
|
|
4
4
|
require "base64"
|
5
5
|
|
6
6
|
module Jekyll::Spaceship
|
7
|
-
class
|
7
|
+
class PlantumlProcessor < Processor
|
8
8
|
exclude :none
|
9
9
|
|
10
|
-
PLANT_UML_HOST = 'http://www.plantuml.com/plantuml/png/'
|
11
|
-
|
12
10
|
def on_handle_markdown(content)
|
13
11
|
# match default plantuml block and code block
|
14
12
|
pattern = Regexp.union(
|
@@ -52,7 +50,7 @@ module Jekyll::Spaceship
|
|
52
50
|
|
53
51
|
def get_plantuml_img_data(code)
|
54
52
|
data = ''
|
55
|
-
url = "#{
|
53
|
+
url = "#{config['src']}#{code}"
|
56
54
|
begin
|
57
55
|
data = Net::HTTP.get URI(url)
|
58
56
|
data = Base64.encode64(data)
|
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.0
|
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-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: jekyll
|
@@ -131,6 +131,7 @@ files:
|
|
131
131
|
- Rakefile
|
132
132
|
- jekyll-spaceship.gemspec
|
133
133
|
- lib/jekyll-spaceship.rb
|
134
|
+
- lib/jekyll-spaceship/cores/config.rb
|
134
135
|
- lib/jekyll-spaceship/cores/logger.rb
|
135
136
|
- lib/jekyll-spaceship/cores/manager.rb
|
136
137
|
- lib/jekyll-spaceship/cores/processor.rb
|