add line numbers, make it one column by default
This commit is contained in:
16
TODO.md
16
TODO.md
@@ -1,13 +1,15 @@
|
||||
## TODO
|
||||
- silent mode by default when doing PDF
|
||||
- add nice spacing and typography for easy reading
|
||||
- make
|
||||
- pdf options
|
||||
- problem numbers [true]
|
||||
- number of columns [auto]
|
||||
- include column labels
|
||||
- print
|
||||
- addition
|
||||
- subtraction
|
||||
- mult? div?
|
||||
- make it prettier
|
||||
- different font, using nice fonts if they're available on someone's system
|
||||
- better spacing
|
||||
- [use different sized fonts for different parts](https://unix.stackexchange.com/a/500365)
|
||||
- arithmetic
|
||||
- addition
|
||||
- subtraction
|
||||
- mult? div?
|
||||
- hex?
|
||||
|
||||
|
||||
20
app/main.py
20
app/main.py
@@ -13,8 +13,8 @@ from app.pdf import make_pdf
|
||||
@click.option("--silent", default=False, is_flag=True)
|
||||
@click.option("--include-answers", default=True, is_flag=True)
|
||||
@click.option("--output-filepath")
|
||||
@click.option("--num-columns", default=4)
|
||||
@click.option("--font-size", default=12)
|
||||
@click.option("--num-columns", default=1)
|
||||
@click.option("--font-size", default=26)
|
||||
def main(
|
||||
bits: int,
|
||||
num_problems: int,
|
||||
@@ -22,17 +22,14 @@ def main(
|
||||
silent: bool = False,
|
||||
include_answers: bool = True,
|
||||
output_filepath: str = None,
|
||||
num_columns: int = 4,
|
||||
font_size: int = 12,
|
||||
num_columns: int = 1,
|
||||
font_size: int = 26,
|
||||
) -> None:
|
||||
|
||||
validate_args(pdf, silent, output_filepath)
|
||||
|
||||
answers, problems = make_problems_and_answers(bits, num_problems)
|
||||
|
||||
if bits > 12:
|
||||
num_columns = 3
|
||||
|
||||
if pdf:
|
||||
silent = True
|
||||
make_pdf(
|
||||
@@ -65,8 +62,13 @@ def validate_args(pdf, silent, output_filepath):
|
||||
def make_problems_and_answers(bits, num_problems):
|
||||
problems = generate_problems(bits, num_problems)
|
||||
answers = generate_answers(problems)
|
||||
problems_string = "\n\n".join(problems)
|
||||
problems_string = "\n\n".join(
|
||||
[f"{index:2}) {p} =" for index, p in enumerate(problems, start=1)]
|
||||
)
|
||||
answers_string = "\n\n".join(
|
||||
[f"{problem} | {answer} " for problem, answer in zip(problems, answers)]
|
||||
[
|
||||
f"{index:2}) {problem} = {answer}"
|
||||
for index, (problem, answer) in enumerate(zip(problems, answers), start=1)
|
||||
]
|
||||
)
|
||||
return answers_string, problems_string
|
||||
|
||||
@@ -46,9 +46,9 @@ def make_pdf_file(output_path):
|
||||
subprocess.call(command, shell=True)
|
||||
|
||||
|
||||
def make_postscript_file(txt_file: str, num_columns: int, font_size: int):
|
||||
def make_postscript_file(txt_file, num_columns: int, font_size: int):
|
||||
command = (
|
||||
f"enscript --columns={num_columns} --no-header --output={POSTSCRIPT_FILEPATH} "
|
||||
f"-FCourier{font_size} {txt_file.name}"
|
||||
f"enscript --columns={num_columns} --no-header --font=Courier{font_size} "
|
||||
f"--output={POSTSCRIPT_FILEPATH} {txt_file.name}"
|
||||
)
|
||||
subprocess.call(command, shell=True)
|
||||
|
||||
BIN
problems-answers.pdf
Normal file
BIN
problems-answers.pdf
Normal file
Binary file not shown.
BIN
problems.pdf
Normal file
BIN
problems.pdf
Normal file
Binary file not shown.
Reference in New Issue
Block a user