mirror of
https://git.lyx.org/repos/lyx.git
synced 2025-01-03 08:28:25 +00:00
Fix reversion of IEEEtran layout documents.
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@34789 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
20b7726ab3
commit
7fd69c63a7
@ -154,6 +154,7 @@ def lyx2latex(document, lines):
|
|||||||
# clean up multiline stuff
|
# clean up multiline stuff
|
||||||
content = ""
|
content = ""
|
||||||
ert_end = 0
|
ert_end = 0
|
||||||
|
note_end = 0
|
||||||
|
|
||||||
for curline in range(len(lines)):
|
for curline in range(len(lines)):
|
||||||
line = lines[curline]
|
line = lines[curline]
|
||||||
@ -181,6 +182,10 @@ def lyx2latex(document, lines):
|
|||||||
line = "''"
|
line = "''"
|
||||||
else:
|
else:
|
||||||
line = "'"
|
line = "'"
|
||||||
|
elif line.startswith("\\begin_inset Note Note"):
|
||||||
|
# We want to skip LyX notes, so remember where the inset ends
|
||||||
|
note_end = find_end_of_inset(lines, curline + 1)
|
||||||
|
continue
|
||||||
elif line.isspace() or \
|
elif line.isspace() or \
|
||||||
line.startswith("\\begin_layout") or \
|
line.startswith("\\begin_layout") or \
|
||||||
line.startswith("\\end_layout") or \
|
line.startswith("\\end_layout") or \
|
||||||
@ -192,6 +197,10 @@ def lyx2latex(document, lines):
|
|||||||
#skip all that stuff
|
#skip all that stuff
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
# Skip LyX notes
|
||||||
|
if note_end >= curline:
|
||||||
|
continue
|
||||||
|
|
||||||
# this needs to be added to the preamble because of cases like
|
# this needs to be added to the preamble because of cases like
|
||||||
# \textmu, \textbackslash, etc.
|
# \textmu, \textbackslash, etc.
|
||||||
add_to_preamble(document, ['% added by lyx2lyx for converted index entries',
|
add_to_preamble(document, ['% added by lyx2lyx for converted index entries',
|
||||||
@ -1861,53 +1870,35 @@ def revert_IEEEtran(document):
|
|||||||
|
|
||||||
revert_flex_inset(document, "IEEE membership", "\\IEEEmembership", 0)
|
revert_flex_inset(document, "IEEE membership", "\\IEEEmembership", 0)
|
||||||
revert_flex_inset(document, "Lowercase", "\\MakeLowercase", 0)
|
revert_flex_inset(document, "Lowercase", "\\MakeLowercase", 0)
|
||||||
revert_layout_command(document, "Special Paper Notice", "\\IEEEspecialpapernotice", 0)
|
|
||||||
revert_layout_command(document, "After Title Text", "\\IEEEaftertitletext", 0)
|
layouts = ("Special Paper Notice", "After Title Text", "Publication ID",
|
||||||
revert_layout_command(document, "Page headings", "\\markboth", 0)
|
"Page headings", "Biography without photo")
|
||||||
revert_layout_command(document, "Publication ID", "\\IEEEpubid", 0)
|
|
||||||
note = '\\begin_layout Standard\n' \
|
latexcmd = {"Special Paper Notice": "\\IEEEspecialpapernotice",
|
||||||
+ '\\begin_inset Note Note\n' \
|
"After Title Text": "\\IEEEaftertitletext",
|
||||||
+ 'status open\n\n' \
|
"Publication ID": "\\IEEEpubid"}
|
||||||
+ '\\begin_layout Plain Layout\n\n' \
|
|
||||||
+ '\series bold\n' \
|
obsoletedby = {"Page headings": "MarkBoth",
|
||||||
+ 'IMPORTANT NOTICE!!!:\n' \
|
"Biography without photo": "BiographyNoPhoto"}
|
||||||
+ '\\series default\n' \
|
|
||||||
+ ' \n' \
|
for layout in layouts:
|
||||||
+ '\\color red\n' \
|
i = 0
|
||||||
+ 'This document was created from a newer LyX version.\n' \
|
while True:
|
||||||
+ ' To be able to view/export it with LyX 1.6.x or earlier, the title and author\n' \
|
i = find_token(document.body, '\\begin_layout ' + layout, i)
|
||||||
+ ' must be specified by using TeX code.\n' \
|
if i == -1:
|
||||||
+ ' Do not use then the standard title and author environment!\n' \
|
break
|
||||||
+ '\\end_layout\n\n' \
|
j = find_end_of(document.body, i, '\\begin_layout', '\\end_layout')
|
||||||
+ '\\end_inset\n\n\n' \
|
if j == -1:
|
||||||
+ '\\end_layout\n\n'
|
document.warning("Malformed LyX document: Can't find end of " + layout + " layout.")
|
||||||
# insert a note that title and author must be given in TeX code
|
i += 1
|
||||||
document.body.insert(0, note)
|
continue
|
||||||
# we need to revert title and author to TeX code to set \maketitle correctly
|
if layout in obsoletedby:
|
||||||
revert_layout_command(document, "Title", "\\title", 0)
|
document.body[i] = "\\begin_layout " + obsoletedby[layout]
|
||||||
revert_layout_command(document, "Author", "\\author", 0)
|
i = j
|
||||||
# write \markboth code to the preamble
|
else:
|
||||||
insert_to_preamble(0, document,
|
content = lyx2latex(document, document.body[i:j+1])
|
||||||
'% Commands inserted by lyx2lyx\n'
|
add_to_preamble(document, [latexcmd[layout] + "{" + content + "}"])
|
||||||
+ '% protect \\markboth against an old bug reintroduced in babel >= 3.8g\n'
|
del document.body[i:j+1]
|
||||||
+ '\\let\\oldforeign@language\\foreign@language\n'
|
|
||||||
+ '\\DeclareRobustCommand{\\foreign@language}[1]{%\n'
|
|
||||||
+ ' \\lowercase{\\oldforeign@language{#1}}}\n')
|
|
||||||
# set maketitle
|
|
||||||
y = find_token(document.body, '\\begin_layout Abstract', 0)
|
|
||||||
if y == -1:
|
|
||||||
document.warning("Malformed LyX document: Can't find abstract of IEEEtran paper.")
|
|
||||||
return
|
|
||||||
maketitle = ['\\begin_layout Standard\n', \
|
|
||||||
'\\begin_inset ERT\n', \
|
|
||||||
'status collapsed\n', \
|
|
||||||
'\\begin_layout Plain Layout\n', \
|
|
||||||
'\\backslash\n', \
|
|
||||||
'maketitle \n', \
|
|
||||||
'\\end_layout\n', \
|
|
||||||
'\\end_inset\n', \
|
|
||||||
'\\end_layout\n']
|
|
||||||
document.body[y:y] = maketitle
|
|
||||||
|
|
||||||
|
|
||||||
##
|
##
|
||||||
|
Loading…
Reference in New Issue
Block a user