Browse code

Improved support for non Latin characters in category names. Fixes #128

Chun-wei Kuo authored on 05/09/2011 at 10:07:40
Showing 1 changed files
... ...
@@ -1,3 +1,5 @@
1
+# encoding: utf-8
2
+#
1 3
 # Jekyll category page generator.
2 4
 # http://recursive-design.com/projects/jekyll-plugins/
3 5
 #
... ...
@@ -16,7 +18,6 @@
16 16
 # - category_dir:          The subfolder to build category pages in (default is 'categories').
17 17
 # - category_title_prefix: The string used before the category name in the page title (default is
18 18
 #                          'Category: ').
19
-require "unicode_utils"
20 19
 
21 20
 module Jekyll
22 21
 
... ...
@@ -69,7 +70,7 @@ module Jekyll
69 69
       if self.layouts.key? 'category_index'
70 70
         dir = self.config['category_dir'] || 'categories'
71 71
         self.categories.keys.each do |category|
72
-          self.write_category_index(File.join(dir, UnicodeUtils.nfkd(category).gsub(/[^\x00-\x7F]/, '').gsub(/_|\W/, '-').gsub(/-{2,}/, '-').to_s), category)
72
+          self.write_category_index(File.join(dir, category.gsub(/_|\P{Word}/, '-').gsub(/-{2,}/, '-')), category)
73 73
         end
74 74
 
75 75
       # Throw an exception if the layout couldn't be found.
... ...
@@ -106,7 +107,7 @@ module Jekyll
106 106
     def category_links(categories)
107 107
       dir = @context.registers[:site].config['category_dir']
108 108
       categories = categories.sort!.map do |item|
109
-        "<a class='category' href='/#{dir}/#{UnicodeUtils.nfkd(item).gsub(/[^\x00-\x7F]/, '').gsub(/_|\W/, '-').gsub(/-{2,}/, '-').to_s}/'>#{item}</a>"
109
+        "<a class='category' href='/#{dir}/#{item.gsub(/_|\P{Word}/, '-').gsub(/-{2,}/, '-')}/'>#{item}</a>"
110 110
       end
111 111
 
112 112
       case categories.length