Switch slugify regex to support more Unicode character groups (#8167)
Merge pull request 8167
This commit is contained in:
parent
11dd893416
commit
f8286b62a2
|
@ -13,8 +13,8 @@ module Jekyll
|
||||||
# Constants for use in #slugify
|
# Constants for use in #slugify
|
||||||
SLUGIFY_MODES = %w(raw default pretty ascii latin).freeze
|
SLUGIFY_MODES = %w(raw default pretty ascii latin).freeze
|
||||||
SLUGIFY_RAW_REGEXP = Regexp.new('\\s+').freeze
|
SLUGIFY_RAW_REGEXP = Regexp.new('\\s+').freeze
|
||||||
SLUGIFY_DEFAULT_REGEXP = Regexp.new("[^[:alnum:]]+").freeze
|
SLUGIFY_DEFAULT_REGEXP = Regexp.new("[^\\p{M}\\p{L}\\p{Nd}]+").freeze
|
||||||
SLUGIFY_PRETTY_REGEXP = Regexp.new("[^[:alnum:]._~!$&'()+,;=@]+").freeze
|
SLUGIFY_PRETTY_REGEXP = Regexp.new("[^\\p{M}\\p{L}\\p{Nd}._~!$&'()+,;=@]+").freeze
|
||||||
SLUGIFY_ASCII_REGEXP = Regexp.new("[^[A-Za-z0-9]]+").freeze
|
SLUGIFY_ASCII_REGEXP = Regexp.new("[^[A-Za-z0-9]]+").freeze
|
||||||
|
|
||||||
# Takes a slug and turns it into a simple title.
|
# Takes a slug and turns it into a simple title.
|
||||||
|
|
|
@ -176,6 +176,11 @@ class TestUtils < JekyllUnitTest
|
||||||
assert_equal "5時-6時-三-一四", Utils.slugify("5時〜6時 三・一四")
|
assert_equal "5時-6時-三-一四", Utils.slugify("5時〜6時 三・一四")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
should "not replace Unicode 'Mark', 'Letter', or 'Number: Decimal Digit' category characters" do
|
||||||
|
assert_equal "மல்லிப்பூ-வகைகள்", Utils.slugify("மல்லிப்பூ வகைகள்")
|
||||||
|
assert_equal "மல்லிப்பூ-வகைகள்", Utils.slugify("மல்லிப்பூ வகைகள்", :mode => "pretty")
|
||||||
|
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)
|
||||||
|
|
Loading…
Reference in New Issue