Juergen Spitzmueller wrote:
> This has to be \\space{} of course, not \\normal{}. I fixed this, but
> nevertheless evertion of spaces to 221 fails. What's missing?

I think I got it (trial and error). Please have a look (it works for all cases 
I could imagine).

Jürgen
Index: LyX.py
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/lib/lyx2lyx/LyX.py,v
retrieving revision 1.24
diff -u -r1.24 LyX.py
--- LyX.py	19 Sep 2005 11:31:26 -0000	1.24
+++ LyX.py	27 Sep 2005 13:01:54 -0000
@@ -46,7 +46,7 @@
                    ("1_1_6fix3", [218], ["1.1.6fix3","1.1.6fix4","1.1"]),
                    ("1_2", [220], ["1.2.0","1.2.1","1.2.3","1.2.4","1.2"]),
                    ("1_3", [221], ["1.3.0","1.3.1","1.3.2","1.3.3","1.3.4","1.3.5","1.3.6","1.3"]),
-                   ("1_4", range(222,244), ["1.4.0cvs","1.4"])]
+                   ("1_4", range(222,245), ["1.4.0cvs","1.4"])]
 
 
 def formats_list():
Index: lyx_1_4.py
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/lib/lyx2lyx/lyx_1_4.py,v
retrieving revision 1.52
diff -u -r1.52 lyx_1_4.py
--- lyx_1_4.py	20 Sep 2005 12:47:45 -0000	1.52
+++ lyx_1_4.py	27 Sep 2005 13:01:58 -0000
@@ -65,8 +65,38 @@
 
 
 def revert_spaces(file):
+    regexp = re.compile(r'(.*)(\\InsetSpace\s+)(\S+)')
+    i = 0
+    while 1:
+        i = find_re(file.body, regexp, i)
+        if i == -1:
+            break
+        space = regexp.match(file.body[i]).group(3)
+	prepend = regexp.match(file.body[i]).group(1)
+        if space == '~':
+            file.body[i] = regexp.sub(prepend + '\\SpecialChar ~', file.body[i])
+            i = i + 1
+        else:
+            file.body[i] = regexp.sub(prepend, file.body[i])
+            file.body[i+1:i+1] = ''
+	    if space == "\\space":
+		space = "\\ "
+            i = insert_ert(file.body, i+1, 'Collapsed', space, file.format - 1)
+
+##
+# \InsetSpace \, -> \InsetSpace \thinspace{}
+# \InsetSpace \space -> \InsetSpace \space{}
+#
+def rename_spaces(file):
+    for i in range(len(file.body)):
+        file.body[i] = replace(file.body[i],"\\InsetSpace \\space","\\InsetSpace \\space{}")
+	file.body[i] = replace(file.body[i],"\\InsetSpace \,","\\InsetSpace \\thinspace{}")
+
+
+def revert_space_names(file):
     for i in range(len(file.body)):
-        file.body[i] = replace(file.body[i],"\\InsetSpace ~", "\\SpecialChar ~")
+        file.body[i] = replace(file.body[i],"\\InsetSpace \\space{}","\\InsetSpace \\space")
+	file.body[i] = replace(file.body[i],"\\InsetSpace \\thinspace{}","\\InsetSpace \\,")
 
 
 ##
@@ -2255,9 +2285,11 @@
            [240, [convert_output_changes]],
            [241, [convert_ert_paragraphs]],
            [242, [convert_french]],
-           [243, [remove_paperpackage]]]
+           [243, [remove_paperpackage]],
+	   [244, [rename_spaces]]]
 
-revert =  [[242, []],
+revert =  [[243, [revert_space_names]],
+	   [242, []],
            [241, []],
            [240, [revert_ert_paragraphs]],
            [239, [revert_output_changes]],

Reply via email to