aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--screenplain/export/html.py13
-rw-r--r--screenplain/main.py13
2 files changed, 20 insertions, 6 deletions
diff --git a/screenplain/export/html.py b/screenplain/export/html.py
index b987d81..625fcb4 100644
--- a/screenplain/export/html.py
+++ b/screenplain/export/html.py
@@ -166,12 +166,11 @@ class Formatter(object):
def _read_file(filename):
- path = os.path.join(os.path.dirname(__file__), filename)
with open(path) as stream:
return stream.read()
-def convert(screenplay, out, bare=False):
+def convert(screenplay, out, css_file=None, bare=False):
"""Convert the screenplay into HTML, written to the file-like object `out`.
The output will be a complete HTML document unless `bare` is true.
@@ -180,15 +179,19 @@ def convert(screenplay, out, bare=False):
if bare:
convert_bare(screenplay, out)
else:
- convert_full(screenplay, out)
+ convert_full(
+ screenplay, out,
+ css_file or os.path.join(os.path.dirname(__file__), 'default.css')
+ )
-def convert_full(screenplay, out):
+def convert_full(screenplay, out, css_file):
"""Convert the screenplay into a complete HTML document,
written to the file-like object `out`.
"""
- css = _read_file('default.css')
+ with open(css_file, 'r') as stream:
+ css = stream.read()
out.write(
'<!DOCTYPE html>\n'
'<html>'
diff --git a/screenplain/main.py b/screenplain/main.py
index ba6fc10..4469489 100644
--- a/screenplain/main.py
+++ b/screenplain/main.py
@@ -50,6 +50,14 @@ def main(args):
)
)
parser.add_option(
+ '--css',
+ metavar='FILE',
+ help=(
+ 'For HTML output, inline the given CSS file in the HTML document '
+ 'instead of the default.'
+ )
+ )
+ parser.add_option(
'--strong',
action='store_true',
dest='strong',
@@ -109,7 +117,10 @@ def main(args):
to_fdx(screenplay, output)
elif format == 'html':
from screenplain.export.html import convert
- convert(screenplay, output, bare=options.bare)
+ convert(
+ screenplay, output,
+ css_file=options.css, bare=options.bare
+ )
finally:
if output_file:
output.close()