From 7535cabd6024041a0404b37362be22c848ff2607 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jos=C3=A9=20Matox?= Date: Wed, 19 Mar 2008 09:40:24 +0000 Subject: [PATCH] Normalize the begining of Tabular insets (+ cosmetics: remove spaces at the end of lines) git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@23823 a592a061-630c-0410-9148-cb99ea01b6c8 --- lib/lyx2lyx/lyx_1_6.py | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/lib/lyx2lyx/lyx_1_6.py b/lib/lyx2lyx/lyx_1_6.py index a30b59f9e8..ef269added 100644 --- a/lib/lyx2lyx/lyx_1_6.py +++ b/lib/lyx2lyx/lyx_1_6.py @@ -33,7 +33,7 @@ def find_end_of_inset(lines, i): def wrap_into_ert(string, src, dst): " Wrap a something into an ERT" - return string.replace(src, '\n\\begin_inset ERT\nstatus collapsed\n\\begin_layout Standard\n' + return string.replace(src, '\n\\begin_inset ERT\nstatus collapsed\n\\begin_layout Standard\n' + dst + '\n\\end_layout\n\\end_inset\n') def add_to_preamble(document, text): @@ -76,9 +76,13 @@ def convert_tablines(document): while True: i = find_token(document.body, "\\begin_inset Tabular", i) if i == -1: + # LyX 1.3 inserted an extra space between \begin_inset + # and Tabular so let us try if this is the case and fix it. i = find_token(document.body, "\\begin_inset Tabular", i) if i == -1: return + else: + document.body[i] = "\\begin_inset Tabular" j = find_end_of_inset(document.body, i + 1) if j == -1: document.warning("Malformed LyX document: Could not find end of tabular.") @@ -288,7 +292,7 @@ def axe_show_label(document): document.warning("Malformed LyX document: show_label neither false nor true.") else: document.warning("Malformed LyX document: show_label missing in CharStyle.") - + i += 1 @@ -418,8 +422,8 @@ def remove_inzip_options(document): def convert_inset_command(document): """ Convert: - \begin_inset LatexCommand cmd - to + \begin_inset LatexCommand cmd + to \begin_inset CommandInset InsetType LatexCommand cmd """ @@ -457,8 +461,8 @@ def revert_inset_command(document): Convert: \begin_inset CommandInset InsetType LatexCommand cmd - to - \begin_inset LatexCommand cmd + to + \begin_inset LatexCommand cmd Some insets may end up being converted to insets earlier versions of LyX will not be able to recognize. Not sure what to do about that. """ @@ -516,7 +520,7 @@ def revert_wrapfig_options(document): def convert_latexcommand_index(document): "Convert from LatexCommand form to collapsable form." - i = 0 + i = 0 while True: i = find_token(document.body, "\\begin_inset CommandInset index", i) if i == -1: @@ -662,7 +666,7 @@ def revert_japanese_encoding(document): document.header[j] = "\\inputencoding JIS" k = 0 k = find_token(document.header, "\\inputencoding SJIS-plain", 0) - if k != -1: # convert to UTF8 since there is currently no SJIS encoding + if k != -1: # convert to UTF8 since there is currently no SJIS encoding document.header[k] = "\\inputencoding UTF8" @@ -763,7 +767,7 @@ def convert_url(document): i = k continue newstuff = ["\\begin_inset Flex URL", - "status collapsed", "", + "status collapsed", "", "\\begin_layout Standard", "", target, @@ -840,7 +844,7 @@ def convert_include(document): cmd = m.group(1) fn = m.group(2) opt = m.group(3) - insertion = ["\\begin_inset CommandInset include", + insertion = ["\\begin_inset CommandInset include", "LatexCommand " + cmd, previewline, "filename \"" + fn + "\""] newlines = 2 -- 2.39.2