Skip to content

Commit

Permalink
Fix compatibility with .meta files
Browse files Browse the repository at this point in the history
Signed-off-by: Chris Warrick <kwpolska@gmail.com>
  • Loading branch information
Kwpolska committed Jul 3, 2017
1 parent f7679bc commit 4a21369
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
2 changes: 1 addition & 1 deletion nikola/plugin_categories.py
Expand Up @@ -404,7 +404,7 @@ def _split_metadata_from_text(self, source_text: str) -> (str, str):
else:
split_result = self.split_metadata_re.split(source_text.lstrip(), maxsplit=1)
if len(split_result) == 1:
return '', split_result[0]
return split_result[0], split_result[0]
else:
# Necessary?
return split_result[0], split_result[-1]
Expand Down
6 changes: 2 additions & 4 deletions nikola/post.py
Expand Up @@ -972,7 +972,6 @@ def get_metadata_from_file(source_path, post, config, lang, metadata_extractors_

if found_in_priority:
break

return meta, used_extractors
except (UnicodeDecodeError, UnicodeEncodeError):
msg = 'Error reading {0}: Nikola only supports UTF-8 files'.format(source_path)
Expand All @@ -990,13 +989,12 @@ def get_metadata_from_meta_file(path, post, config, lang, metadata_extractors_by
elif lang:
meta_path += '.' + lang
if os.path.isfile(meta_path):
return get_metadata_from_file(path, post, config, lang, metadata_extractors_by)[0]

return get_metadata_from_file(meta_path, post, config, lang, metadata_extractors_by)[0]
elif lang:
# Metadata file doesn't exist, but not default language,
# So, if default language metadata exists, return that.
# This makes the 2-file format detection more reliable (Issue #525)
return get_metadata_from_meta_file(path, post, config, None, metadata_extractors_by)[0]
return get_metadata_from_meta_file(meta_path, post, config, None, metadata_extractors_by)[0]
else: # No 2-file metadata
return {}

Expand Down

0 comments on commit 4a21369

Please sign in to comment.