Am Freitag, 18. Februar 2005 12:17 schrieb Paul Smith:
> Dear All
> 
> I am sending you two examples showing some problems with tex2lyx.
> Please, be aware that I am not a subscriber of your list.

The file subequations.tex shows that André forgot to increase the file 
format when he added support for eqref to insetref. The attached patch 
adds the missing conversion in lyx2lyx.
OK to apply?


Georg
diff -p -r -U 3 -X excl.tmp lyx-1.4-clean/development/FORMAT lyx-1.4-cvs/development/FORMAT
--- lyx-1.4-clean/development/FORMAT	2005-02-03 20:12:13.000000000 +0100
+++ lyx-1.4-cvs/development/FORMAT	2005-02-20 16:13:33.000000000 +0100
@@ -320,6 +320,11 @@ Paragraph text.
 		ERT: "\ " could be converted to InsetSpace \<space>
 		ERT: "\," could be converted to InsetSpace \,
 
+2003-04-24  André Pönitz <[EMAIL PROTECTED]>
+
+	* Added eqref support:
+	\begin_inset LatexCommand \eqref{label}
+
 2003-03-12  John Levon  <[EMAIL PROTECTED]>
 
 	* Added \\end_header to signify the end of the header in a
diff -p -r -U 3 -X excl.tmp lyx-1.4-clean/lib/lyx2lyx/ChangeLog lyx-1.4-cvs/lib/lyx2lyx/ChangeLog
--- lyx-1.4-clean/lib/lyx2lyx/ChangeLog	2005-02-17 20:41:58.000000000 +0100
+++ lyx-1.4-cvs/lib/lyx2lyx/ChangeLog	2005-02-20 16:17:51.000000000 +0100
@@ -1,3 +1,10 @@
+2005-02-20  Georg Baum  <[EMAIL PROTECTED]>
+
+	* lyx_1_4.py (lyx_support_escape): new
+	* lyx_1_4.py (revert_eqref): new, convert
+	'\begin_inset LatexCommand \eqref{label}' to ERT
+	* lyx_1_4.py (revert): call revert_eqref in step 223 -> 221
+
 2005-02-17  Georg Baum  <[EMAIL PROTECTED]>
 
 	* lyx_1_4.py (convert_table_valignment_middle,
diff -p -r -U 3 -X excl.tmp lyx-1.4-clean/lib/lyx2lyx/lyx_1_4.py lyx-1.4-cvs/lib/lyx2lyx/lyx_1_4.py
--- lyx-1.4-clean/lib/lyx2lyx/lyx_1_4.py	2005-02-17 20:41:58.000000000 +0100
+++ lyx-1.4-cvs/lib/lyx2lyx/lyx_1_4.py	2005-02-20 16:23:27.000000000 +0100
@@ -70,6 +70,41 @@ def revert_spaces(file):
 
 
 ##
+# equivalent to lyx::support::escape()
+#
+def lyx_support_escape(lab):
+    hexdigit = ['0', '1', '2', '3', '4', '5', '6', '7',
+                '8', '9', 'A', 'B', 'C', 'D', 'E', 'F']
+    enc = ""
+    for c in lab:
+        o = ord(c)
+        if o >= 128 or c == '=' or c == '%':
+            enc = enc + '='
+            enc = enc + hexdigit[o >> 4]
+            enc = enc + hexdigit[o & 15]
+        else:
+            enc = enc + c
+    return enc;
+
+
+##
+# \begin_inset LatexCommand \eqref -> ERT
+#
+def revert_eqref(file):
+    regexp = re.compile(r'^\\begin_inset\s+LatexCommand\s+\\eqref')
+    i = 0
+    while 1:
+        i = find_re(file.body, regexp, i)
+        if i == -1:
+            break
+        eqref = lyx_support_escape(regexp.sub("", file.body[i]))
+        file.body[i:i+1] = ["\\begin_inset ERT", "status Collapsed", "",
+                            "\\layout Standard", "", "\\backslash ",
+                            "eqref" + eqref]
+        i = i + 7
+
+
+##
 # BibTeX changes
 #
 def convert_bibtex(file):
@@ -1834,7 +1887,7 @@ revert =  [[240, [revert_ert_paragraphs]
            [225, [revert_note]],
            [224, [rm_end_layout, begin_layout2layout, revert_end_document,
                   revert_valignment_middle, convert_vspace, convert_frameless_box]],
-           [223, [revert_external_2, revert_comment]],
+           [223, [revert_external_2, revert_comment, revert_eqref]],
            [221, [rm_end_header, revert_spaces, revert_bibtex,
                   rm_tracking_changes, rm_body_changes]]]
 

Reply via email to