The branch, master, has been updated. - Log -----------------------------------------------------------------
commit 370bbbc7f2b15a365b3c1faf8af541350522a455 Author: Juergen Spitzmueller <[email protected]> Date: Sat Mar 16 12:52:00 2013 +0100 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. diff --git a/development/FORMAT b/development/FORMAT index 0558362..ae42c5d 100644 --- a/development/FORMAT +++ b/development/FORMAT @@ -11,9 +11,14 @@ adjustments are made to tex2lyx and bugs are fixed in lyx2lyx. ----------------------- +2013-03-16 Jürgen Spitzmüller <[email protected]> + * 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 <[email protected]> - * Format incremented to 464: - - Added "cancel" to the GUI handled list of LaTeX packages + * Format incremented to 464: + - Added "cancel" to the GUI handled list of LaTeX packages 2013-02-18 Julien Rioux <[email protected]> * Format incremented to 463: diff --git a/lib/layouts/article-beamer.layout b/lib/layouts/article-beamer.layout index eff054c..31a4c7e 100644 --- a/lib/layouts/article-beamer.layout +++ b/lib/layouts/article-beamer.layout @@ -24,35 +24,3 @@ Preamble \def\gobbletableofcontents#1{\origtableofcontents} } 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 diff --git a/lib/layouts/beamer.layout b/lib/layouts/beamer.layout index e1fb28b..6e0be1b 100644 --- a/lib/layouts/beamer.layout +++ b/lib/layouts/beamer.layout @@ -1561,158 +1561,3 @@ End 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 diff --git a/lib/layouts/scrarticle-beamer.layout b/lib/layouts/scrarticle-beamer.layout index 3e35b87..0359dc9 100644 --- a/lib/layouts/scrarticle-beamer.layout +++ b/lib/layouts/scrarticle-beamer.layout @@ -24,35 +24,3 @@ Preamble \def\gobbletableofcontents#1{\origtableofcontents} } 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 diff --git a/lib/lyx2lyx/lyx_2_1.py b/lib/lyx2lyx/lyx_2_1.py index ccb17eb..ba50eea 100644 --- a/lib/lyx2lyx/lyx_2_1.py +++ b/lib/lyx2lyx/lyx_2_1.py @@ -3672,6 +3672,150 @@ def revert_new_libertines(document): 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 # @@ -3729,9 +3873,11 @@ convert = [ [462, []], [463, [convert_encodings]], [464, [convert_use_cancel]], + [465, [convert_lyxframes, remove_endframes]] ] revert = [ + [464, []], [463, [revert_use_cancel]], [462, [revert_encodings]], [461, [revert_new_libertines]], diff --git a/src/tex2lyx/TODO.txt b/src/tex2lyx/TODO.txt index 5c7ba2d..481a139 100644 --- a/src/tex2lyx/TODO.txt +++ b/src/tex2lyx/TODO.txt @@ -88,7 +88,7 @@ Format LaTeX feature LyX feature \font_sans \font_sf_scale 463 - +465 General diff --git a/src/version.h b/src/version.h index 94e5244..0c1e051 100644 --- a/src/version.h +++ b/src/version.h @@ -30,8 +30,8 @@ extern char const * const lyx_version_info; // Do not remove the comment below, so we get merge conflict in // independent branches. Instead add your own. -#define LYX_FORMAT_LYX 464 // kornel: use_package cancel -#define LYX_FORMAT_TEX2LYX 464 // kornel: use_package cancel +#define LYX_FORMAT_LYX 465 // spitz: new beamer frames +#define LYX_FORMAT_TEX2LYX 465 // spitz: new beamer frames #if LYX_FORMAT_TEX2LYX != LYX_FORMAT_LYX #ifndef _MSC_VER ----------------------------------------------------------------------- Summary of changes: development/FORMAT | 9 ++- lib/layouts/article-beamer.layout | 32 ------- lib/layouts/beamer.layout | 155 ---------------------------------- lib/layouts/scrarticle-beamer.layout | 32 ------- lib/lyx2lyx/lyx_2_1.py | 146 ++++++++++++++++++++++++++++++++ src/tex2lyx/TODO.txt | 2 +- src/version.h | 4 +- 7 files changed, 156 insertions(+), 224 deletions(-) hooks/post-receive -- The LyX Source Repository
