mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-22 21:21:32 +00:00
Simplify some lyx2lyx code.
Also, if the local layout we are removing is all there was, then we can remove the entire block.
This commit is contained in:
parent
6915fc7de8
commit
7a584f71bd
@ -200,47 +200,48 @@ def revert_beamer_article_styles(document):
|
|||||||
if document.textclass == "scrarticle-beamer":
|
if document.textclass == "scrarticle-beamer":
|
||||||
inclusion = "scrartcl.layout"
|
inclusion = "scrartcl.layout"
|
||||||
|
|
||||||
while True:
|
i = find_token(document.header, "\\begin_local_layout", 0)
|
||||||
i = find_token(document.header, "\\begin_local_layout", 0)
|
if i == -1:
|
||||||
if i == -1:
|
k = find_token(document.header, "\\language", 0)
|
||||||
k = find_token(document.header, "\\language", 0)
|
if k == -1:
|
||||||
if k == -1:
|
# this should not happen
|
||||||
# this should not happen
|
document.warning("Malformed LyX document! No \\language header found!")
|
||||||
document.warning("Malformed LyX document! No \\language header found!")
|
return
|
||||||
break
|
document.header[k-1 : k-1] = ["\\begin_local_layout", "\\end_local_layout"]
|
||||||
document.header[k-1 : k-1] = ["\\begin_local_layout", "\\end_local_layout"]
|
i = k - 1
|
||||||
i = find_token(document.header, "\\begin_local_layout", 0)
|
|
||||||
if i != -1:
|
|
||||||
j = find_end_of(document.header, i, "\\begin_local_layout", "\\end_local_layout")
|
|
||||||
if j == -1:
|
|
||||||
# this should not happen
|
|
||||||
break
|
|
||||||
|
|
||||||
document.header[i+1 : i+1] = ["### Inserted by lyx2lyx (more [scr]article styles) ###",
|
j = find_end_of(document.header, i, "\\begin_local_layout", "\\end_local_layout")
|
||||||
"Input " + inclusion,
|
if j == -1:
|
||||||
"Input beamer.layout",
|
# this should not happen
|
||||||
"Provides geometry 0",
|
document.warning("Malformed LyX document: Can't find end of local layout!")
|
||||||
"Provides hyperref 0",
|
|
||||||
"DefaultFont",
|
|
||||||
" Family Roman",
|
|
||||||
" Series Medium",
|
|
||||||
" Shape Up",
|
|
||||||
" Size Normal",
|
|
||||||
" Color None",
|
|
||||||
"EndFont",
|
|
||||||
"Preamble",
|
|
||||||
" \\usepackage{beamerarticle,pgf}",
|
|
||||||
" % this default might be overridden by plain title style",
|
|
||||||
" \\newcommand\makebeamertitle{\\frame{\\maketitle}}%",
|
|
||||||
" \\AtBeginDocument{",
|
|
||||||
" \\let\\origtableofcontents=\\tableofcontents",
|
|
||||||
" \\def\\tableofcontents{\\@ifnextchar[{\\origtableofcontents}{\\gobbletableofcontents}}",
|
|
||||||
" \\def\\gobbletableofcontents#1{\\origtableofcontents}",
|
|
||||||
" }",
|
|
||||||
"EndPreamble",
|
|
||||||
"### End of insertion by lyx2lyx (more [scr]article styles) ###"]
|
|
||||||
return
|
return
|
||||||
|
|
||||||
|
document.header[i+1 : i+1] = [
|
||||||
|
"### Inserted by lyx2lyx (more [scr]article styles) ###",
|
||||||
|
"Input " + inclusion,
|
||||||
|
"Input beamer.layout",
|
||||||
|
"Provides geometry 0",
|
||||||
|
"Provides hyperref 0",
|
||||||
|
"DefaultFont",
|
||||||
|
" Family Roman",
|
||||||
|
" Series Medium",
|
||||||
|
" Shape Up",
|
||||||
|
" Size Normal",
|
||||||
|
" Color None",
|
||||||
|
"EndFont",
|
||||||
|
"Preamble",
|
||||||
|
" \\usepackage{beamerarticle,pgf}",
|
||||||
|
" % this default might be overridden by plain title style",
|
||||||
|
" \\newcommand\makebeamertitle{\\frame{\\maketitle}}%",
|
||||||
|
" \\AtBeginDocument{",
|
||||||
|
" \\let\\origtableofcontents=\\tableofcontents",
|
||||||
|
" \\def\\tableofcontents{\\@ifnextchar[{\\origtableofcontents}{\\gobbletableofcontents}}",
|
||||||
|
" \\def\\gobbletableofcontents#1{\\origtableofcontents}",
|
||||||
|
" }",
|
||||||
|
"EndPreamble",
|
||||||
|
"### End of insertion by lyx2lyx (more [scr]article styles) ###"
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
def convert_beamer_article_styles(document):
|
def convert_beamer_article_styles(document):
|
||||||
" Remove included (scr)article styles in beamer article "
|
" Remove included (scr)article styles in beamer article "
|
||||||
@ -249,28 +250,30 @@ def convert_beamer_article_styles(document):
|
|||||||
if document.textclass not in beamer_articles:
|
if document.textclass not in beamer_articles:
|
||||||
return
|
return
|
||||||
|
|
||||||
while True:
|
i = find_token(document.header, "\\begin_local_layout", 0)
|
||||||
i = find_token(document.header, "\\begin_local_layout", 0)
|
if i == -1:
|
||||||
if i == -1:
|
return
|
||||||
|
|
||||||
|
j = find_end_of(document.header, i, "\\begin_local_layout", "\\end_local_layout")
|
||||||
|
if j == -1:
|
||||||
|
# this should not happen
|
||||||
|
document.warning("Malformed LyX document: Can't find end of local layout!")
|
||||||
|
return
|
||||||
|
|
||||||
|
k = find_token(document.header, "### Inserted by lyx2lyx (more [scr]article styles) ###", i, j)
|
||||||
|
if k != -1:
|
||||||
|
l = find_token(document.header, "### End of insertion by lyx2lyx (more [scr]article styles) ###", i, j)
|
||||||
|
if l == -1:
|
||||||
|
# this should not happen
|
||||||
|
document.warning("End of lyx2lyx local layout insertion not found!")
|
||||||
return
|
return
|
||||||
|
|
||||||
j = find_end_of(document.header, i, "\\begin_local_layout", "\\end_local_layout")
|
if k == i + 1 and l == j - 1:
|
||||||
if j == -1:
|
# that was all the local layout there was
|
||||||
# this should not happen
|
document.header[i : j + 1] = []
|
||||||
break
|
else:
|
||||||
|
|
||||||
k = find_token(document.header, "### Inserted by lyx2lyx (more [scr]article styles) ###", i, j)
|
|
||||||
if k != -1:
|
|
||||||
l = find_token(document.header, "### End of insertion by lyx2lyx (more [scr]article styles) ###", i, j)
|
|
||||||
if l == -1:
|
|
||||||
# this should not happen
|
|
||||||
document.warning("End of lyx2lyx local layout insertion not found!")
|
|
||||||
break
|
|
||||||
|
|
||||||
document.header[k : l + 1] = []
|
document.header[k : l + 1] = []
|
||||||
|
|
||||||
return
|
|
||||||
|
|
||||||
|
|
||||||
def revert_bosnian(document):
|
def revert_bosnian(document):
|
||||||
"Set the document language to English but assure Bosnian output"
|
"Set the document language to English but assure Bosnian output"
|
||||||
@ -612,7 +615,6 @@ def revert_iopart(document):
|
|||||||
"Input stdlayouts.inc",
|
"Input stdlayouts.inc",
|
||||||
"### End of insertion by lyx2lyx (stdlayouts) ###"
|
"### End of insertion by lyx2lyx (stdlayouts) ###"
|
||||||
]
|
]
|
||||||
return
|
|
||||||
|
|
||||||
|
|
||||||
def convert_iopart(document):
|
def convert_iopart(document):
|
||||||
@ -643,8 +645,6 @@ def convert_iopart(document):
|
|||||||
else:
|
else:
|
||||||
document.header[k : l + 1] = []
|
document.header[k : l + 1] = []
|
||||||
|
|
||||||
return
|
|
||||||
|
|
||||||
|
|
||||||
##
|
##
|
||||||
# Conversion hub
|
# Conversion hub
|
||||||
|
Loading…
Reference in New Issue
Block a user