Ignore empty lines at the start of workout file

This commit is contained in:
Rene Saarsoo 2020-09-21 16:42:46 +03:00
parent d2d998b160
commit 184666c6f7
2 changed files with 6 additions and 2 deletions

View File

@ -24,7 +24,8 @@ describe("Parser", () => {
it("parses workout header with all fields", () => { it("parses workout header with all fields", () => {
expect( expect(
parse(`Name: My Workout parse(`
Name: My Workout
Author: John Doe Author: John Doe
Description: Description:
It's a great workout. It's a great workout.

View File

@ -21,7 +21,10 @@ const parseHeader = (tokens: Token[]): [Header, Token[]] => {
while (tokens[0]) { while (tokens[0]) {
const token = tokens[0]; const token = tokens[0];
if (token.type === "label" && token.value === "Name") { if (token.type === "text" && token.value === "") {
// Ignore empty lines before header
tokens.shift();
} else if (token.type === "label" && token.value === "Name") {
tokens.shift(); tokens.shift();
const [name, rest] = extractText(tokens); const [name, rest] = extractText(tokens);
header.name = name; header.name = name;