("1_2", [220], minor_versions("1.2" , 4)),
("1_3", [221], minor_versions("1.3" , 7)),
("1_4", range(222,246), minor_versions("1.4" , 5)),
- ("1_5", range(246,277), minor_versions("1.5" , 1)),
- ("1_6", range(277,290), minor_versions("1.6" , 0))] #MV, index collapsable
+ ("1_5", range(246,277), minor_versions("1.5" , 2)),
+ ("1_6", range(277,312), minor_versions("1.6" , 0))] # Richard Heck: AMS conversion
def formats_list():
self.default_layout = ''
self.header = []
self.preamble = []
- self.manifest = []
self.body = []
self.status = 0
self.encoding = encoding
def read(self):
- """Reads a file into the self.header, self.manifest and
+ """Reads a file into the self.header and
self.body parts, from self.input."""
while True:
if check_token(line, '\\end_preamble'):
continue
- if check_token(line, '\\begin_manifest'):
- while 1:
- line = self.input.readline()
- if not line:
- self.error("Invalid LyX file.")
-
- line = trim_eol(line)
- if check_token(line, "\\end_manifest"):
- break
-
- if not line.startswith('\\filename') and \
- not line.startswith('\\inzipName') and \
- not line.startswith('\\embed'):
- self.warning("Malformed LyX file: Missing"
- "'\\end_manifest'.")
-
- self.manifest.append(line)
-
- if check_token(line, '\\end_manifest'):
- continue
-
line = line.strip()
if not line:
continue
else:
header = self.header
- # LyX file format <= 284 does not have a manifest section
- # so this section is set to None
- if self.manifest is None:
- manifest = []
- else:
- manifest = ['\\begin_manifest'] + self.manifest + ['\\end_manifest', '']
-
- for line in header + [''] + manifest + self.body:
+ for line in header + [''] + self.body:
self.output.write(line.encode(self.encoding)+"\n")
self.header[i] = "\\textclass %s" % self.textclass
+ #Note that the module will be added at the END of the extant ones
+ def add_module(self, module):
+ i = find_token(self.header, "\\begin_modules", 0)
+ if i == -1:
+ #No modules yet included
+ i = find_token(self.header, "\\textclass", 0)
+ if i == -1:
+ self.warning("Malformed LyX document: No \\textclass!!")
+ return
+ modinfo = ["\\begin_modules", module, "\\end_modules"]
+ self.header[i + 1: i + 1] = modinfo
+ return
+ j = find_token(self.header, "\\end_modules", i)
+ if j == -1:
+ self.warning("Malformed LyX document: No \\end_modules.")
+ return
+ k = find_token(self.header, module, i)
+ if k != -1 and k < j:
+ return
+ self.header.insert(j, module)
+
+
def set_parameter(self, param, value):
" Set the value of the header parameter."
i = find_token(self.header, '\\' + param, 0)