]> git.lyx.org Git - lyx.git/blobdiff - lib/lyx2lyx/LyX.py
jss.layout: correct appearance of sectioning commands
[lyx.git] / lib / lyx2lyx / LyX.py
index e7b2186706ae047c42b040562394f5770bad1a34..73818fa827557f1492dcf405823f4b15576b6c1b 100644 (file)
@@ -80,12 +80,12 @@ format_relation = [("0_06",    [200], minor_versions("0.6" , 4)),
                    ("1_1_6_3", [218], ["1.1", "1.1.6.3","1.1.6.4"]),
                    ("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" , 7)),
-                   ("1_6", range(277,346), minor_versions("1.6" , 10)),
-                   ("2_0", range(346,414), minor_versions("2.0", 8)),
-                   ("2_1", range(414,475), minor_versions("2.1", 0)),
-                   ("2_2", range(475,476), minor_versions("2.2", 0))
+                   ("1_4", list(range(222,246)), minor_versions("1.4" , 5)),
+                   ("1_5", list(range(246,277)), minor_versions("1.5" , 7)),
+                   ("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" , 0)),
+                   ("2_2", list(range(475,496)), minor_versions("2.2" , 0))
                   ]
 
 ####################################################################
@@ -147,6 +147,9 @@ def get_backend(textclass):
 
 def trim_eol(line):
     " Remove end of line char(s)."
+    if line[-1] != '\n' and line[-1] != '\r':
+        # May happen for the last line of a document
+        return line
     if line[-2:-1] == '\r':
         return line[:-2]
     else:
@@ -435,8 +438,22 @@ class LyX_base:
 
     def set_version(self):
         " Set the header with the version used."
-        self.header[0] = " ".join(["#LyX %s created this file." % version__,
-                                  "For more info see http://www.lyx.org/"])
+
+        initial_comment = " ".join(["#LyX %s created this file." % version__,
+                                    "For more info see http://www.lyx.org/"])
+
+        # Simple heuristic to determine the comment that always starts
+        # a lyx file
+        if self.header[0].startswith("#"):
+            self.header[0] = initial_comment
+        else:
+            self.header.insert(0, initial_comment)
+
+        # Old lyx files had a two lines comment header:
+        # 1) the first line had the user who had created it
+        # 2) the second line had the lyx version used
+        # later we decided that 1) was a privacy risk for no gain
+        # here we remove the second line effectively erasing 1)
         if self.header[1][0] == '#':
             del self.header[1]
 
@@ -717,6 +734,7 @@ class File(LyX_base):
         self.read()
 
 
+# FIXME: header settings are completely outdated, don't use like this
 #class NewFile(LyX_base):
 #    " This class is to create new LyX files."
 #    def set_header(self, **params):
@@ -745,6 +763,7 @@ class File(LyX_base):
 #            "\\use_amsmath 1",
 #            "\\cite_engine basic",
 #            "\\use_bibtopic false",
+#            "\\use_indices false",
 #            "\\paperorientation portrait",
 #            "\\secnumdepth 3",
 #            "\\tocdepth 3",