Skip to content

Commit

Permalink
Quick Save
Browse files Browse the repository at this point in the history
  • Loading branch information
rsdoiel committed Dec 23, 2017
1 parent 1327db7 commit 7148bc5
Show file tree
Hide file tree
Showing 8 changed files with 36 additions and 63 deletions.
24 changes: 19 additions & 5 deletions TODO.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,29 @@ <h2>Bugs</h2>
<h2>Next</h2>

<ul>
<li>write fountain2fdx</li>
<li>write fdx2fountain</li>
<li>[ ] fountain2fdx (Fountain to Final Draft XML)</li>
<li>[ ] fountain2osf (Fountain to Open Screenplay Format 2.x)</li>
<li>[ ] fdx2fountain (build on fdx2txt in <a href="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/rsdoiel/fdx">fdx</a>, handle TitlePage better)</li>
<li>[ ] fdx2osf (Final Draft XML to Open Screenplay Format 2.x XML)</li>
<li>[ ] osf2fdx (Open Screenplay Format 2.x XML to Final Draft XML)</li>
<li>[ ] osf2fountain (Open Screenplay Format 2.x XML to Fountain)</li>
</ul>

<h2>Someday, Maybe</h2>

<ul>
<li>write fdx2trelby</li>
<li>write trelby2fdx</li>
<li>write trelby2fountain</li>
<li>[ ] fdx2trelby</li>
<li>[ ] trelby2fdx</li>
<li>[ ] trelby2fountain</li>
<li>[ ] trelby2osf</li>
</ul>

<h2>Reference Links</h2>

<ul>
<li><a href="https://fountain.io">Fountain</a></li>
<li><a href="https://sourceforge.net/projects/openscrfmt/">Open Screenplay Format 2.0</a></li>
<li><a href="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/severdia/Open-Screenplay-Format">Open Screenplay Format 2.1</a></li>
</ul>

</section>
Expand All @@ -36,6 +49,7 @@ <h2>Someday, Maybe</h2>
<li><a href="license.html">LICENSE</a></li>
<li><a href="install.html">INSTALL</a></li>
<li><a href="docs/scripttool.html">Documentation</a></li>
<li><a href="TODO.html">TODO</a></li>
<li><a href="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/rsdoiel/scripttool">Github</a></li>
</ul>

Expand Down
1 change: 1 addition & 0 deletions docs/scripttool.html
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ <h2>EXAMPLES</h2>
<li><a href="../license.html">LICENSE</a></li>
<li><a href="../install.html">INSTALL</a></li>
<li><a href="scripttool.html">Documentation</a></li>
<li><a href="../TODO.html">TODO</a></li>
<li><a href="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/rsdoiel/scripttool">Github</a></li>
</ul>

Expand Down
1 change: 1 addition & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ <h2>Script Reports</h2>
<li><a href="license.html">LICENSE</a></li>
<li><a href="install.html">INSTALL</a></li>
<li><a href="docs/scripttool.html">Documentation</a></li>
<li><a href="TODO.html">TODO</a></li>
<li><a href="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/rsdoiel/scripttool">Github</a></li>
</ul>

Expand Down
1 change: 1 addition & 0 deletions install.html
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@ <h2>Compiling from source</h2>
<li><a href="license.html">LICENSE</a></li>
<li><a href="install.html">INSTALL</a></li>
<li><a href="docs/scripttool.html">Documentation</a></li>
<li><a href="TODO.html">TODO</a></li>
<li><a href="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/rsdoiel/scripttool">Github</a></li>
</ul>

Expand Down
1 change: 1 addition & 0 deletions license.html
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
<li><a href="license.html">LICENSE</a></li>
<li><a href="install.html">INSTALL</a></li>
<li><a href="docs/scripttool.html">Documentation</a></li>
<li><a href="TODO.html">TODO</a></li>
<li><a href="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/rsdoiel/scripttool">Github</a></li>
</ul>

Expand Down
54 changes: 2 additions & 52 deletions scripttool.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,9 @@
package scripttool

import (
"encoding/xml"
"fmt"
"io"
"io/ioutil"
"strings"

// My packages
"github.com/rsdoiel/fdx"
Expand All @@ -56,59 +54,11 @@ func Fdx2Fountain(in io.Reader, out io.Writer) error {
return err
}

screenplay := new(fdx.FinalDraft)
err = xml.Unmarshal(src, &screenplay)
screenplay, err := fdx.Parse(src)
if err != nil {
return err
}
// FIXME: See if we have a title page
if screenplay.TitlePage != nil {
fmt.Println("DEBUG we have a title page!")
m := screenplay.TitlePageAsMap()
if val, ok := m["Title"]; ok == true {
fmt.Fprintf(out, "Title:\n")
for _, line := range strings.Split(val, "\n") {
fmt.Fprintln(out, " %s\n", line)
}
}
if val, ok := m["Credit"]; ok == true {
fmt.Fprintf(out, "Credit: ")
for _, line := range strings.Split(val, "\n") {
fmt.Fprintln(out, " %s\n", line)
}
}
if val, ok := m["Author"]; ok == true {
fmt.Fprintf(out, "Author: ")
for _, line := range strings.Split(val, "\n") {
fmt.Fprintln(out, " %s\n", line)
}
}
if val, ok := m["Source"]; ok == true {
fmt.Fprintf(out, "Source: ")
for _, line := range strings.Split(val, "\n") {
fmt.Fprintln(out, " %s\n", line)
}
}
if val, ok := m["Draft date"]; ok == true {
fmt.Fprintf(out, "Draft date: ")
for _, line := range strings.Split(val, "\n") {
fmt.Fprintln(out, " %s\n", line)
}
}
if val, ok := m["Contact"]; ok == true {
fmt.Fprintf(out, "Contact:\n")
for _, line := range strings.Split(val, "\n") {
fmt.Fprintln(out, " %s\n", line)
}
}
if len(m) > 0 {
// Add the implicit page marker as two blank lines.
fmt.Fprintln(out, "\n\n")
}
}
if screenplay.Content != nil {
fmt.Println("DEBUG we have screenplay content!")
}
fmt.Fprintf(out, "%s", screenplay.String())
return nil
}

Expand Down
16 changes: 10 additions & 6 deletions scripttool_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,14 @@ var (
expectedDocs map[string][]byte
)

func screenplayFile(t *testing.T, fname string) {
src, err := ioutil.ReadFile(fname)
func screenplayFile(t *testing.T, dir, fname string) {
src, err := ioutil.ReadFile(path.Join(dir, fname))
if err != nil {
fmt.Fprintf(os.Stderr, "skipping %s, %s", fname, err)
if fname == "Big%20Fish.fdx" {
fmt.Fprintf(os.Stderr, "Skipping %s\n", fname)
} else {
fmt.Fprintf(os.Stderr, "Skipping %s, %s\n", fname, err)
}
return
}
screenplay := new(fdx.FinalDraft)
Expand All @@ -72,9 +76,9 @@ func screenplayFile(t *testing.T, fname string) {
}

func TestConversion(t *testing.T) {
screenplayFile(t, "testdata/testplay-01a.fdx")
screenplayFile(t, "testdata/testplay-01b.fdx")
screenplayFile(t, "testdata/Big Fish.fdx")
screenplayFile(t, "testdata", "testplay-01a.fdx")
screenplayFile(t, "testdata", "testplay-01b.fdx")
screenplayFile(t, "testdata", "Big%20Fish.fdx")
}

func TestMain(m *testing.M) {
Expand Down
1 change: 1 addition & 0 deletions testdata.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ <h1>About some of the test data</h1>
<li><a href="license.html">LICENSE</a></li>
<li><a href="install.html">INSTALL</a></li>
<li><a href="docs/scripttool.html">Documentation</a></li>
<li><a href="TODO.html">TODO</a></li>
<li><a href="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/rsdoiel/scripttool">Github</a></li>
</ul>

Expand Down

0 comments on commit 7148bc5

Please sign in to comment.