# This file is part of lyx2lyx
# -*- coding: utf-8 -*-
-# Copyright (C) 2002-2015 The LyX Team
+# Copyright (C) 2002-2018 The LyX Team
# Copyright (C) 2002-2004 Dekel Tsur <dekel@lyx.org>
# Copyright (C) 2002-2006 José Matos <jamatos@lyx.org>
#
import re
import time
import io
+import codecs
try:
import lyx2lyx_version
version__ = lyx2lyx_version.version
+ stable_version = True
except: # we are running from build directory so assume the last version
- version__ = '2.3'
+ version__ = '2.4'
+ stable_version = False
default_debug__ = 2
("1_6", list(range(277,346)), minor_versions("1.6" , 10)),
("2_0", list(range(346,414)), minor_versions("2.0" , 8)),
("2_1", list(range(414,475)), minor_versions("2.1" , 5)),
- ("2_2", list(range(475,509)), minor_versions("2.2" , 0)),
- ("2_3", (), minor_versions("2.3" , 0))
+ ("2_2", list(range(475,509)), minor_versions("2.2" , 4)),
+ ("2_3", list(range(509,545)), minor_versions("2.3" , 0)),
+ ("2_4", (), minor_versions("2.4" , 0))
]
####################################################################
def format_info():
- " Returns a list with supported file formats."
- out = """Major version:
- minor versions
- formats
+ " Returns a list with the supported file formats."
+ template = """
+%s\tstable format: %s
+ \tstable versions: %s
+ \tdevelopment formats: %s
"""
+
+ out = "version: formats and versions"
for version in format_relation:
major = str(version[2][0])
versions = str(version[2][1:])
if len(version[1]) == 1:
formats = str(version[1][0])
+ stable_format = str(version[1][0])
+ elif not stable_version and major == version__:
+ stable_format = "-- not yet --"
+ versions = "-- not yet --"
+ formats = "%s - %s" % (version[1][0], version[1][-1])
else:
- formats = "%s - %s" % (version[1][-1], version[1][0])
- out += "%s\n\t%s\n\t%s\n\n" % (major, versions, formats)
+ formats = "%s - %s" % (version[1][0], version[1][-2])
+ stable_format = str(version[1][-1])
+
+ out += template % (major, stable_format, versions, formats)
return out + '\n'
# use latin1. This works since a) the parts we are interested in are
# pure ASCII (subset of latin1) and b) in contrast to pure ascii or
# utf8, one can decode any 8byte string using latin1.
+ first_line = True
while True:
line = self.input.readline()
if not line:
# eof found before end of header
self.error("Invalid LyX file: Missing body.")
+ if first_line:
+ # Remove UTF8 BOM marker if present
+ if line.startswith(codecs.BOM_UTF8):
+ line = line[len(codecs.BOM_UTF8):]
+
+ first_line = False
+
if PY2:
line = trim_eol(line)
decoded = line
self.inputencoding = get_value(self.header, b"\\inputencoding", 0,
default = b"auto").decode('ascii')
self.format = self.read_format()
+ self.initial_format = self.format
self.encoding = get_encoding(self.language,
self.inputencoding, self.format,
self.cjk_encoding)
else:
header = self.header
- for line in header + [''] + self.body:
- self.output.write(line+u"\n")
+ for line in header + [u''] + self.body:
+ self.output.write(line+u'\n')
def choose_output(self, output):
" Set the header with the version used."
initial_comment = " ".join(["#LyX %s created this file." % version__,
- "For more info see http://www.lyx.org/"])
+ "For more info see https://www.lyx.org/"])
# Simple heuristic to determine the comment that always starts
# a lyx file
conversion are taken. It returns a list of modules needed to
convert the LyX file from self.format to self.end_format"""
- self.start = self.format
format = self.format
correct_version = 0
# Convertion mode, back or forth
steps = []
- if (initial_step, self.start) < (final_step, self.end_format):
+ if (initial_step, self.initial_format) < (final_step, self.end_format):
mode = "convert"
full_steps = []
for step in format_relation: