diff options
-rw-r--r-- | fountain/parse.go | 27 | ||||
-rw-r--r-- | pdf/create.go | 2 | ||||
-rw-r--r-- | rules/rules.go | 9 |
3 files changed, 22 insertions, 16 deletions
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}) } diff --git a/pdf/create.go b/pdf/create.go index 4cf17f9..05cc871 100644 --- a/pdf/create.go +++ b/pdf/create.go @@ -40,7 +40,7 @@ func (t Tree) Render() { func line(pdf *gofpdf.Fpdf, format rules.Format, text string) { pdf.SetFont(format.Font, format.Style, format.Size) pdf.SetX(format.Left) - pdf.MultiCell(format.Width, 0.19, tr(text), "", "aligned", false) + pdf.MultiCell(format.Width, 0.19, tr(text), "", format.Align, false) } func Create(file string, format rules.Set, contents lex.Screenplay) { diff --git a/rules/rules.go b/rules/rules.go index 45e5b56..c71df9d 100644 --- a/rules/rules.go +++ b/rules/rules.go @@ -7,6 +7,7 @@ type Format struct{ Style string Size float64 Hide bool + Align string } type Set map[string]Format @@ -23,6 +24,9 @@ func (s Set) Get(action string) (f Format) { if f.Size == 0 { f.Size = 12 } + if f.Align == "" { + f.Align = "L" + } return f } @@ -65,8 +69,9 @@ var Default = Set{ Width: 6, }, "title": { - Left: 3.6, - Width: 4, + Left: 1.5, + Width: 6, + Align: "C", }, "meta": { Left: 1.5, |