mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-25 10:58:52 +00:00
Old beamer frames bite the dust
With this commit, old beamer frames are converted to new ones. The old styles are removed (including the infamous \lyxframe). This should be tested with as much beamer documents as possible (I have already done so), also, tex2lyx now probably produces invalid LyX files.
This commit is contained in:
parent
257edda49a
commit
370bbbc7f2
@ -11,9 +11,14 @@ adjustments are made to tex2lyx and bugs are fixed in lyx2lyx.
|
|||||||
|
|
||||||
-----------------------
|
-----------------------
|
||||||
|
|
||||||
|
2013-03-16 Jürgen Spitzmüller <spitz@lyx.org>
|
||||||
|
* Format incremented to 465: Convert old beamer frames to new ones.
|
||||||
|
The layouts BeginFrame, BeginPlainFrame and EndFrame are now not
|
||||||
|
valied anymore (use "Frame", "PlainFrame" instead, and nesting).
|
||||||
|
|
||||||
2013-02-27 Kornel Benko <kornel@lyx.org>
|
2013-02-27 Kornel Benko <kornel@lyx.org>
|
||||||
* Format incremented to 464:
|
* Format incremented to 464:
|
||||||
- Added "cancel" to the GUI handled list of LaTeX packages
|
- Added "cancel" to the GUI handled list of LaTeX packages
|
||||||
|
|
||||||
2013-02-18 Julien Rioux <jrioux@lyx.org>
|
2013-02-18 Julien Rioux <jrioux@lyx.org>
|
||||||
* Format incremented to 463:
|
* Format incremented to 463:
|
||||||
|
@ -24,35 +24,3 @@ Preamble
|
|||||||
\def\gobbletableofcontents#1{\origtableofcontents}
|
\def\gobbletableofcontents#1{\origtableofcontents}
|
||||||
}
|
}
|
||||||
EndPreamble
|
EndPreamble
|
||||||
|
|
||||||
##########################################
|
|
||||||
# OBSOLETE STUFF
|
|
||||||
# Everything below should be removed
|
|
||||||
# (but this is a file format change)
|
|
||||||
#
|
|
||||||
# TODO:
|
|
||||||
# * conversion of old frame
|
|
||||||
# and plain frame to new layout
|
|
||||||
##########################################
|
|
||||||
|
|
||||||
#
|
|
||||||
# Backwards compatible definitions
|
|
||||||
#
|
|
||||||
|
|
||||||
AddToPreamble
|
|
||||||
\providecommand\lyxframeend{}
|
|
||||||
EndPreamble
|
|
||||||
|
|
||||||
# Frame control definition
|
|
||||||
Style BeginFrame
|
|
||||||
# This redefinition is needed to make beamerarticle work
|
|
||||||
Preamble
|
|
||||||
\long\def\lyxframe#1{\@lyxframe#1\@lyxframestop}%
|
|
||||||
\def\@lyxframe{\@ifnextchar<{\@@lyxframe}{\@@lyxframe<*>}}%
|
|
||||||
\def\@@lyxframe<#1>{\@ifnextchar[{\@@@lyxframe<#1>}{\@@@lyxframe<#1>[]}}
|
|
||||||
\def\@@@lyxframe<#1>[{\@ifnextchar<{\@@@@@lyxframe<#1>[}{\@@@@lyxframe<#1>[<*>][}}
|
|
||||||
\def\@@@@@lyxframe<#1>[#2]{\@ifnextchar[{\@@@@lyxframe<#1>[#2]}{\@@@@lyxframe<#1>[#2][]}}
|
|
||||||
\long\def\@@@@lyxframe<#1>[#2][#3]#4\@lyxframestop#5\lyxframeend{%
|
|
||||||
\frame<#1>[#3]{\frametitle{#4}#5}}
|
|
||||||
EndPreamble
|
|
||||||
End
|
|
||||||
|
@ -1561,158 +1561,3 @@ End
|
|||||||
|
|
||||||
|
|
||||||
Input theorems-refprefix.inc
|
Input theorems-refprefix.inc
|
||||||
|
|
||||||
|
|
||||||
##########################################
|
|
||||||
# OBSOLETE STUFF
|
|
||||||
# Everything below should be removed
|
|
||||||
# (but this is a file format change)
|
|
||||||
#
|
|
||||||
# TODO:
|
|
||||||
# * conversion of old frame
|
|
||||||
# and plain frame to new layout
|
|
||||||
##########################################
|
|
||||||
|
|
||||||
#
|
|
||||||
# Backwards compatible definitions
|
|
||||||
#
|
|
||||||
|
|
||||||
AddToPreamble
|
|
||||||
\providecommand\lyxframeend{}
|
|
||||||
EndPreamble
|
|
||||||
|
|
||||||
IfStyle Section
|
|
||||||
LatexName lyxframeend{}\section
|
|
||||||
End
|
|
||||||
|
|
||||||
IfStyle Section*
|
|
||||||
LatexName lyxframeend{}\section
|
|
||||||
End
|
|
||||||
|
|
||||||
IfStyle Subsection
|
|
||||||
LatexName lyxframeend{}\subsection
|
|
||||||
End
|
|
||||||
|
|
||||||
IfStyle Subsection*
|
|
||||||
LatexName lyxframeend{}\subsection
|
|
||||||
End
|
|
||||||
|
|
||||||
IfStyle Subsubsection
|
|
||||||
LatexName lyxframeend{}\subsubsection
|
|
||||||
End
|
|
||||||
|
|
||||||
IfStyle Subsubsection*
|
|
||||||
LatexName lyxframeend{}\subsubsection
|
|
||||||
End
|
|
||||||
|
|
||||||
IfStyle AgainFrame
|
|
||||||
LatexName lyxframeend{}\againframe
|
|
||||||
End
|
|
||||||
|
|
||||||
|
|
||||||
#
|
|
||||||
# Deprecated Styles
|
|
||||||
#
|
|
||||||
|
|
||||||
Style BeginFrame
|
|
||||||
Category "Deprecated Styles"
|
|
||||||
TocLevel 4
|
|
||||||
KeepEmpty 1
|
|
||||||
LatexType Command
|
|
||||||
LatexName lyxframeend{}\lyxframe
|
|
||||||
Argument 1
|
|
||||||
LabelString "Frame Options"
|
|
||||||
Tooltip "Frame options (see beamer manual)"
|
|
||||||
EndArgument
|
|
||||||
Margin First_Dynamic
|
|
||||||
NextNoIndent 1
|
|
||||||
ParSkip 0
|
|
||||||
TopSep 2.5
|
|
||||||
BottomSep 0.5
|
|
||||||
ParSep 0
|
|
||||||
Align Center
|
|
||||||
LabelType Static
|
|
||||||
LabelBottomSep 0
|
|
||||||
LeftMargin M
|
|
||||||
LabelSep xx
|
|
||||||
LabelString "Frame"
|
|
||||||
Font
|
|
||||||
Series Bold
|
|
||||||
Size Largest
|
|
||||||
Color Blue
|
|
||||||
EndFont
|
|
||||||
LabelFont
|
|
||||||
Family Roman
|
|
||||||
Color latex
|
|
||||||
EndFont
|
|
||||||
Preamble
|
|
||||||
\long\def\lyxframe#1{\@lyxframe#1\@lyxframestop}%
|
|
||||||
\def\@lyxframe{\@ifnextchar<{\@@lyxframe}{\@@lyxframe<*>}}%
|
|
||||||
\def\@@lyxframe<#1>{\@ifnextchar[{\@@@lyxframe<#1>}{\@@@lyxframe<#1>[]}}
|
|
||||||
\def\@@@lyxframe<#1>[{\@ifnextchar<{\@@@@@lyxframe<#1>[}{\@@@@lyxframe<#1>[<*>][}}
|
|
||||||
\def\@@@@@lyxframe<#1>[#2]{\@ifnextchar[{\@@@@lyxframe<#1>[#2]}{\@@@@lyxframe<#1>[#2][]}}
|
|
||||||
\long\def\@@@@lyxframe<#1>[#2][#3]#4\@lyxframestop#5\lyxframeend{%
|
|
||||||
\frame<#1>[#2][#3]{\frametitle{#4}#5}}
|
|
||||||
EndPreamble
|
|
||||||
End
|
|
||||||
|
|
||||||
Style BeginPlainFrame
|
|
||||||
Category "Deprecated Styles"
|
|
||||||
TocLevel 4
|
|
||||||
KeepEmpty 1
|
|
||||||
LatexType Command
|
|
||||||
LatexName lyxframeend{}\lyxplainframe
|
|
||||||
Margin First_Dynamic
|
|
||||||
NextNoIndent 1
|
|
||||||
ParSkip 0
|
|
||||||
TopSep 2.5
|
|
||||||
BottomSep 0.5
|
|
||||||
ParSep 0
|
|
||||||
Align Center
|
|
||||||
LabelType Static
|
|
||||||
LabelBottomSep 0
|
|
||||||
LeftMargin M
|
|
||||||
LabelSep xx
|
|
||||||
LabelString "Frame (no head/foot/sidebars)"
|
|
||||||
Font
|
|
||||||
Series Bold
|
|
||||||
Size Largest
|
|
||||||
Color Blue
|
|
||||||
EndFont
|
|
||||||
LabelFont
|
|
||||||
Family Roman
|
|
||||||
Color latex
|
|
||||||
EndFont
|
|
||||||
Preamble
|
|
||||||
\long\def\lyxplainframe#1{\@lyxplainframe#1\@lyxframestop}%
|
|
||||||
\def\@lyxplainframe{\@ifnextchar<{\@@lyxplainframe}{\@@lyxplainframe<*>}}%
|
|
||||||
\long\def\@@lyxplainframe<#1>#2\@lyxframestop#3\lyxframeend{%
|
|
||||||
\frame<#1>[plain]{\frametitle{#2}#3}}
|
|
||||||
EndPreamble
|
|
||||||
End
|
|
||||||
|
|
||||||
Style EndFrame
|
|
||||||
Category "Deprecated Styles"
|
|
||||||
KeepEmpty 1
|
|
||||||
LatexType Command
|
|
||||||
LatexName lyxframeend
|
|
||||||
Margin First_Dynamic
|
|
||||||
ParSkip 0
|
|
||||||
TopSep 0
|
|
||||||
BottomSep 3
|
|
||||||
ParSep 0
|
|
||||||
Align Center
|
|
||||||
LabelType Static
|
|
||||||
LabelBottomSep 0
|
|
||||||
LeftMargin MMMMM
|
|
||||||
LabelString "________________________________"
|
|
||||||
LabelFont
|
|
||||||
Family typewriter
|
|
||||||
Series Medium
|
|
||||||
Size Normal
|
|
||||||
Color latex
|
|
||||||
EndFont
|
|
||||||
Preamble
|
|
||||||
\def\lyxframeend{} % In case there is a superfluous frame end
|
|
||||||
EndPreamble
|
|
||||||
End
|
|
||||||
|
@ -24,35 +24,3 @@ Preamble
|
|||||||
\def\gobbletableofcontents#1{\origtableofcontents}
|
\def\gobbletableofcontents#1{\origtableofcontents}
|
||||||
}
|
}
|
||||||
EndPreamble
|
EndPreamble
|
||||||
|
|
||||||
##########################################
|
|
||||||
# OBSOLETE STUFF
|
|
||||||
# Everything below should be removed
|
|
||||||
# (but this is a file format change)
|
|
||||||
#
|
|
||||||
# TODO:
|
|
||||||
# * conversion of old frame
|
|
||||||
# and plain frame to new layout
|
|
||||||
##########################################
|
|
||||||
|
|
||||||
#
|
|
||||||
# Backwards compatible definitions
|
|
||||||
#
|
|
||||||
|
|
||||||
AddToPreamble
|
|
||||||
\providecommand\lyxframeend{}
|
|
||||||
EndPreamble
|
|
||||||
|
|
||||||
# Frame control definition
|
|
||||||
Style BeginFrame
|
|
||||||
# This redefinition is needed to make beamerarticle work
|
|
||||||
Preamble
|
|
||||||
\long\def\lyxframe#1{\@lyxframe#1\@lyxframestop}%
|
|
||||||
\def\@lyxframe{\@ifnextchar<{\@@lyxframe}{\@@lyxframe<*>}}%
|
|
||||||
\def\@@lyxframe<#1>{\@ifnextchar[{\@@@lyxframe<#1>}{\@@@lyxframe<#1>[]}}
|
|
||||||
\def\@@@lyxframe<#1>[{\@ifnextchar<{\@@@@@lyxframe<#1>[}{\@@@@lyxframe<#1>[<*>][}}
|
|
||||||
\def\@@@@@lyxframe<#1>[#2]{\@ifnextchar[{\@@@@lyxframe<#1>[#2]}{\@@@@lyxframe<#1>[#2][]}}
|
|
||||||
\long\def\@@@@lyxframe<#1>[#2][#3]#4\@lyxframestop#5\lyxframeend{%
|
|
||||||
\frame<#1>[#3]{\frametitle{#4}#5}}
|
|
||||||
EndPreamble
|
|
||||||
End
|
|
||||||
|
@ -3672,6 +3672,150 @@ def revert_new_libertines(document):
|
|||||||
document.header[k] = "\\font_sans default"
|
document.header[k] = "\\font_sans default"
|
||||||
|
|
||||||
|
|
||||||
|
def convert_lyxframes(document):
|
||||||
|
" Converts old beamer frames to new style "
|
||||||
|
|
||||||
|
beamer_classes = ["beamer", "article-beamer", "scrarticle-beamer"]
|
||||||
|
if document.textclass not in beamer_classes:
|
||||||
|
return
|
||||||
|
|
||||||
|
framebeg = ["BeginFrame", "BeginPlainFrame"]
|
||||||
|
frameend = ["EndFrame", "BeginFrame", "BeginPlainFrame", "AgainFrame", "Section", "Section*", "Subsection", "Subsection*", "Subsubsection", "Subsubsection*"]
|
||||||
|
for lay in framebeg:
|
||||||
|
i = 0
|
||||||
|
while True:
|
||||||
|
i = find_token_exact(document.body, "\\begin_layout " + lay, i)
|
||||||
|
if i == -1:
|
||||||
|
break
|
||||||
|
parent = get_containing_layout(document.body, i)
|
||||||
|
if parent == False or parent[1] != i:
|
||||||
|
document.warning("Wrong parent layout!")
|
||||||
|
i += 1
|
||||||
|
continue
|
||||||
|
frametype = parent[0]
|
||||||
|
j = parent[2]
|
||||||
|
parbeg = parent[3]
|
||||||
|
if i != -1:
|
||||||
|
# Step I: Convert ERT arguments
|
||||||
|
# FIXME: This currently only works if the arguments are in one single ERT
|
||||||
|
if document.body[parbeg] == "\\begin_inset ERT":
|
||||||
|
ertcont = parbeg + 5
|
||||||
|
if document.body[ertcont].startswith("[<"):
|
||||||
|
# This is a default overlay specification
|
||||||
|
# strip off the [<
|
||||||
|
document.body[ertcont] = document.body[ertcont][2:]
|
||||||
|
if document.body[ertcont].endswith(">]"):
|
||||||
|
# strip off the >]
|
||||||
|
document.body[ertcont] = document.body[ertcont][:-2]
|
||||||
|
elif document.body[ertcont].endswith("]"):
|
||||||
|
# divide the args
|
||||||
|
tok = document.body[ertcont].find('>][')
|
||||||
|
if tok != -1:
|
||||||
|
subst = [document.body[ertcont][:tok],
|
||||||
|
'\\end_layout', '', '\\end_inset', '', '', '\\begin_inset Argument 3',
|
||||||
|
'status collapsed', '', '\\begin_layout Plain Layout',
|
||||||
|
document.body[ertcont][tok + 3:-1]]
|
||||||
|
document.body[ertcont : ertcont + 1] = subst
|
||||||
|
# Convert to ArgInset
|
||||||
|
document.body[parbeg] = "\\begin_inset Argument 2"
|
||||||
|
elif document.body[ertcont].startswith("<"):
|
||||||
|
# This is an overlay specification
|
||||||
|
# strip off the <
|
||||||
|
document.body[ertcont] = document.body[ertcont][1:]
|
||||||
|
if document.body[ertcont].endswith(">"):
|
||||||
|
# strip off the >
|
||||||
|
document.body[ertcont] = document.body[ertcont][:-1]
|
||||||
|
# Convert to ArgInset
|
||||||
|
document.body[parbeg] = "\\begin_inset Argument 1"
|
||||||
|
elif document.body[ertcont].endswith(">]"):
|
||||||
|
# divide the args
|
||||||
|
tok = document.body[ertcont].find('>[<')
|
||||||
|
if tok != -1:
|
||||||
|
document.body[ertcont : ertcont + 1] = [document.body[ertcont][:tok],
|
||||||
|
'\\end_layout', '', '\\end_inset', '', '', '\\begin_inset Argument 2',
|
||||||
|
'status collapsed', '', '\\begin_layout Plain Layout',
|
||||||
|
document.body[ertcont][tok + 3:-2]]
|
||||||
|
# Convert to ArgInset
|
||||||
|
document.body[parbeg] = "\\begin_inset Argument 1"
|
||||||
|
elif document.body[ertcont].endswith("]"):
|
||||||
|
# divide the args
|
||||||
|
tok = document.body[ertcont].find('>[<')
|
||||||
|
if tok != -1:
|
||||||
|
# divide the args
|
||||||
|
tokk = document.body[ertcont].find('>][')
|
||||||
|
if tokk != -1:
|
||||||
|
document.body[ertcont : ertcont + 1] = [document.body[ertcont][:tok],
|
||||||
|
'\\end_layout', '', '\\end_inset', '', '', '\\begin_inset Argument 2',
|
||||||
|
'status collapsed', '', '\\begin_layout Plain Layout',
|
||||||
|
document.body[ertcont][tok + 3:tokk],
|
||||||
|
'\\end_layout', '', '\\end_inset', '', '', '\\begin_inset Argument 3',
|
||||||
|
'status collapsed', '', '\\begin_layout Plain Layout',
|
||||||
|
document.body[ertcont][tokk + 3:-1]]
|
||||||
|
else:
|
||||||
|
tokk = document.body[ertcont].find('>[')
|
||||||
|
if tokk != -1:
|
||||||
|
document.body[ertcont : ertcont + 1] = [document.body[ertcont][:tokk],
|
||||||
|
'\\end_layout', '', '\\end_inset', '', '', '\\begin_inset Argument 3',
|
||||||
|
'status collapsed', '', '\\begin_layout Plain Layout',
|
||||||
|
document.body[ertcont][tokk + 2:-1]]
|
||||||
|
# Convert to ArgInset
|
||||||
|
document.body[parbeg] = "\\begin_inset Argument 1"
|
||||||
|
elif document.body[ertcont].startswith("["):
|
||||||
|
# This is an ERT option
|
||||||
|
# strip off the [
|
||||||
|
document.body[ertcont] = document.body[ertcont][1:]
|
||||||
|
if document.body[ertcont].endswith("]"):
|
||||||
|
# strip off the ]
|
||||||
|
document.body[ertcont] = document.body[ertcont][:-1]
|
||||||
|
# Convert to ArgInset
|
||||||
|
document.body[parbeg] = "\\begin_inset Argument 3"
|
||||||
|
# End of argument conversion
|
||||||
|
# Step II: Now rename the layout
|
||||||
|
if lay == "BeginFrame":
|
||||||
|
document.body[i] = "\\begin_layout Frame"
|
||||||
|
else:
|
||||||
|
document.body[i] = "\\begin_layout PlainFrame"
|
||||||
|
# Step III: find real frame end
|
||||||
|
jj = j
|
||||||
|
while True:
|
||||||
|
fend = find_token(document.body, "\\begin_layout", jj)
|
||||||
|
if fend == -1:
|
||||||
|
document.warning("Malformed LyX document: No real frame end!")
|
||||||
|
return
|
||||||
|
val = get_value(document.body, "\\begin_layout", fend)
|
||||||
|
if val not in frameend:
|
||||||
|
jj = fend + 1
|
||||||
|
continue
|
||||||
|
old = document.body[fend]
|
||||||
|
if val == frametype:
|
||||||
|
document.body[fend : fend] = ['\\end_deeper', '', '\\begin_layout Separator', '', '\\end_layout']
|
||||||
|
else:
|
||||||
|
document.body[fend : fend] = ['\\end_deeper']
|
||||||
|
document.body[j + 1 : j + 1] = ['', '\\begin_deeper']
|
||||||
|
break
|
||||||
|
i = j
|
||||||
|
|
||||||
|
|
||||||
|
def remove_endframes(document):
|
||||||
|
" Remove deprecated beamer endframes "
|
||||||
|
|
||||||
|
beamer_classes = ["beamer", "article-beamer", "scrarticle-beamer"]
|
||||||
|
if document.textclass not in beamer_classes:
|
||||||
|
return
|
||||||
|
|
||||||
|
i = 0
|
||||||
|
while True:
|
||||||
|
i = find_token_exact(document.body, "\\begin_layout EndFrame", i)
|
||||||
|
if i == -1:
|
||||||
|
break
|
||||||
|
j = find_end_of_layout(document.body, i)
|
||||||
|
if j == -1:
|
||||||
|
document.warning("Malformed LyX document: Missing \\end_layout to EndFrame")
|
||||||
|
i = i + 1
|
||||||
|
continue
|
||||||
|
del document.body[i : j + 1]
|
||||||
|
|
||||||
|
|
||||||
##
|
##
|
||||||
# Conversion hub
|
# Conversion hub
|
||||||
#
|
#
|
||||||
@ -3729,9 +3873,11 @@ convert = [
|
|||||||
[462, []],
|
[462, []],
|
||||||
[463, [convert_encodings]],
|
[463, [convert_encodings]],
|
||||||
[464, [convert_use_cancel]],
|
[464, [convert_use_cancel]],
|
||||||
|
[465, [convert_lyxframes, remove_endframes]]
|
||||||
]
|
]
|
||||||
|
|
||||||
revert = [
|
revert = [
|
||||||
|
[464, []],
|
||||||
[463, [revert_use_cancel]],
|
[463, [revert_use_cancel]],
|
||||||
[462, [revert_encodings]],
|
[462, [revert_encodings]],
|
||||||
[461, [revert_new_libertines]],
|
[461, [revert_new_libertines]],
|
||||||
|
@ -88,7 +88,7 @@ Format LaTeX feature LyX feature
|
|||||||
\font_sans
|
\font_sans
|
||||||
\font_sf_scale
|
\font_sf_scale
|
||||||
463
|
463
|
||||||
|
465
|
||||||
|
|
||||||
General
|
General
|
||||||
|
|
||||||
|
@ -30,8 +30,8 @@ extern char const * const lyx_version_info;
|
|||||||
|
|
||||||
// Do not remove the comment below, so we get merge conflict in
|
// Do not remove the comment below, so we get merge conflict in
|
||||||
// independent branches. Instead add your own.
|
// independent branches. Instead add your own.
|
||||||
#define LYX_FORMAT_LYX 464 // kornel: use_package cancel
|
#define LYX_FORMAT_LYX 465 // spitz: new beamer frames
|
||||||
#define LYX_FORMAT_TEX2LYX 464 // kornel: use_package cancel
|
#define LYX_FORMAT_TEX2LYX 465 // spitz: new beamer frames
|
||||||
|
|
||||||
#if LYX_FORMAT_TEX2LYX != LYX_FORMAT_LYX
|
#if LYX_FORMAT_TEX2LYX != LYX_FORMAT_LYX
|
||||||
#ifndef _MSC_VER
|
#ifndef _MSC_VER
|
||||||
|
Loading…
Reference in New Issue
Block a user