Preserve category case in importer

Adds a `preserve_case` parameter to the `slugify()` function and uses it
to preserve capital letters in category names when using the Pelican
importer.
This commit is contained in:
Justin Mayer 2020-04-15 20:42:21 +02:00
commit 8ba00dd9f1
4 changed files with 16 additions and 7 deletions

View file

@ -634,7 +634,8 @@ def get_out_filename(output_path, filename, ext, kind,
typename = ''
kind = 'article'
if dircat and (len(categories) > 0):
catname = slugify(categories[0], regex_subs=slug_subs)
catname = slugify(
categories[0], regex_subs=slug_subs, preserve_case=True)
else:
catname = ''
out_filename = os.path.join(output_path, typename,
@ -643,7 +644,8 @@ def get_out_filename(output_path, filename, ext, kind,
os.makedirs(os.path.join(output_path, typename, catname))
# option to put files in directories with categories names
elif dircat and (len(categories) > 0):
catname = slugify(categories[0], regex_subs=slug_subs)
catname = slugify(
categories[0], regex_subs=slug_subs, preserve_case=True)
out_filename = os.path.join(output_path, catname, filename + ext)
if not os.path.isdir(os.path.join(output_path, catname)):
os.mkdir(os.path.join(output_path, catname))