- for line in open(latex_file, 'r').readlines():
- match = documentclass_re.match(line)
- if match != None:
- changed = 1
- tmp.write("%s%s\n" % (match.group(1), match.group(3)))
- continue
-
- if not pdf_output and not usepkg:
- if userpreamble_re.search(line) != None:
- in_user_preamble = 1
- elif enduserpreamble_re.search(line) != None:
- in_user_preamble = 0
- if usepackage_re.match(line) != None and in_user_preamble:
- usepkg = 1
- changed = 1
- tmp.write("\\def\\t@a{microtype}\n")
- tmp.write("\\let\\oldusepkg\\usepackage\n")
- tmp.write("\\def\\usepackage{\\@ifnextchar[\\@usepkg{\\@usepkg[]}}\n")
- tmp.write("\\def\\@usepkg[#1]#2{\\@ifnextchar[")
- tmp.write("{\\@@usepkg[#1]{#2}}{\\@@usepkg[#1]{#2}[]}}\n")
- tmp.write("\\def\@@usepkg[#1]#2[#3]{\\def\\t@b{#2}")
- tmp.write("\\ifx\\t@a\\t@b\\else\\oldusepkg[#1]{#2}[#3]\\fi}\n")
- tmp.write(line)
- continue
-
- match = def_re.match(line)
- if match == None:
- tmp.write(line)
- continue
-
- macroname = match.group(2)
- if not macroname in macros:
- macros.append(macroname)
- tmp.write(line)
- continue
-
- definecmd = match.group(1)
- if definecmd == "\\global\\long\\def":
- tmp.write(line)
+ for line in open(latex_file, 'rb').readlines():
+ if not pdf_output and line.startswith(b"\\documentclass"):
+ changed = True
+ line += b"\\PassOptionsToPackage{draft}{microtype}\n"