Skip to content
Permalink
Browse files

Improved category slug collision test.

Fixed error message for unknown escape sequences.
  • Loading branch information
felixfontein committed May 12, 2015
1 parent 18296cf commit 374fd3c0670dbc7f8b74a2f091a534d1aec2f609
Showing with 6 additions and 2 deletions.
  1. +1 −1 nikola/nikola.py
  2. +5 −1 nikola/plugins/task/tags.py
@@ -1377,7 +1377,7 @@ def parse_category_name(self, category_name):
sys.exit(1)
esc_ch = category_name[next_backslash + 1]
if esc_ch not in {'/', '\\'}:
utils.LOGGER.error("Unknown escape sequence '\\{0}' in '{1}' at last position!".format(esc_ch, category_name))
utils.LOGGER.error("Unknown escape sequence '\\{0}' in '{1}'!".format(esc_ch, category_name))
sys.exit(1)
current += category_name[index:next_backslash] + esc_ch
index = next_backslash + 2
@@ -107,12 +107,16 @@ def gen_tasks(self):
categories = {}
for category in self.site.posts_per_category.keys():
slug = tuple(self.slugify_category_name(category))
for part in slug:
if len(part) == 0:
utils.LOGGER.error("Category '{0}' yields invalid slug '{1}'!".format(category, '/'.join(slug)))
sys.exit(1)
if slug in categories:
other_category = categories[slug]
utils.LOGGER.error('You have categories that are too similar: {0} and {1}'.format(category, other_category))
utils.LOGGER.error('Category {0} is used in: {1}'.format(category, ', '.join([p.source_path for p in self.posts_per_category[category]])))
utils.LOGGER.error('Category {0} is used in: {1}'.format(other_category, ', '.join([p.source_path for p in self.posts_per_category[other_category]])))
pass
sys.exit(1)
categories[slug] = category

tag_list = list(self.site.posts_per_tag.items())

0 comments on commit 374fd3c

Please sign in to comment.
You can’t perform that action at this time.