Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support blank lines in YAML/TOML metadata (part of issue #2801) #2827

Merged
merged 2 commits into from Jun 6, 2017

Conversation

ralsina
Copy link
Member

@ralsina ralsina commented Jun 6, 2017

Split on the right markers for YAML/TOML metadata.

@@ -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)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You have four dashes before the Windows newlines. I guess that's one too many.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also: isn't it better to split along \n\n---\n\n (for Unix-style newlines) instead of ---\n\n? Otherwise, a line ending with --- will also suffice for a split (which is probably not what you want), as opposed to a line containing only ---.

Copy link
Member Author

@ralsina ralsina Jun 6, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good points. I think you mean "\n---\n\n" but yes :-)

Copy link
Contributor

@felixfontein felixfontein left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@ralsina ralsina merged commit de9e213 into master Jun 6, 2017
@ralsina ralsina deleted the empty-lines-in-metadata branch June 6, 2017 20:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants