jekyll-wns 3.3.1 β 4.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/gem-push.yml +1 -1
- data/Gemfile +2 -0
- data/README.md +39 -2
- data/jekyll-wns.gemspec +3 -1
- data/lib/jekyll-wns.rb +4 -1
- data/lib/jekyll-wns/assets/abbreviations.rb +15 -6
- data/lib/jekyll-wns/assets/file_property_filters.rb +39 -0
- data/lib/jekyll-wns/assets/label_unicode.rb +19 -0
- data/lib/jekyll-wns/assets/quads.rb +3 -1
- data/lib/jekyll-wns/assets/ruby_tag.rb +21 -0
- data/lib/jekyll-wns/assets/scene_break_tag.rb +1 -1
- data/lib/jekyll-wns/register_filters.rb +1 -1
- data/lib/jekyll-wns/register_hooks.rb +15 -6
- data/lib/jekyll-wns/register_tags.rb +1 -0
- metadata +20 -5
- data/lib/.ruby-version +0 -1
- data/lib/jekyll-wns/assets/file_properties_filter.rb +0 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 310b65aa25c9965524dcd5fd5e4f1b744fbf6d7640403ffa0c2ca257dae4c246
|
4
|
+
data.tar.gz: ac7e510fd0c70e90df4fe5e51961ee4e691c787c5de5451cd40c38b56eed8c06
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b84558f5db3a205b2fb788040ba239ff6ec6247c3a200c0e023e7e792f9782bd9eb482fd604e8de90a31859b9e73d2abbfe8be05200bda21cf05297b9dcead3b
|
7
|
+
data.tar.gz: 9d35693e10e8ce1667a2fb971dd7f832f8522988c044d5a33980233b3fc334b9fade0e29966dc7d6926d49b6ba3070838a383804c24a77029121ad459131f5e3
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -4,11 +4,11 @@ A collection of filters, tags and hooks that I use on my pages.
|
|
4
4
|
|
5
5
|
## Installation
|
6
6
|
|
7
|
-
1.
|
7
|
+
1. Run Μ bundle add jekyll-wns` and
|
8
8
|
2. Add the following to your site's `_config.yml`:
|
9
9
|
|
10
10
|
```yml
|
11
|
-
|
11
|
+
plugins:
|
12
12
|
- jekyll-wns
|
13
13
|
```
|
14
14
|
|
@@ -76,6 +76,24 @@ gems:
|
|
76
76
|
<p style="text-align:center" data-mce-style="text-align:center">πΏπΎπΏπΎπΏπΎπΏπΎ
|
77
77
|
```
|
78
78
|
|
79
|
+
#### Ruby Annotations
|
80
|
+
|
81
|
+
```liquid
|
82
|
+
{% ruby b|t %}
|
83
|
+
|
84
|
+
{% ruby a#b|t#s %}
|
85
|
+
|
86
|
+
{% ruby a#b#c|x#y#z %}
|
87
|
+
```
|
88
|
+
|
89
|
+
```html
|
90
|
+
<p><ruby><span class="rb first last" aria-hidden="true">b</span><rp>(</rp><rt first="" last="">t</rt><rp>)</rp></ruby></p>
|
91
|
+
|
92
|
+
<p><ruby><span class="rb first" aria-hidden="true">a</span><rp>(</rp><rt first="">t</rt><rp>)</rp><span class="rb last" aria-hidden="true">b</span><rp>(</rp><rt last="">s</rt><rp>)</rp></ruby></p>
|
93
|
+
|
94
|
+
<p><ruby><span class="rb first" aria-hidden="true">a</span><rp>(</rp><rt first="">x</rt><rp>)</rp><span class="rb" aria-hidden="true">b</span><rp>(</rp><rt>y</rt><rp>)</rp><span class="rb last" aria-hidden="true">c</span><rp>(</rp><rt last="">z</rt><rp>)</rp></ruby></p>
|
95
|
+
```
|
96
|
+
|
79
97
|
#### YouTube Embed
|
80
98
|
|
81
99
|
The following snippet should be integrated into your site for the tag to properly work:
|
@@ -146,3 +164,22 @@ With `abbreviations: true`:
|
|
146
164
|
```html
|
147
165
|
β¦ tools, e. \g., hammer,β¦
|
148
166
|
```
|
167
|
+
|
168
|
+
### Automatic labelling of Unicode Characters
|
169
|
+
|
170
|
+
Some assistive technologies don't play nice with Unicode character, this should improve thing by adding aria-labels spans to wherever necessary.
|
171
|
+
|
172
|
+
To enable this, add this to your `_config.yml`:
|
173
|
+
|
174
|
+
```yml
|
175
|
+
wns:
|
176
|
+
label_unicode: true
|
177
|
+
```
|
178
|
+
|
179
|
+
```markdown
|
180
|
+
Hyda-β
£
|
181
|
+
```
|
182
|
+
|
183
|
+
```html
|
184
|
+
Hyda-<span aria-label="4">β
£</span>
|
185
|
+
```
|
data/jekyll-wns.gemspec
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |spec|
|
4
4
|
spec.name = "jekyll-wns"
|
5
|
-
spec.version = "
|
5
|
+
spec.version = "4.1.0"
|
6
6
|
spec.authors = ["Thai Chung"]
|
7
7
|
spec.email = ["mail@0xReki.de"]
|
8
8
|
spec.summary = "Collection of Filters, Tags and Hooks I use."
|
@@ -10,4 +10,6 @@ Gem::Specification.new do |spec|
|
|
10
10
|
spec.licenses = "MIT"
|
11
11
|
|
12
12
|
spec.files = `git ls-files -z`.split("\x0")
|
13
|
+
|
14
|
+
spec.add_dependency("ruby-mp3info", "~> 0.8.10")
|
13
15
|
end
|
data/lib/jekyll-wns.rb
CHANGED
@@ -2,11 +2,14 @@ require 'liquid'
|
|
2
2
|
require 'jekyll'
|
3
3
|
|
4
4
|
require_relative 'jekyll-wns/assets/abbreviations'
|
5
|
+
require_relative 'jekyll-wns/assets/label_unicode'
|
5
6
|
require_relative 'jekyll-wns/assets/quads'
|
6
7
|
|
7
8
|
require_relative 'jekyll-wns/assets/digest_filters'
|
8
|
-
require_relative 'jekyll-wns/assets/
|
9
|
+
require_relative 'jekyll-wns/assets/file_property_filters'
|
9
10
|
require_relative 'jekyll-wns/assets/quads_filter'
|
11
|
+
|
12
|
+
require_relative 'jekyll-wns/assets/ruby_tag'
|
10
13
|
require_relative 'jekyll-wns/assets/scene_break_tag'
|
11
14
|
require_relative 'jekyll-wns/assets/youtube_tag'
|
12
15
|
|
@@ -1,9 +1,16 @@
|
|
1
1
|
module WNS
|
2
2
|
module Abbreviations
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
3
|
+
INNER_DOTS_EXPRESSION = /([a-zA-Z]\.)([a-zA-Z]\.)([a-zA-Z]\.|)([a-zA-Z]\.|)([a-zA-Z]\.|)(,|) /
|
4
|
+
INNER_DOTS_REPLACEMENT = "\\1 \\2 \\3 \\4 \\5 \\6 "
|
5
|
+
|
6
|
+
TITLE_EXPRESSION = /(Mr|Ms|Mrs|Messrs|Mmes|Msgr|Prof|Rev|Dr|Sr|St|[A-Z][a-z]|[A-Z][a-z][a-z])(\.|\.,|,) /
|
7
|
+
TITLE_REPLACEMENT = "\\1\\2 "
|
8
|
+
|
9
|
+
PREFIX_EXPRESSION = /, ([a-zA-Z]\.&)/
|
10
|
+
PREFIX_REPLACEMENT = ", \\1"
|
11
|
+
|
12
|
+
COLLAPSE_SPACES_EXPRESSION = /( )*( |,)/
|
13
|
+
COLLAPSE_SPACES_REPLACEMENT = "\\2"
|
7
14
|
|
8
15
|
def self.enabled?(doc)
|
9
16
|
wns = doc.site.config["wns"] || {}
|
@@ -12,8 +19,10 @@ module WNS
|
|
12
19
|
|
13
20
|
def self.replace_abbreviations!(doc)
|
14
21
|
if Abbreviations::enabled?(doc)
|
15
|
-
doc.content = doc.content.gsub(Abbreviations::
|
16
|
-
doc.content = doc.content.gsub(Abbreviations::
|
22
|
+
doc.content = doc.content.gsub(Abbreviations::INNER_DOTS_EXPRESSION, Abbreviations::INNER_DOTS_REPLACEMENT)
|
23
|
+
doc.content = doc.content.gsub(Abbreviations::TITLE_EXPRESSION, Abbreviations::TITLE_REPLACEMENT)
|
24
|
+
doc.content = doc.content.gsub(Abbreviations::PREFIX_EXPRESSION, Abbreviations::PREFIX_REPLACEMENT)
|
25
|
+
doc.content = doc.content.gsub(Abbreviations::COLLAPSE_SPACES_EXPRESSION, Abbreviations::COLLAPSE_SPACES_REPLACEMENT)
|
17
26
|
end
|
18
27
|
end
|
19
28
|
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require 'mp3info'
|
2
|
+
|
3
|
+
module WNS
|
4
|
+
module FilePropertyFilters
|
5
|
+
def file_size(path)
|
6
|
+
source = Jekyll.configuration({})['source']
|
7
|
+
|
8
|
+
unless source.empty?
|
9
|
+
source += '/'
|
10
|
+
else
|
11
|
+
source = ''
|
12
|
+
end
|
13
|
+
full_path = source + path
|
14
|
+
|
15
|
+
unless path.nil?
|
16
|
+
File.size full_path
|
17
|
+
else
|
18
|
+
0
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def mp3_duration(path)
|
23
|
+
source = Jekyll.configuration({})['source'] || ''
|
24
|
+
|
25
|
+
unless source.empty?
|
26
|
+
source += '/'
|
27
|
+
else
|
28
|
+
source = ''
|
29
|
+
end
|
30
|
+
full_path = source + path
|
31
|
+
|
32
|
+
unless path.nil?
|
33
|
+
Mp3Info.open(full_path).length.to_i
|
34
|
+
else
|
35
|
+
0
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module WNS
|
2
|
+
module LabelUnicode
|
3
|
+
SYMBOLS = [/(β
)/, /(β
‘)/, /(β
’)/, /(β
£)/, /(β
€)/, /(β
₯)/, /(β
¦)/, /(β
§)/, /(β
¨)/, /(β
©)/]
|
4
|
+
READINGS = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10']
|
5
|
+
|
6
|
+
def self.enabled?(doc)
|
7
|
+
wns = doc.site.config["wns"] || {}
|
8
|
+
wns["label_unicode"] || false
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.label_unicode!(doc)
|
12
|
+
if LabelUnicode::enabled?(doc)
|
13
|
+
for i in (0..(LabelUnicode::SYMBOLS.length()) - 1) do
|
14
|
+
doc.content = doc.content.gsub(Regexp.new("([\\-A-Za-z0-9]*|)#{LabelUnicode::SYMBOLS[i].source}([\\-A-Za-z0-9]*|)"), "<span aria-label='\\1#{LabelUnicode::READINGS[i]}\\3'>\\1\\2\\3</span>")
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module WNS
|
2
|
+
class RubyTag < Liquid::Tag
|
3
|
+
def initialize(tag_name, text, tokens)
|
4
|
+
super
|
5
|
+
|
6
|
+
@text = text.strip!.split("|")
|
7
|
+
end
|
8
|
+
|
9
|
+
def render(context)
|
10
|
+
base = @text[0].split("#")
|
11
|
+
text = @text[1].split("#")
|
12
|
+
output = "<ruby>"
|
13
|
+
i = 0
|
14
|
+
while i < base.length()
|
15
|
+
output += "<span class='rb" + (i == 0 ? " first" : "") + (i == base.length() - 1 ? " last" : "") + "' aria-hidden='true'>#{base[i]}</span><rp>(</rp><rt" + (i == 0 ? " first" : "") + (i == base.length() - 1 ? " last" : "") + ">#{text[i]}</rt><rp>)</rp>"
|
16
|
+
i += 1
|
17
|
+
end
|
18
|
+
output += "</ruby>"
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -13,7 +13,7 @@ module WNS
|
|
13
13
|
when "wave"
|
14
14
|
'<p style="text-align:center;letter-spacing:-.13em" data-mce-style="text-align:center;letter-spacing:-.13em">β β‘β β‘β β‘β β‘β β‘β β‘β β‘β β‘β β‘β β‘β β</p>'
|
15
15
|
when "wall"
|
16
|
-
'<p style="text-align:center;letter-spacing:-.2em" data-mce-style="text-align:center;letter-spacing:-.2em"
|
16
|
+
'<p style="text-align:center;letter-spacing:-.2em" data-mce-style="text-align:center;letter-spacing:-.2em">ββββββββββββββββββββ</p>'
|
17
17
|
else
|
18
18
|
'<p style="text-align:center" data-mce-style="text-align:center">πΏπΎπΏπΎπΏπΎπΏπΎπΏπΎπΏπΎπΏπΎπΏ</p>'
|
19
19
|
end
|
@@ -1,14 +1,23 @@
|
|
1
|
-
Jekyll::Hooks.register :
|
2
|
-
|
3
|
-
|
1
|
+
Jekyll::Hooks.register :pages, :pre_render do |document|
|
2
|
+
if document.path =~ /(.md|.html)/
|
3
|
+
WNS::Abbreviations::replace_abbreviations! document
|
4
|
+
WNS::LabelUnicode::label_unicode! document
|
5
|
+
WNS::Quads::insert_quads_into_document! document
|
6
|
+
end
|
4
7
|
end
|
5
8
|
|
6
|
-
Jekyll::Hooks.register :pages, :
|
7
|
-
|
8
|
-
|
9
|
+
Jekyll::Hooks.register :pages, :post_render do |document|
|
10
|
+
if document.path =~ /(.md|.html)/
|
11
|
+
true
|
12
|
+
end
|
9
13
|
end
|
10
14
|
|
11
15
|
Jekyll::Hooks.register :posts, :pre_render do |document|
|
12
16
|
WNS::Abbreviations::replace_abbreviations! document
|
17
|
+
WNS::LabelUnicode::label_unicode! document
|
13
18
|
WNS::Quads::insert_quads_into_document! document
|
14
19
|
end
|
20
|
+
|
21
|
+
Jekyll::Hooks.register :posts, :post_render do |document|
|
22
|
+
true
|
23
|
+
end
|
metadata
CHANGED
@@ -1,15 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jekyll-wns
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 4.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Thai Chung
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-06-
|
12
|
-
dependencies:
|
11
|
+
date: 2021-06-26 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: ruby-mp3info
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 0.8.10
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 0.8.10
|
13
27
|
description:
|
14
28
|
email:
|
15
29
|
- mail@0xReki.de
|
@@ -24,13 +38,14 @@ files:
|
|
24
38
|
- README.md
|
25
39
|
- jekyll-wns.gemspec
|
26
40
|
- js/youtube.js
|
27
|
-
- lib/.ruby-version
|
28
41
|
- lib/jekyll-wns.rb
|
29
42
|
- lib/jekyll-wns/assets/abbreviations.rb
|
30
43
|
- lib/jekyll-wns/assets/digest_filters.rb
|
31
|
-
- lib/jekyll-wns/assets/
|
44
|
+
- lib/jekyll-wns/assets/file_property_filters.rb
|
45
|
+
- lib/jekyll-wns/assets/label_unicode.rb
|
32
46
|
- lib/jekyll-wns/assets/quads.rb
|
33
47
|
- lib/jekyll-wns/assets/quads_filter.rb
|
48
|
+
- lib/jekyll-wns/assets/ruby_tag.rb
|
34
49
|
- lib/jekyll-wns/assets/scene_break_tag.rb
|
35
50
|
- lib/jekyll-wns/assets/youtube_tag.rb
|
36
51
|
- lib/jekyll-wns/register_filters.rb
|
data/lib/.ruby-version
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
3.0.1
|