Skip to content

Commit

Permalink
modify build script for two exercise versions
Browse files Browse the repository at this point in the history
  • Loading branch information
wallscheid committed Jul 28, 2024
1 parent 8ebda6c commit af5ae47
Showing 1 changed file with 29 additions and 1 deletion.
30 changes: 29 additions & 1 deletion exercise/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def clear_tex_binaries():
os.remove(file)


# build main pdf
# build main pdf (with solutions)
clear_tex_binaries()
with fileinput.input('main.tex', inplace=True) as f:
for line in f:
Expand All @@ -34,6 +34,34 @@ def clear_tex_binaries():
call(call_pdflatex_l)


# go into the parent directory
os.chdir('..')
os.makedirs('built', exist_ok=True)
#take main.pdf from the exercise folder and move it to the parent folder
os.replace('exercise/main.pdf', os.path.join('built', 'exercise_with_solution.pdf'))


# build main pdf (without solutions)
os.chdir('exercise')
clear_tex_binaries()
with fileinput.input('main.tex', inplace=True) as f:
for line in f:
if 'includeonly{' in line:
# comment out includeonly flag
print(f'%{line}', end='')
#check if the line including '\documentclass' has the parameter 'solution' - if yes remove it
elif '{exerciseClass}' in line:
if 'solution' in line:
print(line.replace(', [solution]{exerciseClass}', '{exerciseClass}'), end='')
else:
print(line, end='')
else:
print(line, end='')

call(call_pdflatex_l)
call(call_pdflatex_l)


# go into the parent directory
os.chdir('..')
os.makedirs('built', exist_ok=True)
Expand Down

0 comments on commit af5ae47

Please sign in to comment.