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)

This comment has been minimized.

@felixfontein

felixfontein Jun 6, 2017
Contributor

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

This comment has been minimized.

@felixfontein

felixfontein Jun 6, 2017
Contributor

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 ---.

This comment has been minimized.

@ralsina

ralsina Jun 6, 2017
Author Member

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

Copy link
Contributor

@felixfontein felixfontein left a comment

LGTM

@ralsina ralsina merged commit de9e213 into master Jun 6, 2017
3 of 5 checks passed
3 of 5 checks passed
continuous-integration/travis-ci/pr The Travis CI build is in progress
Details
continuous-integration/travis-ci/push The Travis CI build is in progress
Details
codacy/pr Good work! A positive pull request.
Details
continuous-integration/appveyor/branch AppVeyor build succeeded
Details
continuous-integration/appveyor/pr AppVeyor build succeeded
Details
@ralsina ralsina deleted the empty-lines-in-metadata branch Jun 6, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

2 participants