From 0b115f57dbd54d7691a36a5e74e34ba006c6bacc Mon Sep 17 00:00:00 2001 From: =?utf8?q?Uwe=20St=C3=B6hr?= Date: Thu, 7 Aug 2008 22:37:27 +0000 Subject: [PATCH] lyx2lyx/lyx_1_6.py: fix bug 5137 and another bug git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@26094 a592a061-630c-0410-9148-cb99ea01b6c8 --- lib/lyx2lyx/lyx_1_6.py | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/lib/lyx2lyx/lyx_1_6.py b/lib/lyx2lyx/lyx_1_6.py index ad8365038a..fa99394da9 100644 --- a/lib/lyx2lyx/lyx_1_6.py +++ b/lib/lyx2lyx/lyx_1_6.py @@ -308,7 +308,7 @@ def latex2lyx(data): return retval -def lyx2latex(lines): +def lyx2latex(document, lines): 'Convert some LyX stuff into corresponding LaTeX stuff, as best we can.' # clean up multiline stuff content = "" @@ -352,12 +352,23 @@ def lyx2latex(lines): #skip all that stuff continue + # this needs to be added to the preamble because of cases like + # \textmu, \textbackslash, etc. + add_to_preamble(document, ['% added by lyx2lyx for converted index entries\n' + + '\\@ifundefined{textmu}\n' + + ' {\\usepackage{textcomp}}{}']) # a lossless reversion is not possible # try at least to handle some common insets and settings - # do not replace inside ERTs if ert_end >= curline: line = line.replace(r'\backslash', r'\\') else: + line = line.replace('&', '\\&{}') + line = line.replace('#', '\\#{}') + line = line.replace('^', '\\^{}') + line = line.replace('%', '\\%{}') + line = line.replace('_', '\\_{}') + line = line.replace('$', '\\${}') + # Do the LyX text --> LaTeX conversion for rep in reps: line = line.replace(rep[1], rep[0] + "{}") @@ -1083,7 +1094,7 @@ def revert_latexcommand_index(document): if j == -1: return - content = lyx2latex(document.body[i:j]) + content = lyx2latex(document, document.body[i:j]) # escape quotes content = content.replace('"', r'\"') document.body[i:j] = ["\\begin_inset CommandInset index", "LatexCommand index", -- 2.39.2