From f119b8f4de8d9f4f3585a797c453977b2b9594a9 Mon Sep 17 00:00:00 2001 From: Richard Heck Date: Sun, 13 Jul 2008 19:24:09 +0000 Subject: [PATCH] Fix bug 4927 again. The latex2ert routine was geared too much toward IndexInset, where the initial backslash in a LaTeX command is escaped, which it is not in a subfigure. Note that we are NOT converting labels here into InsetLabel objects. That would not be all that hard to do. I've put a comment in about how we could do that. It would be fairly easy to do. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@25581 a592a061-630c-0410-9148-cb99ea01b6c8 --- lib/lyx2lyx/lyx_1_6.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/lib/lyx2lyx/lyx_1_6.py b/lib/lyx2lyx/lyx_1_6.py index 21c3c26d26..07f69236a8 100644 --- a/lib/lyx2lyx/lyx_1_6.py +++ b/lib/lyx2lyx/lyx_1_6.py @@ -207,7 +207,11 @@ def latex2ert(line): retval = "" ## FIXME Escaped \ ?? - labelre = re.compile(r'(.*?)\\(\\(?:[a-zA-Z]+|.))(.*)') + # This regex looks for a LaTeX command---i.e., something of the form + # "\alPhaStuFF", or "\X", where X is any character---where the command + # may also be preceded by an additional backslash, which is how it would + # appear (e.g.) in an InsetIndex. + labelre = re.compile(r'(.*?)\\?(\\(?:[a-zA-Z]+|.))(.*)') m = labelre.match(line) while m != None: @@ -221,6 +225,10 @@ def latex2ert(line): break cmd += arg end = rest + # If we wanted to put labels into an InsetLabel, for example, then we + # would just need to test here for cmd == "label" and then take some + # appropriate action, i.e., to use arg to get the content and then + # wrap it appropriately. cmd = put_cmd_in_ert(cmd) retval += "\n" + cmd + "\n" line = end @@ -241,7 +249,7 @@ def latex2lyx(data): # Commands of this sort need to be checked to make sure they are # followed by a non-alpha character, lest we replace too much. hardone = re.compile(r'^\\\\[a-zA-Z]+$') - + for rep in reps: if hardone.match(rep[0]): pos = 0 -- 2.39.2