Skip to content

Commit

Permalink
Stop using reserved name.
Browse files Browse the repository at this point in the history
  • Loading branch information
felixfontein committed Jul 1, 2017
1 parent dff2d7c commit 6ef898e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
6 changes: 3 additions & 3 deletions nikola/post.py
Expand Up @@ -990,11 +990,11 @@ def get_metadata_from_file(source_path, config=None, lang=None):

def _get_metadata_from_file(file_lines, config=None):
"""Extract metadata from a post's source file."""
meta, type = utils.extract_metadata(file_lines)
if type == 'yaml':
meta, metadata_type = utils.extract_metadata(file_lines)
if metadata_type == 'yaml':
# Map metadata from other platforms to names Nikola expects (Issue #2817)
map_metadata(meta, 'yaml', config)
if type == 'toml':
if metadata_type == 'toml':
# Map metadata from other platforms to names Nikola expects (Issue #2817)
map_metadata(meta, 'toml', config)
return meta
Expand Down
20 changes: 10 additions & 10 deletions nikola/utils.py
Expand Up @@ -2053,10 +2053,10 @@ def re_meta(line, match=None):
def extract_metadata(file_lines):
"""Extract metadata from the lines of a file.
Returns a pair ``(meta, type)``, where ``meta`` is the
metadata dictionary and ``type`` the metadata format.
Returns a pair ``(meta, metadata_type)``, where ``meta`` is the
metadata dictionary and ``metadata_type`` the metadata format.
Valid values for ``type`` are:
Valid values for ``metadata_type`` are:
* ``'none'``: no metadata was found (file was empty)
* ``'yaml'``: metadata in YAML format
* ``'toml'``: metadata in TOML format
Expand Down Expand Up @@ -2112,11 +2112,11 @@ def split_metadata(data):
This splits in the first empty line that is NOT at the beginning
of the document, or after YAML/TOML metadata without an empty line.
Returns a tuple ``(meta, content, type)`` where ``meta`` and
``content`` are parts of ``data``, and ``type`` is the metadata
Returns a tuple ``(meta, content, metadata_type)`` where ``meta`` and
``content`` are parts of ``data``, and ``metadata_type`` is the metadata
format.
Valid values for ``type`` are:
Valid values for ``metadata_type`` are:
* ``'none'``: no metadata was found (file was empty)
* ``'yaml'``: metadata in YAML format
* ``'toml'``: metadata in TOML format
Expand All @@ -2125,14 +2125,14 @@ def split_metadata(data):
"""
if data.startswith('---'): # YAML metadata
split_result = re.split('(\n---\n|\r\n---\r\n)', data.lstrip(), maxsplit=1)
type = 'yaml'
metadata_type = 'yaml'
elif data.startswith('+++'): # TOML metadata
split_result = re.split('(\n\\+\\+\\+\n|\r\n\\+\\+\\+\r\n)', data.lstrip(), maxsplit=1)
type = 'toml'
metadata_type = 'toml'
else:
split_result = re.split('(\n\n|\r\n\r\n)', data.lstrip(), maxsplit=1)
type = 'nikola'
metadata_type = 'nikola'
if len(split_result) == 1:
return '', split_result[0], 'none'
# ['metadata', '\n\n', 'post content']
return split_result[0], split_result[-1], type
return split_result[0], split_result[-1], metadata_type

0 comments on commit 6ef898e

Please sign in to comment.