Skip to content
Permalink
Browse files
Support blank lines in YAML/TOML metadata (part of issue #2801)
  • Loading branch information
ralsina committed Jun 6, 2017
1 parent 5b339f3 commit c638cee495674145c8cb9d8a84615c559742324e
Showing with 7 additions and 1 deletion.
  1. +1 −0 CHANGES.txt
  2. +6 −1 nikola/plugin_categories.py
@@ -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
@@ -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']

0 comments on commit c638cee

Please sign in to comment.