blob: 1f380322ec6ed8a0d1a1b7cebab77fe8436f125c (
plain)
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
31
32
33
34
35
|
#!/usr/bin/python3
# Farcical script to remove newlines after
# \begin{sidebar} in dblatex' .tex output;
#
# farcical because I'm sure this can be done
# in 1 line of sed, and also because I'm sure
# the whole need for this script could be fixed
# in the dcpomatic.sty (but I don't know how).
import sys
import os
import tempfile
import shutil
f = open(sys.argv[1])
t = tempfile.NamedTemporaryFile(delete=False)
remove_next = False
while True:
l = f.readline()
if l == '':
break
if not remove_next:
t.write(l.encode('UTF-8'))
remove_next = False
if l.strip() == '\\begin{sidebar}':
remove_next = True
f.close()
t.close()
shutil.move(t.name, sys.argv[1])
|