import getopt, sys, string, re
from error import error, warning
-from parser_tools import set_comment, set_format
+from parser_tools import set_comment, set_format, check_token
version = "0.0.2"
format = re.compile(r"(\d)[\.,]?(\d\d)")
fileformat = re.compile(r"\\lyxformat\s*(\S*)")
-lst_ft = ["210", "215", "216", "217", "218", "220"]
+lst_ft = ["210", "215", "216", "217", "218", "220", "221", "222"]
def usage():
print """Usage: lyx2lyx [options] file1
def parse_options(argv):
- _options = ["help", "version", "list", "from=", "to=", "output=", "quiet"]
+ _options = ["help", "version", "list", "debug=", "from=", "to=", "output=", "quiet"]
try:
- opts, args = getopt.getopt(argv[1:], "f:hlo:qt:v", _options)
+ opts, args = getopt.getopt(argv[1:], "d:f:hlo:qt:v", _options)
except getopt.error:
usage()
sys.exit(2)
def read_file(file, header, body):
"""Reads a file into the header and body parts"""
fmt = None
+ preamble = 0
+
while 1:
line = file.readline()
if not line:
sys.exit(3)
line = line[:-1]
- if not line:
+ if check_token(line, '\\begin_preamble'):
+ preamble = 1
+ if check_token(line, '\\end_preamble'):
+ preamble = 0
+
+ if not preamble:
+ line = string.strip(line)
+
+ if not line and not preamble:
break
header.append(line)