Skip to content

Commit

Permalink
FIX: Detect a line containing only whitespace as a valid break betwee…
Browse files Browse the repository at this point in the history
…n metadata and the source.

Fixes #22
  • Loading branch information
jasedit committed Sep 25, 2016
1 parent f0031aa commit 39f0f79
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/transclude.c
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,20 @@ char * source_without_metadata(char * source, unsigned long extensions ) {
/* If we have metadata, then return just the body */
/* TODO: This could miss YAML Metadata that does not contain
blank line afterwards */
result = strstr(source, "\n\n");

char *result = strstr(result, "\n");
while (result != NULL) {
if (*result == '\n') {
break;
} else if (isspace(*result)) {
++result;
} else {
result = strstr(result, "\n");
}
}

if (result != NULL)
return result + 2;
return result;
}

/* No metadata, so return original pointer */
Expand Down

0 comments on commit 39f0f79

Please sign in to comment.