Skip to content

Commit

Permalink
Default to no break limit
Browse files Browse the repository at this point in the history
  • Loading branch information
nimaid committed Jul 22, 2020
1 parent 7f4f363 commit d61a5f8
Showing 1 changed file with 16 additions and 12 deletions.
28 changes: 16 additions & 12 deletions bookdir2pdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ def path_to_ext(path_in):
tocf_args = ()

# Defaults
toc_line_break_limit = 80
toc_line_break_limit = None
pagenum_pre = "Page #"
pagenum_post = " "
ident_str = "--- "
Expand All @@ -297,13 +297,16 @@ def path_to_ext(path_in):
except(ValueError):
worked = False

# Test if it's greater than 10
# Test if it's greater than min_toc_line_break_limit
min_toc_line_break_limit = 10
if toc_line_break_limit <= min_toc_line_break_limit:
if toc_line_break_limit == 0:
toc_line_break_limit = None
workied=True
elif toc_line_break_limit <= min_toc_line_break_limit:
worked = False

if not worked:
raise argparse.ArgumentTypeError("(--break_limit | -b) length must be an integer greater than {}.".format(min_toc_line_break_limit))
raise argparse.ArgumentTypeError("(--break_limit | -b) length must be an integer greater than {}, or 0 for no limit.".format(min_toc_line_break_limit))
elif tocf_arg_name in ["number_prefix", "p"]:
pagenum_pre = tocf_arg_value
elif tocf_arg_name in ["number_postfix", "a"]:
Expand Down Expand Up @@ -404,11 +407,12 @@ def path_to_ext(path_in):
print("\tSharpening factor: {}".format(sharpen_factor))
print("\tThreshold: {}.".format(thresh_setting))

print("Table of Contents formatting:")
print("\tName length break limit: {}".format(toc_line_break_limit))
print("\tPage number prefix: '{}'".format(pagenum_pre))
print("\tPage number postfix: '{}'".format(pagenum_post))
print("\tIndent text: '{}'".format(ident_str))
if args["table_of_contents_format"] != None:
print("Table of Contents formatting:")
print("\tName length break limit: {}".format(toc_line_break_limit))
print("\tPage number prefix: '{}'".format(pagenum_pre))
print("\tPage number postfix: '{}'".format(pagenum_post))
print("\tIndent text: '{}'".format(ident_str))


# We will be catching KeyboardInterrupts
Expand Down Expand Up @@ -904,9 +908,9 @@ def make_toc_row(bm_dict_in):
final_row += "\n" + base_space + l
return final_row

# If we didn't break it up, just return it
final_row += "\n" + page_toc_base + bm_dict_in["name"]
return final_row.strip("\n")
# If we didn't break it up, just return it
final_row += page_toc_base + bm_dict_in["name"]
return final_row

# Make rows of ToC
toc_row_list = [make_toc_row(r) for r in toc_dict_list]
Expand Down

0 comments on commit d61a5f8

Please sign in to comment.