Skip to content

Instantly share code, notes, and snippets.

@gkthiruvathukal
Created December 25, 2019 05:19
Show Gist options
  • Save gkthiruvathukal/05e82bfbec79df32fc239b16ca4ef7d0 to your computer and use it in GitHub Desktop.
Save gkthiruvathukal/05e82bfbec79df32fc239b16ca4ef7d0 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python3
import sys
in_file = sys.argv[1]
out_file = sys.argv[2]
def add_table_hline(text):
return text.replace(
"\\end{minipage}\\tabularnewline\n\\begin{minipage}",
"\\end{minipage}\\tabularnewline\\hline\n\\begin{minipage}"
)
def add_table_vline(text):
t1 = text.replace("@{}lll@{}", "@{}l|l|l@{}")
t2 = t1.replace("@{}ll@{}", "@{}l|l@{}")
return t2
with open(in_file) as inf:
text = inf.read()
with open(out_file,"w") as outf:
transforms = [ add_table_hline, add_table_vline ]
new_text = text
for transform in transforms:
new_text = transform(new_text)
outf.write(new_text)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment