re_CopyStyle = re.compile(r'^(\s*)(CopyStyle)(\s+)(\S+)', re.IGNORECASE)
re_NoStyle = re.compile(r'^(\s*)(NoStyle)(\s+)(\S+)', re.IGNORECASE)
re_End = re.compile(r'^(\s*)(End)(\s*)$', re.IGNORECASE)
+ re_Provides = re.compile(r'^(\s*)Provides(\S+)(\s+)(\S+)', re.IGNORECASE)
# counters for sectioning styles (hardcoded in 1.3)
counters = {"part" : "\\Roman{part}",
match = re_Format.match(lines[i])
if match:
format = int(match.group(4))
- if format == 2:
- lines[i] = "Format 3"
+ if format > 1 and format < 4:
+ lines[i] = "Format %d" % (format + 1)
only_comment = 0
- elif format == 3:
+ elif format == 4:
# nothing to do
- return
+ return format
else:
error('Cannot convert file format %s' % format)
else:
- lines.insert(i, "Format 3")
+ lines.insert(i, "Format 2")
only_comment = 0
continue
i = i + 1
continue
+ if format == 3:
+ # convert 'providesamsmath x', 'providesmakeidx x', 'providesnatbib x', 'providesurl x' to
+ # 'provides amsmath x', 'provides makeidx x', 'provides natbib x', 'provides url x'
+ # x is either 0 or 1
+ match = re_Provides.match(lines[i])
+ if match:
+ lines[i] = "%sProvides %s%s%s" % (match.group(1), match.group(2).lower(),
+ match.group(3), match.group(4))
+ i = i + 1
+ continue
+
if format == 2:
caption = []
i = i + 1
+ return format + 1
+
def main(argv):
# Do the real work
lines = read(input)
- convert(lines)
+ format = 1
+ while (format < 4):
+ format = convert(lines)
write(output, lines)
# Close files