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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d0351f261c69b6656bf1d298ce16dfb717d5c52986a5cf56ca7855346fb72dca
4
- data.tar.gz: fb3675d3b79af34e0c5468e0713d42e673016fa6d6a143b4bbd41421222fdc54
3
+ metadata.gz: 310b65aa25c9965524dcd5fd5e4f1b744fbf6d7640403ffa0c2ca257dae4c246
4
+ data.tar.gz: ac7e510fd0c70e90df4fe5e51961ee4e691c787c5de5451cd40c38b56eed8c06
5
5
  SHA512:
6
- metadata.gz: a836a9f9c7aa948d35ad2028488de9ab0cdc87b54b7d577891db98eadd85d01cbd7d54aa53f910d7c3a8c508de11085e08303f7f3d287c831b03f8e4dcd9d85b
7
- data.tar.gz: 6e7f9eb5905b628a8686ecce3b6667f0ecddf3fca96b67c9dd4b6400088556d40659c872c2796927d6e12374e32560413c2886b28b2ca68de4ebdba382d6b049
6
+ metadata.gz: b84558f5db3a205b2fb788040ba239ff6ec6247c3a200c0e023e7e792f9782bd9eb482fd604e8de90a31859b9e73d2abbfe8be05200bda21cf05297b9dcead3b
7
+ data.tar.gz: 9d35693e10e8ce1667a2fb971dd7f832f8522988c044d5a33980233b3fc334b9fade0e29966dc7d6926d49b6ba3070838a383804c24a77029121ad459131f5e3
@@ -2,7 +2,7 @@ name: Ruby Gem
2
2
 
3
3
  on:
4
4
  push:
5
- tags: "*"
5
+ tags: "v*"
6
6
 
7
7
  jobs:
8
8
  build:
data/Gemfile CHANGED
@@ -1,3 +1,5 @@
1
1
  source "https://rubygems.org"
2
2
 
3
3
  gemspec
4
+
5
+ gem "ruby-mp3info", "~> 0.8.10"
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. Add `gem "jekyll-wns", git: "https://github.com/0xReki/jekyll-wns.git, branch: "main"` to your site's Gemfile and run `bundle`
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
- gems:
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,&nbsp;e.&#8239;\g.,&nbsp;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 = "3.3.1"
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/file_properties_filter'
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
- MAIN_EXPRESSION = /([a-zA-Z])\.([a-zA-Z])\.(,|) /
4
- MAIN_REPLACEMENT = "\\1.&#8239;\\2.\\3&nbsp;"
5
- CLEANUP_EXPRESSION = /, ([a-zA-Z]\.&)/
6
- CLEANUP_REPLACEMENT = ",&nbsp;\\1"
3
+ INNER_DOTS_EXPRESSION = /([a-zA-Z]\.)([a-zA-Z]\.)([a-zA-Z]\.|)([a-zA-Z]\.|)([a-zA-Z]\.|)(,|) /
4
+ INNER_DOTS_REPLACEMENT = "\\1&#8239;\\2&#8239;\\3&#8239;\\4&#8239;\\5&#8239;\\6&nbsp;"
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&nbsp;"
8
+
9
+ PREFIX_EXPRESSION = /, ([a-zA-Z]\.&)/
10
+ PREFIX_REPLACEMENT = ",&nbsp;\\1"
11
+
12
+ COLLAPSE_SPACES_EXPRESSION = /(&#8239;)*(&nbsp;|,)/
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::MAIN_EXPRESSION, Abbreviations::MAIN_REPLACEMENT)
16
- doc.content = doc.content.gsub(Abbreviations::CLEANUP_EXPRESSION, Abbreviations::CLEANUP_REPLACEMENT)
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
@@ -16,7 +16,9 @@ module WNS
16
16
  end
17
17
 
18
18
  def self.insert_quads_into_document!(doc)
19
- doc.content = insert_quads doc.content
19
+ if Quads::enabled?(doc)
20
+ doc.content = insert_quads doc.content
21
+ end
20
22
  end
21
23
  end
22
24
  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">β€ŽβšŽβ€βšβ€ŽβšŽβšβ€ŽβšŽβšβ€ŽβšŽβšβ€ŽβšŽβšβ€ŽβšŽβšβ€ŽβšŽβšβ€ŽβšŽβšβ€ŽβšŽβšβ€ŽβšŽβšβ€ŽβšŽ</p>'
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,3 +1,3 @@
1
1
  Liquid::Template.register_filter(WNS::QuadsFilter)
2
2
  Liquid::Template.register_filter(WNS::DigestFilters)
3
- Liquid::Template.register_filter(WNS::FilePropertiesFilter)
3
+ Liquid::Template.register_filter(WNS::FilePropertyFilters)
@@ -1,14 +1,23 @@
1
- Jekyll::Hooks.register :documents, :pre_render do |document|
2
- WNS::Abbreviations::replace_abbreviations! document
3
- WNS::Quads::insert_quads_into_document! document
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, :pre_render do |document|
7
- WNS::Abbreviations::replace_abbreviations! document
8
- WNS::Quads::insert_quads_into_document! document
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
@@ -1,2 +1,3 @@
1
1
  Liquid::Template.register_tag('scene_break', WNS::SceneBreakTag)
2
2
  Liquid::Template.register_tag('youtube', WNS::YoutubeTag)
3
+ Liquid::Template.register_tag('ruby', WNS::RubyTag)
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: 3.3.1
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-11 00:00:00.000000000 Z
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/file_properties_filter.rb
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
@@ -1,7 +0,0 @@
1
- module WNS
2
- module FilePropertiesFilter
3
- def file_size(path)
4
- File.size path
5
- end
6
- end
7
- end