File: remove-tt.py

package info (click to toggle)
orpie 1.5.2-2
  • links: PTS
  • area: main
  • in suites: buster
  • size: 1,924 kB
  • ctags: 2,720
  • sloc: ml: 13,872; ansic: 3,754; makefile: 310; sh: 11; python: 11
file content (21 lines) | stat: -rw-r--r-- 501 bytes parent folder | download | duplicates (9)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#!/usr/bin/env python
# Strip out all the \texttt{} occurrences (not perfect, but good enough)
import re, sys

infilename  = sys.argv[1]
outfilename = sys.argv[2]

infile = open(infilename, "r").read()

tt_regex         = re.compile("\\\\texttt\{([^}]+)}")

def tt_replace(m):
   return m.group(1) 

replaced_string = re.sub(tt_regex, tt_replace, infile)

outfile = open(outfilename, "w")
outfile.write(replaced_string)
outfile.close()

# arch-tag: DO_NOT_CHANGE_97d4155d-0a4e-42ae-ae0a-0d064c1a7b71