aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Vilcans <martin@librador.com>2015-11-26 21:23:11 +0100
committerMartin Vilcans <martin@librador.com>2015-11-26 21:23:54 +0100
commitb6dce18fbc850c4e8c39ac1405ac6261666697f1 (patch)
tree9fc748d09ae554323e3e7af72927f83dde800915
parentfe3a3c714221288b81127beee389b0431cad8527 (diff)
downloadscreenplain-b6dce18fbc850c4e8c39ac1405ac6261666697f1.tar.gz
Possible to specify which CSS file to use
Closes #24
-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()