Fix markdown meta parsing#12817
Merged
Merged
Conversation
Signed-off-by: jolheiser <john.olheiser@gmail.com>
zeripath
reviewed
Sep 11, 2020
Signed-off-by: jolheiser <john.olheiser@gmail.com>
Signed-off-by: jolheiser <john.olheiser@gmail.com>
Codecov Report
@@ Coverage Diff @@
## master #12817 +/- ##
==========================================
+ Coverage 43.13% 43.16% +0.02%
==========================================
Files 654 654
Lines 72205 72205
==========================================
+ Hits 31146 31165 +19
+ Misses 36013 35990 -23
- Partials 5046 5050 +4
Continue to review full report at Codecov.
|
zeripath
reviewed
Sep 12, 2020
Signed-off-by: jolheiser <john.olheiser@gmail.com>
zeripath
approved these changes
Sep 12, 2020
lunny
reviewed
Sep 12, 2020
| var front, body []string | ||
| var seps int | ||
| lines := strings.Split(contents, "\n") | ||
| for idx, line := range lines { |
Member
There was a problem hiding this comment.
It's better to use Scanner.
scanner := bufio.NewScanner(strings.NewReader(contents))
var idx = 0
for scanner.Scan() {
line := scanner.Text()
...
idx++
}
Member
Author
There was a problem hiding this comment.
What's the advantage in this case?
We still need to scan the whole file so we can return body, and we've already checked file size prior to calling this func.
Member
There was a problem hiding this comment.
Less CPU and memory usage. But since it should be a small file, it's not necessary.
mrsdizzie
approved these changes
Sep 12, 2020
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #12815
This code should now exclude the separator lines themselves, so as long as there are two or more hyphens it will work as a separator and also YAML won't choke.
Included a minimal test case.