Proper support for memoir epigraph (bug #8151)

This commit is contained in:
Juergen Spitzmueller 2012-12-28 12:32:59 +01:00
parent 37f41fd4b5
commit 78cd88f5a3
5 changed files with 93 additions and 4 deletions

View File

@ -11,6 +11,11 @@ adjustments are made to tex2lyx and bugs are fixed in lyx2lyx.
-----------------------
2012-12-28 Jürgen Spitzmüller <spitz@lyx.org>
* Format incremented to 456: Proper support for memoir \epigraph
\epigraph{text}{source} > begin_layout Epigraph, <source> as
InsetArgument post:1
2012-12-22 Jürgen Spitzmüller <spitz@lyx.org>
* Format incremented to 455: Support for beamer \frametitle
\frametitle<overlay>[short]{title} > begin_layout FrameTitle

View File

@ -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

View File

@ -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]],

View File

@ -96,6 +96,7 @@ Format LaTeX feature LyX feature
\end{overprint}
455 beamer frametitle command \begin_layout FrameTitle
\frametitle<overlay>[short}{long}
456 memoir: \epigraph{text}{source} layout Epigraph, InsetArgument
General

View File

@ -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