Add flag to format the whole document including the title page (if any).
continuous-integration/drone/push Build is failing
Details
continuous-integration/drone/push Build is failing
Details
This commit is contained in:
parent
a4663d8139
commit
89faad1b2b
|
@ -83,7 +83,7 @@ def right_align_header(document):
|
||||||
header_paragraph.paragraph_format.alignment = docx.enum.text.WD_ALIGN_PARAGRAPH.RIGHT
|
header_paragraph.paragraph_format.alignment = docx.enum.text.WD_ALIGN_PARAGRAPH.RIGHT
|
||||||
|
|
||||||
|
|
||||||
def double_space_and_indent(paragraphs):
|
def double_space_and_indent(paragraphs, format_all):
|
||||||
previous_paragraph = None
|
previous_paragraph = None
|
||||||
this_paragraph_plaintext = False
|
this_paragraph_plaintext = False
|
||||||
previous_paragraph_plaintext = None
|
previous_paragraph_plaintext = None
|
||||||
|
@ -100,7 +100,7 @@ def double_space_and_indent(paragraphs):
|
||||||
reached_first_heading = True
|
reached_first_heading = True
|
||||||
|
|
||||||
# Skip past the title page until we reach the first chapter/other heading.
|
# Skip past the title page until we reach the first chapter/other heading.
|
||||||
if not reached_first_heading:
|
if not reached_first_heading and not format_all:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
paragraph.paragraph_format.line_spacing = 2
|
paragraph.paragraph_format.line_spacing = 2
|
||||||
|
@ -150,6 +150,13 @@ def parse_arguments(unparsed_arguments):
|
||||||
'--title',
|
'--title',
|
||||||
help='Project title to show in page headers, defaults to the manuscript filename without the file extension',
|
help='Project title to show in page headers, defaults to the manuscript filename without the file extension',
|
||||||
)
|
)
|
||||||
|
parser.add_argument(
|
||||||
|
'-f',
|
||||||
|
'--format-all',
|
||||||
|
help='Format the whole document, even the title page (if any)',
|
||||||
|
action='store_true',
|
||||||
|
default=False,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
return parser.parse_args(unparsed_arguments)
|
return parser.parse_args(unparsed_arguments)
|
||||||
|
@ -170,7 +177,7 @@ def main():
|
||||||
skip_page_number_on_first_page(document)
|
skip_page_number_on_first_page(document)
|
||||||
|
|
||||||
right_align_header(document)
|
right_align_header(document)
|
||||||
double_space_and_indent(document.paragraphs)
|
double_space_and_indent(document.paragraphs, arguments.format_all)
|
||||||
|
|
||||||
document.save(arguments.document_filename)
|
document.save(arguments.document_filename)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue