Skip to content

Commit

Permalink
Support blank lines in YAML/TOML metadata (part of issue #2801)
Browse files Browse the repository at this point in the history
  • Loading branch information
Roberto Alsina committed Jun 6, 2017
1 parent 5b339f3 commit c638cee
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGES.txt
Expand Up @@ -11,6 +11,7 @@ Features
Bugfixes
--------

* Support empty lines in YAML/TOML metadata (Part of issue #2801)
* Tests run on macOS.

New in v7.8.7
Expand Down
7 changes: 6 additions & 1 deletion nikola/plugin_categories.py
Expand Up @@ -338,7 +338,12 @@ def split_metadata(self, data):
This splits in the first empty line that is NOT at the beginning
of the document.
"""
split_result = re.split('(\n\n|\r\n\r\n)', data.lstrip(), maxsplit=1)
if data.startswith('---'): # YAML metadata
split_result = re.split('(---\n\n|----\r\n\r\n)', data.lstrip(), maxsplit=1)
elif data.startswith('+++'): # TOML metadata
split_result = re.split('(+++\n\n|+++\r\n\r\n)', data.lstrip(), maxsplit=1)
else:
split_result = re.split('(\n\n|\r\n\r\n)', data.lstrip(), maxsplit=1)
if len(split_result) == 1:
return '', split_result[0]
# ['metadata', '\n\n', 'post content']
Expand Down

0 comments on commit c638cee

Please sign in to comment.