Merge pull request #3047 from karouf/slugify-non-latin

This commit is contained in:
Parker Moore 2014-12-29 00:31:34 -05:00
commit 612eb737a5
2 changed files with 6 additions and 1 deletions

View File

@ -113,7 +113,7 @@ module Jekyll
unless string.nil? unless string.nil?
string \ string \
# Replace each non-alphanumeric character sequence with a hyphen # Replace each non-alphanumeric character sequence with a hyphen
.gsub(/[^a-z0-9]+/i, '-') \ .gsub(/[^[:alnum:]]+/i, '-') \
# Remove leading/trailing hyphen # Remove leading/trailing hyphen
.gsub(/^\-|\-$/i, '') \ .gsub(/^\-|\-$/i, '') \
# Downcase it # Downcase it

View File

@ -120,6 +120,7 @@ class TestUtils < Test::Unit::TestCase
should "drop trailing punctuation" do should "drop trailing punctuation" do
assert_equal "so-what-is-jekyll-exactly", Utils.slugify("So what is Jekyll, exactly?") assert_equal "so-what-is-jekyll-exactly", Utils.slugify("So what is Jekyll, exactly?")
assert_equal "كيف-حالك", Utils.slugify("كيف حالك؟")
end end
should "ignore hyphens" do should "ignore hyphens" do
@ -134,6 +135,10 @@ class TestUtils < Test::Unit::TestCase
assert_equal "customizing-git-git-hooks", Utils.slugify("Customizing Git - Git Hooks") assert_equal "customizing-git-git-hooks", Utils.slugify("Customizing Git - Git Hooks")
end end
should "replace punctuation in any scripts by hyphens" do
assert_equal "5時-6時-三-一四", Utils.slugify("5時〜6時 三・一四")
end
should "not modify the original string" do should "not modify the original string" do
title = "Quick-start guide" title = "Quick-start guide"
Utils.slugify(title) Utils.slugify(title)