]> git.lyx.org Git - features.git/commitdiff
InsetInfo: lyx2lyx support
authorBo Peng <bpeng@lyx.org>
Thu, 11 Oct 2007 14:56:34 +0000 (14:56 +0000)
committerBo Peng <bpeng@lyx.org>
Thu, 11 Oct 2007 14:56:34 +0000 (14:56 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@20905 a592a061-630c-0410-9148-cb99ea01b6c8

development/FORMAT
lib/lyx2lyx/LyX.py
lib/lyx2lyx/lyx_1_6.py
src/Buffer.cpp

index 27515d22d11b6a9abbd431eec53c64ca3f59abc2..c4bf1b7ef974ebc2bd73c23baedf6d768040a45c 100644 (file)
@@ -1,6 +1,9 @@
 LyX file-format changes
 -----------------------
 
+2007-10-11 Bo Peng <ben.bob@gmail.com>
+       * Format incremented to 293: Add InsetInfo.
+
 2007-10-09 Uwe Stöhr Uwe Stöhr <uwestoehr@web.de>
        * Format incremented to 292: Support for Japanese without
          using CJK and inputenc. (japanese-plain)
index 4ad73b439b87ed3ac9798dbcf63d895547f3ee67..0354ca364e666dccc01bd4b73f7593a97a81dbf8 100644 (file)
@@ -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():
index 9f7e9408f060c2fff13e1947b44cd531d50285d4..24abefb90718f4d8381502dea9e7b6b4b4807cb2 100644 (file)
@@ -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]],
index 9c5d3b77082e3501e9e3893ffb8057f02b92af6a..3037e5864a9d5e63a8ace1d7ec0f2a383a2c4e2b 100644 (file)
@@ -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