X-Git-Url: https://git.lyx.org/gitweb/?a=blobdiff_plain;f=lib%2Flyx2lyx%2Flyx_0_10.py;h=dc2d09e868962ec13a0451e7b0208f7b86af9ec9;hb=9da74fe2078e24e1e7891784ecbfe33ff77e7f85;hp=3bf4d33a76a5fdc4ecb1b3f1c849781e8bc9eaba;hpb=088bcef87b57fdbd00490c4ef9c9c0066d2c6eb5;p=lyx.git diff --git a/lib/lyx2lyx/lyx_0_10.py b/lib/lyx2lyx/lyx_0_10.py index 3bf4d33a76..dc2d09e868 100644 --- a/lib/lyx2lyx/lyx_0_10.py +++ b/lib/lyx2lyx/lyx_0_10.py @@ -14,12 +14,12 @@ # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -""" Convert files generated by lyx 0.10""" +""" Convert files to the file format generated by lyx 0.10""" def regularise_header(document): - " Place tokens in their separate line. " + " Put each entry in header into a separate line. " i = 0 while i < len(document.header): line = document.header[i] @@ -31,8 +31,9 @@ def regularise_header(document): def find_next_space(line, j): - """ Return position of next space, starting from position k, if - not existing return last position in line.""" + """ Return position of next space or backslash, which one comes + first, starting from position k, if not existing return last + position in line.""" l = line.find(' ', j) if l == -1: l = len(line) @@ -46,6 +47,20 @@ def find_next_space(line, j): def regularise_body(document): + """ Place tokens starting with a backslash into a separate line. """ + + getline_tokens = ["added_space_bottom", "added_space_top", + "align", "layout", "fill_bottom", "fill_top", + "labelwidthstring", "pagebreak_top", + "pagebreak_bottom", "noindent"] + + noargs_tokens = ["backslash", "begin_deeper", "end_deeper", + "end_float", "end_inset", "hfill", "newline", + "protected_separator"] + + onearg_tokens = ["bar", "begin_float", "family", "latex", "shape", + "size", "series", "cursor"] + i = 0 while i < len(document.body): line = document.body[i] @@ -66,18 +81,18 @@ def regularise_body(document): # These tokens take the rest of the line token = line[j+1:k] - if token in ["added_space_bottom", "added_space_top", "align", "layout", "fill_bottom", "fill_top", "labelwidthstring", "pagebreak_top", "pagebreak_bottom", "noindent"]: + if token in getline_tokens: tmp += [line[j:]] break # These tokens take no arguments - if token in ["backslash", "begin_deeper", "end_deeper", "end_float", "end_inset", "hfill", "newline", "protected_separator"]: + if token in noargs_tokens: tmp += [line[j:k]] j = k continue # These tokens take one argument - if token in ["bar", "begin_float", "family", "latex", "shape", "size", "series", "cursor"]: + if token in onearg_tokens: k = find_next_space(line, k + 1) tmp += [line[j:k]] j = k @@ -103,6 +118,7 @@ def regularise_body(document): j = l continue + document.warning("unkown inset %s" % line) assert(False) # We are inside a latex inset, pass the text verbatim @@ -113,10 +129,10 @@ def regularise_body(document): i += len(tmp) +supported_versions = ["0.10.%d" % i for i in range(8)] + ["0.10"] convert = [[210, [regularise_header, regularise_body]]] revert = [] if __name__ == "__main__": pass -