Skip to content

Commit

Permalink
Issue #23: ignore blank lines with only whitespace
Browse files Browse the repository at this point in the history
This patch changes the parser so that it will ignore blank lines
which contain only whitespace.

Fixes #23
  • Loading branch information
magiconair committed Oct 31, 2017
1 parent 8d7837e commit 476d56d
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 1 addition & 2 deletions lex.go
Original file line number Diff line number Diff line change
Expand Up @@ -196,9 +196,8 @@ func lexBeforeKey(l *lexer) stateFn {
return lexComment

case isWhitespace(r):
l.acceptRun(whitespace)
l.ignore()
return lexKey
return lexBeforeKey

default:
l.backup()
Expand Down
2 changes: 2 additions & 0 deletions properties_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ var complexTests = [][]string{
{"\nkey=value\n", "key", "value"},
{"\rkey=value\r", "key", "value"},
{"\r\nkey=value\r\n", "key", "value"},
{"\nkey=value\n \nkey2=value2", "key", "value", "key2", "value2"},
{"\nkey=value\n\t\nkey2=value2", "key", "value", "key2", "value2"},

// escaped chars in key
{"k\\ ey = value", "k ey", "value"},
Expand Down

0 comments on commit 476d56d

Please sign in to comment.