aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Vilcans <martin@librador.com>2015-10-12 09:03:11 +0200
committerMartin Vilcans <martin@librador.com>2015-10-12 09:03:11 +0200
commit5fac15c2aca4e364dabc1ab43342f6cf4ed985ae (patch)
tree93ca04e0ba4ed4e14cff48f1e8cbe718db42a626
parent334b735e05ae62f7ad345975de3995749818702b (diff)
parentefefca365ef9ab4413bb1ad8dc97e6b28a931202 (diff)
downloadscreenplain-5fac15c2aca4e364dabc1ab43342f6cf4ed985ae.tar.gz
Merge pull request #20 from charneykaye/pdf-scene-headings-bold
PDF exports Scene Headings as Bold and Underlined; fixes #14
-rw-r--r--screenplain/export/pdf.py14
-rw-r--r--screenplain/main.py11
2 files changed, 22 insertions, 3 deletions
diff --git a/screenplain/export/pdf.py b/screenplain/export/pdf.py
index 5f4380f..c5a9ee9 100644
--- a/screenplain/export/pdf.py
+++ b/screenplain/export/pdf.py
@@ -142,6 +142,15 @@ def add_paragraph(story, para, style):
story.append(Paragraph(line.to_html(), style))
+def add_slug(story, para, style, is_strong):
+ for line in para.lines:
+ if is_strong:
+ html = '<b><u>' + line.to_html() + '</u></b>'
+ else:
+ html = line.to_html()
+ story.append(Paragraph(html, style))
+
+
def add_dialog(story, dialog):
story.append(Paragraph(dialog.character.to_html(), character_style))
for parenthetical, line in dialog.blocks:
@@ -221,7 +230,8 @@ def get_title_page_story(screenplay):
return story
-def to_pdf(screenplay, output_filename, template_constructor=DocTemplate):
+def to_pdf(screenplay, output_filename, is_strong):
+ template_constructor = DocTemplate
story = get_title_page_story(screenplay)
has_title_page = bool(story)
@@ -236,7 +246,7 @@ def to_pdf(screenplay, output_filename, template_constructor=DocTemplate):
centered_action_style if para.centered else action_style
)
elif isinstance(para, Slug):
- add_paragraph(story, para, slug_style)
+ add_slug(story, para, slug_style, is_strong)
elif isinstance(para, Transition):
add_paragraph(story, para, transition_style)
elif isinstance(para, types.PageBreak):
diff --git a/screenplain/main.py b/screenplain/main.py
index 43e44a1..3d5e711 100644
--- a/screenplain/main.py
+++ b/screenplain/main.py
@@ -49,6 +49,15 @@ def main(args):
'not a complete HTML document.'
)
)
+ parser.add_option(
+ '--strong',
+ action='store_true',
+ dest='strong',
+ help=(
+ 'For PDF output, scene headings will appear '
+ 'Bold and Underlined.'
+ )
+ )
options, args = parser.parse_args(args)
if len(args) >= 3:
parser.error('Too many arguments')
@@ -85,7 +94,7 @@ def main(args):
if not output_file:
sys.stderr.write("Can't write PDF to standard output")
sys.exit(2)
- to_pdf(screenplay, output_file)
+ to_pdf(screenplay, output_file, options.strong)
else:
if output_file:
output = codecs.open(output_file, 'w', 'utf-8')