diff --git a/development/FORMAT b/development/FORMAT index 1f8d9e1587..033e9be83b 100644 --- a/development/FORMAT +++ b/development/FORMAT @@ -11,6 +11,11 @@ adjustments are made to tex2lyx and bugs are fixed in lyx2lyx. ----------------------- +2012-12-28 Jürgen Spitzmüller + * Format incremented to 456: Proper support for memoir \epigraph + \epigraph{text}{source} > begin_layout Epigraph, as + InsetArgument post:1 + 2012-12-22 Jürgen Spitzmüller * Format incremented to 455: Support for beamer \frametitle \frametitle[short]{title} > begin_layout FrameTitle diff --git a/lib/layouts/memoir.layout b/lib/layouts/memoir.layout index 24de4e5ac2..4e0a3fdf48 100644 --- a/lib/layouts/memoir.layout +++ b/lib/layouts/memoir.layout @@ -171,7 +171,6 @@ Style Chapterprecis EndFont End -#FIXME: this takes two parameters!!! Style Epigraph Category Maintext Margin Right_Address_Box @@ -181,6 +180,12 @@ Style Epigraph BottomSep 1.5 ParSep 1.5 Align Left + Argument post:1 + MenuString "Epigraph Source|S" + LabelString "Source" + Tooltip "The source/author of ths epigraph" + Mandatory 1 + EndArgument End Style Poemtitle diff --git a/lib/lyx2lyx/lyx_2_1.py b/lib/lyx2lyx/lyx_2_1.py index 684f5c83b0..3ee673f02e 100644 --- a/lib/lyx2lyx/lyx_2_1.py +++ b/lib/lyx2lyx/lyx_2_1.py @@ -2897,6 +2897,82 @@ def revert_frametitle(document): i = endlay +def convert_epigraph(document): + " Converts memoir epigraph to new syntax " + + if document.textclass != "memoir": + return + + i = 0 + while True: + i = find_token(document.body, "\\begin_layout Epigraph", i) + if i == -1: + return + j = find_end_of_layout(document.body, i) + if j == -1: + document.warning("Malformed lyx document: Can't find end of Epigraph layout") + i = i + 1 + continue + endlay = j + subst = list() + ert = find_token(document.body, "\\begin_inset ERT", i, j) + if ert != -1: + endInset = find_end_of_inset(document.body, ert) + beginPlain = find_token(document.body, "\\begin_layout Plain Layout", ert) + endPlain = find_end_of_layout(document.body, beginPlain) + ertcont = beginPlain + 2 + if document.body[ertcont] == "}{": + # strip off the < + # Convert to ArgInset + endlay = endlay - 2 * len(document.body[j]) + begsubst = ['\\begin_inset Argument post:1', 'status collapsed', '', + '\\begin_layout Plain Layout'] + endsubst = ['\\end_layout', '', '\\end_inset', '', document.body[j]] + document.body[j : j] = endsubst + document.body[endInset + 1 : endInset + 1] = begsubst + # Adjust range end + endlay += len(begsubst) + len(endsubst) + endlay = endlay - len(document.body[ert : endInset + 1]) + del document.body[ert : endInset + 1] + + i = endlay + + +def revert_epigraph(document): + " Reverts memoir epigraph argument to ERT " + + if document.textclass != "memoir": + return + + i = 0 + while True: + i = find_token(document.body, "\\begin_layout Epigraph", i) + if i == -1: + return + j = find_end_of_layout(document.body, i) + if j == -1: + document.warning("Malformed lyx document: Can't find end of Epigraph layout") + i = i + 1 + continue + endlay = j + subst = list() + p = find_token(document.body, "\\begin_layout Argument post:1", i, j) + if p != -1: + beginPlain = find_token(document.body, "\\begin_layout Plain Layout", p) + endPlain = find_end_of_layout(document.body, beginPlain) + endInset = find_end_of_inset(document.body, p) + content = document.body[beginPlain + 1 : endPlain] + # Adjust range end + endlay = endlay - len(document.body[p : endInset + 1]) + # Remove arg inset + del document.body[p : endInset + 1] + subst += put_cmd_in_ert("}{") + content + else: + subst += put_cmd_in_ert("}{") + + document.body[j : j] = subst + document.body[j : j] + i = endlay + ## # Conversion hub @@ -2945,10 +3021,12 @@ convert = [ [452, [convert_beamerblocks]], [453, [convert_use_stmaryrd]], [454, [convert_overprint]], - [455, []] + [455, []], + [456, [convert_epigraph]] ] revert = [ + [455, [revert_epigraph]], [454, [revert_frametitle]], [453, [revert_overprint]], [452, [revert_use_stmaryrd]], diff --git a/src/tex2lyx/TODO.txt b/src/tex2lyx/TODO.txt index fec204a8ee..f2ae0efd7e 100644 --- a/src/tex2lyx/TODO.txt +++ b/src/tex2lyx/TODO.txt @@ -96,6 +96,7 @@ Format LaTeX feature LyX feature \end{overprint} 455 beamer frametitle command \begin_layout FrameTitle \frametitle[short}{long} +456 memoir: \epigraph{text}{source} layout Epigraph, InsetArgument General diff --git a/src/version.h b/src/version.h index 255c47e623..5cab79e8d5 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 455 // spitz: support for beamer FrameTitle layout -#define LYX_FORMAT_TEX2LYX 455 // spitz: support for beamer FrameTitle layout +#define LYX_FORMAT_LYX 456 // spitz: proper support for memoir epigraph +#define LYX_FORMAT_TEX2LYX 456 // spitz: proper support for memoir epigraph #if LYX_FORMAT_TEX2LYX != LYX_FORMAT_LYX #ifndef _MSC_VER