Skip to content

Commit

Permalink
Gofmt and improving front page support
Browse files Browse the repository at this point in the history
  • Loading branch information
LaPingvino committed Jan 12, 2019
1 parent 99ebe57 commit a6318ee
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 34 deletions.
41 changes: 20 additions & 21 deletions fountain/parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,46 +142,45 @@ func Parse(file io.Reader) (out lex.Screenplay) {
dialog = true
}

checkfuncs := []func(string) (bool, string, string){
CheckScene, // should actually check for empty lines, but doing that creates more problems than it solves
CheckCrow,
CheckEqual,
CheckSection,
CheckForce,
}
for _, checkfunc := range checkfuncs {
check, element, contents := checkfunc(row)
if check {
action = element
row = contents
if action == "speaker" {
dialog = true
}
break
checkfuncs := []func(string) (bool, string, string){
CheckScene, // should actually check for empty lines, but doing that creates more problems than it solves
CheckCrow,
CheckEqual,
CheckSection,
CheckForce,
}
for _, checkfunc := range checkfuncs {
check, element, contents := checkfunc(row)
if check {
action = element
row = contents
if action == "speaker" {
dialog = true
}
break
}
}

if titlepage {
if titletag == "" {
out = append(out, lex.Line{Type: "titlepage"})
}
split := strings.SplitN(row, ":", 2)
if len(split) == 2 {
action = strings.ToLower(split[0])
switch action {
action = split[0]
switch strings.ToLower(action) {
case "title", "credit", "author", "authors":
action = "title"
titletag = "title"
default:
if titletag == "title" {
out = append(out, lex.Line{Type: "metasection"})
}
action = "meta"
titletag = action
}
row = strings.TrimSpace(split[1])
if row == "" {
continue
}
titletag = action
} else {
action = titletag
row = strings.TrimSpace(row)
Expand Down
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Lexington is a command line tool to convert between several formats used for screenwriting.
// When you write a screenplay in Fountain, you can use this tool to convert it into other formats.
// The tool uses an internal format called lex which can be used to tweak the output.
// Run the compiled tool with --help to get information about usage.
// Run the compiled tool with --help to get information about usage.
package main

import (
Expand Down
11 changes: 9 additions & 2 deletions pdf/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,23 +16,30 @@ type Tree struct {
}

func (t Tree) pr(a string, text string) {
line(t.PDF, t.Rules.Get(a), text)
line(t.PDF, t.Rules.Get(a), t.Rules.Get(a).Prefix+text+t.Rules.Get(a).Postfix)
}

func (t Tree) Render() {
var block string
for _, row := range t.F {
switch row.Type {
case "newpage":
block = ""
t.PDF.AddPage()
continue
case "titlepage":
block = "title"
t.PDF.SetY(4)
case "metasection":
block = "meta"
t.PDF.SetY(-2)
}
if t.Rules.Get(row.Type).Hide {
if t.Rules.Get(row.Type).Hide && block == "" {
continue
}
if block != "" {
row.Type = block
}
t.pr(row.Type, row.Contents)
}
}
Expand Down
22 changes: 12 additions & 10 deletions rules/rules.go
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
package rules

type Format struct {
Width float64
Left float64
Font string
Style string
Size float64
Hide bool
Align string
Width float64
Left float64
Font string
Style string
Size float64
Hide bool
Align string
Prefix string
Postfix string
}

type Set map[string]Format
Expand Down Expand Up @@ -79,14 +81,14 @@ var Default = Set{
Width: 6,
},
"center": {
Left: 1.5,
Left: 1.5,
Width: 6,
Align: "C",
},
"lyrics": {
Left: 2,
Left: 2,
Width: 5,
Style: "i",
Font: "Helvetica",
Font: "Helvetica",
},
}

0 comments on commit a6318ee

Please sign in to comment.