From 3b4f9775c15cf7c101c1759ee4e4f0fa0f5117dc Mon Sep 17 00:00:00 2001 From: Joop Kiefte Date: Mon, 31 Dec 2018 22:55:30 +0100 Subject: Add center alignment for title and refactor fountain parsing. --- fountain/parse.go | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) (limited to 'fountain') diff --git a/fountain/parse.go b/fountain/parse.go index ba3a3e8..a3e1747 100644 --- a/fountain/parse.go +++ b/fountain/parse.go @@ -24,20 +24,21 @@ func Parse(file io.Reader) (out lex.Screenplay) { } if row == "" { action = "empty" - } else { - if i > 0 { - switch out[i-1].Type { - case "allcaps": - out[i-1].Type = "speaker" - if row[0] == '(' && row[len(row)-1] == ')' { - action = "paren" - } else { - action = "dialog" - } - case "paren", "dialog": - action = "dialog" - } + continue + } + if i <= 0 { + continue + } + switch out[i-1].Type { + case "allcaps": + out[i-1].Type = "speaker" + if row[0] == '(' && row[len(row)-1] == ')' { + action = "paren" + } else { + action = "dialog" } + case "paren", "dialog": + action = "dialog" } out = append(out, lex.Line{action, row}) } -- cgit v1.2.3-70-g09d2