mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-22 21:21:32 +00:00
Fix issue with convert_macro_global reported by Enrico.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@27058 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
b940dc2db7
commit
87f291c706
@ -252,6 +252,8 @@ def latex2lyx(data):
|
|||||||
converting LaTeX constructs into LyX constructs. Returns a list of
|
converting LaTeX constructs into LyX constructs. Returns a list of
|
||||||
lines, suitable for insertion into document.body.'''
|
lines, suitable for insertion into document.body.'''
|
||||||
|
|
||||||
|
if not data:
|
||||||
|
return []
|
||||||
retval = []
|
retval = []
|
||||||
|
|
||||||
# Convert LaTeX to Unicode
|
# Convert LaTeX to Unicode
|
||||||
@ -1541,15 +1543,37 @@ def convert_macro_global(document):
|
|||||||
# math macros are nowadays already defined \global, so that an additional
|
# math macros are nowadays already defined \global, so that an additional
|
||||||
# \global would make the document uncompilable, see
|
# \global would make the document uncompilable, see
|
||||||
# http://bugzilla.lyx.org/show_bug.cgi?id=5371
|
# http://bugzilla.lyx.org/show_bug.cgi?id=5371
|
||||||
|
# We're looking for something like this:
|
||||||
|
# \begin_inset ERT
|
||||||
|
# status collapsed
|
||||||
|
#
|
||||||
|
# \begin_layout Plain Layout
|
||||||
|
#
|
||||||
|
#
|
||||||
|
# \backslash
|
||||||
|
# global
|
||||||
|
# \end_layout
|
||||||
|
#
|
||||||
|
# \end_inset
|
||||||
|
#
|
||||||
|
#
|
||||||
|
# \begin_inset FormulaMacro
|
||||||
|
# \renewcommand{\foo}{123}
|
||||||
|
# \end_inset
|
||||||
i = 0
|
i = 0
|
||||||
while True:
|
while True:
|
||||||
i = find_token(document.body, "\\begin_inset FormulaMacro", i)
|
i = find_token(document.body, "\\begin_inset FormulaMacro", i)
|
||||||
if i != -1 and i > 13:
|
if i != -1:
|
||||||
|
return
|
||||||
|
# if i <= 13, then there isn't enough room for the ERT
|
||||||
|
if i <= 12:
|
||||||
|
i += 1
|
||||||
|
continue
|
||||||
if document.body[i-6] == "global":
|
if document.body[i-6] == "global":
|
||||||
del document.body[i-13 : i]
|
del document.body[i-13 : i]
|
||||||
else:
|
|
||||||
return
|
|
||||||
i = i - 12
|
i = i - 12
|
||||||
|
else:
|
||||||
|
i += 1
|
||||||
|
|
||||||
|
|
||||||
def revert_macro_optional_params(document):
|
def revert_macro_optional_params(document):
|
||||||
@ -2109,13 +2133,13 @@ def convert_subfig(document):
|
|||||||
continue
|
continue
|
||||||
l = find_token(document.body, '\tsubcaptionText', i, endInset)
|
l = find_token(document.body, '\tsubcaptionText', i, endInset)
|
||||||
if l == -1:
|
if l == -1:
|
||||||
document.warning("Malformed lyx document: Can't find subcaptionText!")
|
caption = ""
|
||||||
i = endInset
|
else:
|
||||||
continue
|
|
||||||
caption = document.body[l][16:].strip('"')
|
caption = document.body[l][16:].strip('"')
|
||||||
del document.body[l]
|
del document.body[l]
|
||||||
|
addedLine = -1
|
||||||
del document.body[k]
|
del document.body[k]
|
||||||
addedLines = -2
|
addedLines -= 1
|
||||||
subst = ['\\begin_inset Float figure', 'wide false', 'sideways false',
|
subst = ['\\begin_inset Float figure', 'wide false', 'sideways false',
|
||||||
'status open', '', '\\begin_layout Plain Layout', '\\begin_inset Caption',
|
'status open', '', '\\begin_layout Plain Layout', '\\begin_inset Caption',
|
||||||
'', '\\begin_layout Plain Layout'] + latex2lyx(caption) + \
|
'', '\\begin_layout Plain Layout'] + latex2lyx(caption) + \
|
||||||
|
Loading…
Reference in New Issue
Block a user