]> git.lyx.org Git - lyx.git/blobdiff - lib/lyx2lyx/lyxconvert_218.py
add bibtopic support (bug 870).
[lyx.git] / lib / lyx2lyx / lyxconvert_218.py
index 8d40596ad84f4ab4c06650ecacf7c561d4d51566..91af9d898d231d4331328829ee806f1c5fd70664 100644 (file)
@@ -1,4 +1,5 @@
 # This file is part of lyx2lyx
+# -*- coding: iso-8859-1 -*-
 # Copyright (C) 2002 Dekel Tsur <dekel@lyx.org>
 #
 # This program is free software; you can redistribute it and/or
@@ -106,7 +107,7 @@ def remove_oldfloat(lines, language):
        # whose value is not default before the float.
        # The check here is not accurate, but it doesn't matter
        # as extra '\foo default' commands are ignored.
-       # In fact, it might be safer to output '\foo default' for all 
+       # In fact, it might be safer to output '\foo default' for all
        # font attributes.
        k = get_paragraph(lines, i)
        flag = 0
@@ -164,11 +165,8 @@ def remove_pextra(lines):
        else:
            start = ["\\layout Standard"] + start
 
-       j = find_token_backwards(lines,"\\layout", i-1)
-       j0 = j
-
-       j = find_tokens(lines, ["\\layout", "\\end_float"], i+1)
-       # j can be -1
+       j0 = find_token_backwards(lines,"\\layout", i-1)
+       j = get_next_paragraph(lines, i)
 
        count = 0
        while 1:
@@ -198,7 +196,7 @@ def is_empty(lines):
     return filter(is_nonempty_line, lines) == []
 
 move_rexp =  re.compile(r"\\(family|series|shape|size|emph|numeric|bar|noun|end_deeper)")
-ert_rexp = re.compile(r"\\begin_inset|.*\\SpecialChar")
+ert_rexp = re.compile(r"\\begin_inset|\\hfill|.*\\SpecialChar")
 spchar_rexp = re.compile(r"(.*)(\\SpecialChar.*)")
 ert_begin = ["\\begin_inset ERT",
             "status Collapsed",
@@ -236,11 +234,15 @@ def remove_oldert(lines):
        k = i+1
        while 1:
            k2 = find_re(lines, ert_rexp, k, j)
-           inset = specialchar = 0
+           inset = hfill = specialchar = 0
            if k2 == -1:
                k2 = j
            elif check_token(lines[k2], "\\begin_inset"):
                inset = 1
+            elif check_token(lines[k2], "\\hfill"):
+                hfill = 1
+                del lines[k2]
+                j = j-1
            else:
                specialchar = 1
                mo = spchar_rexp.match(lines[k2])
@@ -279,6 +281,9 @@ def remove_oldert(lines):
                if not is_nonempty_line(lines[k]):
                    k = k+1
                    new.append("")
+            elif hfill:
+                new = new+["\hfill", ""]
+                k = k2
            elif specialchar:
                if new == []:
                    # This is not necessary, but we want the output to be
@@ -357,7 +362,7 @@ def combine_ert(lines):
            lines[j:k] = text
 
        i = i+1
-       
+
 oldunits = ["pt", "cm", "in", "text%", "col%"]
 
 def get_length(lines, name, start, end):
@@ -406,9 +411,13 @@ def remove_figinset(lines):
        else:
            display = "color"
 
-       subcaptionText = get_value(lines, "subcaption", i+1, j)
-       if subcaptionText != "":
-           subcaptionText = '"'+subcaptionText+'"'
+       subcaptionText = ""
+       subcaptionLine = find_token(lines, "subcaption", i+1, j)
+       if subcaptionLine != -1:
+            subcaptionText = lines[subcaptionLine][11:]
+           if subcaptionText != "":
+               subcaptionText = '"'+subcaptionText+'"'
+
        k = find_token(lines, "subfigure", i+1,j)
        if k == -1:
            subcaption = 0
@@ -483,8 +492,23 @@ def change_infoinset(lines):
         i = find_token(lines, "\\begin_inset Info", i)
         if i == -1:
             break
-        lines[i:i+1] = ["\\begin_inset Note", "collapsed true", "",
-                        "\layout Standard", ""]
+        txt = string.lstrip(lines[i][18:])
+        new = ["\\begin_inset Note", "collapsed true", ""]
+        j = find_token(lines, "\\end_inset", i)
+        if j == -1:
+            break
+
+        note_lines = lines[i+1:j]
+        if len(txt) > 0:
+            note_lines = [txt]+note_lines
+
+        for line in note_lines:
+            new = new + ["\layout Standard", ""]
+            tmp = string.split(line, '\\')
+            new = new + [tmp[0]]
+            for x in tmp[1:]:
+                new = new + ["\\backslash ", x]
+        lines[i:j] = new
         i = i+5
 
 def change_preamble(lines):