Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Improved category slug collision test.
Fixed error message for unknown escape sequences.
  • Loading branch information
felixfontein committed May 12, 2015
1 parent 18296cf commit 374fd3c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion nikola/nikola.py
Expand Up @@ -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
Expand Down
6 changes: 5 additions & 1 deletion nikola/plugins/task/tags.py
Expand Up @@ -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())
Expand Down

0 comments on commit 374fd3c

Please sign in to comment.