-
Notifications
You must be signed in to change notification settings - Fork 0
/
generate_diff.py
30 lines (25 loc) · 920 Bytes
/
generate_diff.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import os
"""
a convenience script to easily generate latexdiffs for projects with multiple tex files
how to use:
1. copy the old version to old/, and the new version to new/
2. install latex, or use the docker image to enter latex-enabled environment
`docker run --rm -it -v $(pwd):/workdir yasu31/latex-docker
3. run this script
4. go to the diff/ folder, and compile PDF:
```
pdflatex main
bibtex main
pdflatex main
pdflatex main
```
"""
# first copy everything in new/ to /diff (since materials like images can't be diff'ed)
os.system("cp -R new/* diff/")
# find files that end in .tex in the old/ directory
tex_files = [f for f in os.listdir('old/') if f.endswith('.tex')]
for tex_file in tex_files:
# run bash command to generate diff file
print(f"diffing {tex_file}...")
os.system(f'latexdiff -t BOLD "old/{tex_file}" "new/{tex_file}" > "diff/{tex_file}"')
# BOLD, CFONT, FONTSTRIKE etc...