From fd832267cf7b55b4d3cdc56e313eb2bec215cc55 Mon Sep 17 00:00:00 2001 From: michaelx386 Date: Fri, 18 Sep 2015 17:51:49 +0100 Subject: Parse files with BOM present; fixes #5 --- screenplain/main.py | 2 +- tests/files/utf-8-bom.fountain | 18 ++++++++++++++++ tests/files/utf-8-bom.fountain.fdx | 43 +++++++++++++++++++++++++++++++++++++ tests/files/utf-8-bom.fountain.html | 6 ++++++ 4 files changed, 68 insertions(+), 1 deletion(-) create mode 100644 tests/files/utf-8-bom.fountain create mode 100644 tests/files/utf-8-bom.fountain.fdx create mode 100644 tests/files/utf-8-bom.fountain.html diff --git a/screenplain/main.py b/screenplain/main.py index ac308b5..43e44a1 100644 --- a/screenplain/main.py +++ b/screenplain/main.py @@ -75,7 +75,7 @@ def main(args): ) if input_file: - input = codecs.open(input_file, 'r', 'utf-8') + input = codecs.open(input_file, 'r', 'utf-8-sig') else: input = codecs.getreader('utf-8')(sys.stdin) screenplay = fountain.parse(input) diff --git a/tests/files/utf-8-bom.fountain b/tests/files/utf-8-bom.fountain new file mode 100644 index 0000000..ddfe1f9 --- /dev/null +++ b/tests/files/utf-8-bom.fountain @@ -0,0 +1,18 @@ +EXT. SOMEWHERE - DAY + +GUY and GURL walk down the street. + +It's a sunny day. +Sunnier than normal. +Too sunny to be funny. + +GUY +So what's up? + +GURL +Nothing much. +Just thinking. +And you? + +GUY +Nothing. \ No newline at end of file diff --git a/tests/files/utf-8-bom.fountain.fdx b/tests/files/utf-8-bom.fountain.fdx new file mode 100644 index 0000000..9701f3a --- /dev/null +++ b/tests/files/utf-8-bom.fountain.fdx @@ -0,0 +1,43 @@ + + + + + + EXT. SOMEWHERE - DAY + + + GUY and GURL walk down the street. + + + It's a sunny day. + + Sunnier than normal. + + Too sunny to be funny. + + + GUY + + + So what's up? + + + GURL + + + Nothing much. + + + Just thinking. + + + And you? + + + GUY + + + Nothing. + + + diff --git a/tests/files/utf-8-bom.fountain.html b/tests/files/utf-8-bom.fountain.html new file mode 100644 index 0000000..70043dd --- /dev/null +++ b/tests/files/utf-8-bom.fountain.html @@ -0,0 +1,6 @@ +
EXT. SOMEWHERE - DAY
+

GUY and GURL walk down the street.

+

It's a sunny day.
Sunnier than normal.
Too sunny to be funny.

+

GUY

So what's up?

+

GURL

Nothing much.

Just thinking.

And you?

+

GUY

Nothing.

-- cgit