From ce0186b1cdb3506f53dd0a2489fae1b33caaad84 Mon Sep 17 00:00:00 2001 From: jamatos Date: Mon, 23 Jul 2007 17:06:32 +0000 Subject: [PATCH] Another take at bug 4049 git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@19172 a592a061-630c-0410-9148-cb99ea01b6c8 --- lib/lyx2lyx/lyx_1_5.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/lib/lyx2lyx/lyx_1_5.py b/lib/lyx2lyx/lyx_1_5.py index 6c4c806685..77c80b242e 100644 --- a/lib/lyx2lyx/lyx_1_5.py +++ b/lib/lyx2lyx/lyx_1_5.py @@ -362,7 +362,7 @@ def revert_unicode_line(document, i, insets, spec_chars, replacement_character = math_outro='$\n\\end_inset' mod_line = u'' - if i and document.body[i - 1][:1] != '\\': + if i and not is_inset_line(document, i-1): last_char = document.body[i - 1][-1:] else: last_char = '' @@ -1150,6 +1150,14 @@ def convert_accent(document): i += 3 +def is_inset_line(document, i): + """ Line i of body has an inset """ + if document.body[i][:1] == '\\': + return True + last_tokens = "".join(document.body[i].split()[-2:]) + return last_tokens.find('\\') != -1 + + def revert_accent(document): inverse_accent_map = {} for k in accent_map: @@ -1168,7 +1176,7 @@ def revert_accent(document): for i in range(len(document.body) - 1): if document.body[i] == '' or document.body[i+1] == '' or document.body[i][-1] == ' ': continue - if (document.body[i+1][0] in inverse_accent_map and document.body[i][:1] != '\\'): + if (document.body[i+1][0] in inverse_accent_map and not is_inset_line(document, i)): # the last character of this line and the first of the next line # form probably a surrogate pair, inline insets are excluded (second part of the test) while (len(document.body[i+1]) > 0 and document.body[i+1][0] != ' '): -- 2.11.4.GIT