diff --git a/development/FORMAT b/development/FORMAT index c098a3cbbd..0954ed053c 100644 --- a/development/FORMAT +++ b/development/FORMAT @@ -320,6 +320,11 @@ Paragraph text. ERT: "\ " could be converted to InsetSpace \ ERT: "\," could be converted to InsetSpace \, +2003-04-24 André Pönitz + + * Added eqref support: + \begin_inset LatexCommand \eqref{label} + 2003-03-12 John Levon * Added \\end_header to signify the end of the header in a diff --git a/lib/lyx2lyx/ChangeLog b/lib/lyx2lyx/ChangeLog index ee8a6d520f..7d541da23d 100644 --- a/lib/lyx2lyx/ChangeLog +++ b/lib/lyx2lyx/ChangeLog @@ -1,3 +1,10 @@ +2005-02-20 Georg Baum + + * 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 * lyx_1_4.py (convert_table_valignment_middle, diff --git a/lib/lyx2lyx/lyx_1_4.py b/lib/lyx2lyx/lyx_1_4.py index 29330d8abb..f459ef43ff 100644 --- a/lib/lyx2lyx/lyx_1_4.py +++ b/lib/lyx2lyx/lyx_1_4.py @@ -69,6 +69,41 @@ def revert_spaces(file): file.body[i] = replace(file.body[i],"\\InsetSpace ~", "\\SpecialChar ~") +## +# 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 # @@ -1834,7 +1869,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]]]