jekyll-slugify_underscore 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/Gemfile +2 -3
- data/README.md +1 -1
- data/jekyll-slugify_underscore.gemspec +2 -1
- data/lib/jekyll/slugify_underscore.rb +20 -11
- data/lib/jekyll/slugify_underscore/version.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c2660dad27664f67c9e1f2988e759b40449f015f
|
4
|
+
data.tar.gz: 9df6607c1986c162bd642c9be36f874446556e87
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f333c50e57942be0948a3b24f461bd5a6ab48e586d3990e8096b652ec633a5dd197535e16e04c969f903967ef622cc8f638af7b45da675e811f96103432a9857
|
7
|
+
data.tar.gz: 9abfcc7c8fa723185b6ffc446a53e2d925c46712aa4b0df6966c55da98ce329a36c281b68d91a0148a1204dbe412851c62c9484a56532a73941a6772c2d632eb
|
data/.gitignore
CHANGED
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -7,7 +7,7 @@ A plugin to make Jekyll slugify with underscores instead of hyphens.
|
|
7
7
|
|
8
8
|
## Installation
|
9
9
|
|
10
|
-
1. Add `gem 'jekyll-slugify_underscore'` to your site’s Gemfile and run bundle
|
10
|
+
1. Add `gem 'jekyll-slugify_underscore'` to your site’s Gemfile and run `bundle`
|
11
11
|
2. Add the following to your site’s `_config.yml`:
|
12
12
|
|
13
13
|
```yml
|
@@ -19,7 +19,8 @@ Gem::Specification.new do |spec|
|
|
19
19
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
20
20
|
spec.require_paths = ["lib"]
|
21
21
|
|
22
|
-
|
22
|
+
# spec.add_development_dependency "jekyll", [">= 3.0.2", "< 4.0"] # will be this
|
23
|
+
spec.add_development_dependency "jekyll", [">= 3.0.1", "< 4.0"] # temp fix
|
23
24
|
spec.add_development_dependency "rspec", "~> 3.0"
|
24
25
|
spec.add_development_dependency 'rake', '~> 0'
|
25
26
|
spec.add_development_dependency "bundler", "~> 1.6"
|
@@ -6,10 +6,12 @@ module Jekyll
|
|
6
6
|
#
|
7
7
|
# string - the filename or title to slugify
|
8
8
|
# mode - how string is slugified
|
9
|
+
# cased - whether to replace all uppercase letters with their
|
10
|
+
# lowercase counterparts
|
9
11
|
#
|
10
|
-
# When mode is "none", return the given string
|
12
|
+
# When mode is "none", return the given string.
|
11
13
|
#
|
12
|
-
# When mode is "raw", return the given string
|
14
|
+
# When mode is "raw", return the given string,
|
13
15
|
# with every sequence of spaces characters replaced with a hyphen.
|
14
16
|
#
|
15
17
|
# When mode is "default" or nil, non-alphabetic characters are
|
@@ -18,6 +20,9 @@ module Jekyll
|
|
18
20
|
# When mode is "pretty", some non-alphabetic characters (._~!$&'()+,;=@)
|
19
21
|
# are not replaced with hyphen.
|
20
22
|
#
|
23
|
+
# If cased is true, all uppercase letters in the result string are
|
24
|
+
# replaced with their lowercase counterparts.
|
25
|
+
#
|
21
26
|
# Examples:
|
22
27
|
# slugify("The _config.yml file")
|
23
28
|
# # => "the-config-yml-file"
|
@@ -25,12 +30,17 @@ module Jekyll
|
|
25
30
|
# slugify("The _config.yml file", "pretty")
|
26
31
|
# # => "the-_config.yml-file"
|
27
32
|
#
|
33
|
+
# slugify("The _config.yml file", "pretty", true)
|
34
|
+
# # => "The-_config.yml file"
|
35
|
+
#
|
28
36
|
# Returns the slugified string.
|
29
|
-
|
30
|
-
def slugify(string, mode=nil, delimiter="_")
|
37
|
+
def slugify(string, mode: nil, cased: false)
|
31
38
|
mode ||= 'default'
|
32
39
|
return nil if string.nil?
|
33
|
-
|
40
|
+
|
41
|
+
unless SLUGIFY_MODES.include?(mode)
|
42
|
+
return cased ? string : string.downcase
|
43
|
+
end
|
34
44
|
|
35
45
|
# Replace each character sequence with a hyphen
|
36
46
|
re = case mode
|
@@ -44,14 +54,13 @@ module Jekyll
|
|
44
54
|
SLUGIFY_PRETTY_REGEXP
|
45
55
|
end
|
46
56
|
|
47
|
-
string.
|
57
|
+
slug = string.
|
48
58
|
# Strip according to the mode
|
49
|
-
gsub(re,
|
59
|
+
gsub(re, '_').
|
50
60
|
# Remove leading/trailing hyphen
|
51
|
-
gsub(
|
52
|
-
# Downcase
|
53
|
-
downcase
|
54
|
-
end
|
61
|
+
gsub(/^\_|\_$/i, '')
|
55
62
|
|
63
|
+
cased ? slug : slug.downcase
|
64
|
+
end
|
56
65
|
end
|
57
66
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jekyll-slugify_underscore
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Paul Robert Lloyd
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-11-
|
11
|
+
date: 2015-11-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: jekyll
|
@@ -16,7 +16,7 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: 3.0.1
|
20
20
|
- - "<"
|
21
21
|
- !ruby/object:Gem::Version
|
22
22
|
version: '4.0'
|
@@ -26,7 +26,7 @@ dependencies:
|
|
26
26
|
requirements:
|
27
27
|
- - ">="
|
28
28
|
- !ruby/object:Gem::Version
|
29
|
-
version:
|
29
|
+
version: 3.0.1
|
30
30
|
- - "<"
|
31
31
|
- !ruby/object:Gem::Version
|
32
32
|
version: '4.0'
|