Skip to content

Commit

Permalink
공백줄로 시작하면 무시
Browse files Browse the repository at this point in the history
  • Loading branch information
if1live committed Mar 10, 2018
1 parent f45b5f8 commit 758bd00
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
1 change: 1 addition & 0 deletions .env.sample
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export GOPATH=$(dirname $(dirname $(pwd)))
15 changes: 13 additions & 2 deletions article.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,15 @@ func NewArticle(text string, mode string) *Article {
// ---
// content

if lines[0] != "---" {
firstLine := 0
for i, line := range lines {
if len(strings.Trim(line, " ")) > 0 {
firstLine = i
break
}
}

if lines[firstLine] != "---" {
// no metadata
return &Article{
MetadataText: "",
Expand All @@ -57,7 +65,10 @@ func NewArticle(text string, mode string) *Article {
}

state := LineParseStateInit
for _, line := range lines {
for i, line := range lines {
if i < firstLine {
continue
}
switch state {
case LineParseStateInit:
if strings.Trim(line, " ") == "---" {
Expand Down
1 change: 1 addition & 0 deletions article_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ func TestNewArticle(t *testing.T) {
// metadata
{
strings.Join([]string{
"",
"---",
"title: hello",
"---",
Expand Down

0 comments on commit 758bd00

Please sign in to comment.