Browse code

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

Brandon Mathis authored on 03/09/2011 at 13:15:01
Showing 1 changed files
... ...
@@ -68,7 +68,7 @@ module Jekyll
68 68
       if self.layouts.key? 'category_index'
69 69
         dir = self.config['category_dir'] || 'categories'
70 70
         self.categories.keys.each do |category|
71
-          self.write_category_index(File.join(dir, category.gsub(/_|\W/, '-')), category)
71
+          self.write_category_index(File.join(dir, category.gsub(/[_\P{word}]/, '-').gsub(/-{2,}/, '-')), category)
72 72
         end
73 73
 
74 74
       # Throw an exception if the layout couldn't be found.
... ...
@@ -105,7 +105,7 @@ module Jekyll
105 105
     def category_links(categories)
106 106
       dir = @context.registers[:site].config['category_dir']
107 107
       categories = categories.sort!.map do |item|
108
-        "<a class='category' href='/#{dir}/#{item.gsub(/_|\W/, '-')}/'>#{item}</a>"
108
+        "<a class='category' href='/#{dir}/#{item.gsub(/[_\P{word}]/, '-').gsub(/-{2,}/, '-')}/'>#{item}</a>"
109 109
       end
110 110
 
111 111
       case categories.length