From 353aacab4b3be09430d0c84508b0b7f58dbb3b7a Mon Sep 17 00:00:00 2001 From: Bo Peng Date: Thu, 11 Oct 2007 14:56:34 +0000 Subject: [PATCH] InsetInfo: lyx2lyx support git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@20905 a592a061-630c-0410-9148-cb99ea01b6c8 --- development/FORMAT | 3 +++ lib/lyx2lyx/LyX.py | 2 +- lib/lyx2lyx/lyx_1_6.py | 31 +++++++++++++++++++++++++++++-- src/Buffer.cpp | 2 +- 4 files changed, 34 insertions(+), 4 deletions(-) diff --git a/development/FORMAT b/development/FORMAT index 27515d22d1..c4bf1b7ef9 100644 --- a/development/FORMAT +++ b/development/FORMAT @@ -1,6 +1,9 @@ LyX file-format changes ----------------------- +2007-10-11 Bo Peng + * Format incremented to 293: Add InsetInfo. + 2007-10-09 Uwe Stöhr Uwe Stöhr * Format incremented to 292: Support for Japanese without using CJK and inputenc. (japanese-plain) diff --git a/lib/lyx2lyx/LyX.py b/lib/lyx2lyx/LyX.py index 4ad73b439b..0354ca364e 100644 --- a/lib/lyx2lyx/LyX.py +++ b/lib/lyx2lyx/LyX.py @@ -80,7 +80,7 @@ format_relation = [("0_06", [200], minor_versions("0.6" , 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" , 1)), - ("1_6", range(277,293), minor_versions("1.6" , 0))] # Uwe Stöhr, Japanese + ("1_6", range(277,294), minor_versions("1.6" , 0))] def formats_list(): diff --git a/lib/lyx2lyx/lyx_1_6.py b/lib/lyx2lyx/lyx_1_6.py index 9f7e9408f0..24abefb907 100644 --- a/lib/lyx2lyx/lyx_1_6.py +++ b/lib/lyx2lyx/lyx_1_6.py @@ -455,6 +455,31 @@ def revert_japanese_encoding(document): document.header[k] = "\\inputencoding UTF8" +def revert_inset_info(document): + 'Replace info inset with its content' + i = 0 + while 1: + i = find_token(document.body, '\\begin_inset Info', i) + if i == -1: + return + j = find_end_of_inset(document.body, i + 1) + if j == -1: + # should not happen + document.warning("Malformed LyX document: Could not find end of Info inset.") + type = 'unknown' + arg = '' + for k in range(i, j+1): + if document.body[k].startswith("arg"): + arg = document.body[k][3:].strip().strip('"') + if document.body[k].startswith("type"): + type = document.body[k][4:].strip().strip('"') + # I think there is a newline after \\end_inset, which should be removed. + if document.body[j + 1].strip() == "": + document.body[i : (j + 2)] = [type + ':' + arg] + else: + document.body[i : (j + 1)] = [type + ':' + arg] + + ## # Conversion hub # @@ -475,10 +500,12 @@ convert = [[277, [fix_wrong_tables]], [289, [convert_latexcommand_index]], [290, []], [291, []], - [292, []] + [292, []], + [293, []] ] -revert = [[291, [revert_japanese, revert_japanese_encoding]], +revert = [[292, [revert_inset_info]], + [291, [revert_japanese, revert_japanese_encoding]], [290, [revert_vietnamese]], [289, [revert_wraptable]], [288, [revert_latexcommand_index]], diff --git a/src/Buffer.cpp b/src/Buffer.cpp index 9c5d3b7708..3037e5864a 100644 --- a/src/Buffer.cpp +++ b/src/Buffer.cpp @@ -154,7 +154,7 @@ namespace fs = boost::filesystem; namespace { -int const LYX_FORMAT = 292; //Uwe Stöhr, Japanese +int const LYX_FORMAT = 293; } // namespace anon