mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-22 05:16:21 +00:00
beamer revision, part 1: support for overlay arguments
This commit is contained in:
parent
50f88e256b
commit
30b53ba4a0
@ -11,6 +11,10 @@ adjustments are made to tex2lyx and bugs are fixed in lyx2lyx.
|
||||
|
||||
-----------------------
|
||||
|
||||
2012-12-09 Jürgen Spitzmüller <spitz@lyx.org>
|
||||
* Format incremented to 451: Native support for beamer action/overlay arguments.
|
||||
\command<overlay> => \begin_inset Argument 1
|
||||
|
||||
2012-12-04 Jürgen Spitzmüller <spitz@lyx.org>
|
||||
* Format incremented to 450: Support for the URW Garamond LaTeX fonts.
|
||||
- \usepackage{garamondx} > \font_serif garamondx
|
||||
|
@ -47,6 +47,7 @@ TitleLaTeXName makebeamertitle
|
||||
AddToPreamble
|
||||
% this default might be overridden by plain title style
|
||||
\newcommand\makebeamertitle{\frame{\maketitle}}%
|
||||
% (ERT) argument for the TOC
|
||||
\AtBeginDocument{%
|
||||
\let\origtableofcontents=\tableofcontents
|
||||
\def\tableofcontents{\@ifnextchar[{\origtableofcontents}{\gobbletableofcontents}}
|
||||
@ -84,6 +85,18 @@ Style Itemize
|
||||
Argument 1
|
||||
LabelString "Overlay Specifications|S"
|
||||
Tooltip "Overlay specifications for this list"
|
||||
LeftDelim [<
|
||||
RightDelim >]
|
||||
EndArgument
|
||||
Argument item:1
|
||||
LabelString "Custom Item|s"
|
||||
Tooltip "A customized item string"
|
||||
EndArgument
|
||||
Argument item:2
|
||||
LabelString "Item Overlay Specifications"
|
||||
Tooltip "Overlay specifications for this item"
|
||||
LeftDelim <
|
||||
RightDelim >
|
||||
EndArgument
|
||||
NextNoIndent 1
|
||||
LeftMargin MMN
|
||||
@ -104,10 +117,22 @@ Style Enumerate
|
||||
Argument 1
|
||||
LabelString "Overlay Specifications|S"
|
||||
Tooltip "Overlay specifications for this list"
|
||||
LeftDelim [<
|
||||
RightDelim >]
|
||||
EndArgument
|
||||
Argument 2
|
||||
LabelString "Mini template"
|
||||
Tooltip "Mini template for this List"
|
||||
LabelString "Mini Template"
|
||||
Tooltip "Mini template for this list (see beamer manual for details)"
|
||||
EndArgument
|
||||
Argument item:1
|
||||
LabelString "Custom Item|s"
|
||||
Tooltip "A customized item string"
|
||||
EndArgument
|
||||
Argument item:2
|
||||
LabelString "Item Overlay Specifications"
|
||||
Tooltip "Overlay specifications for this item"
|
||||
LeftDelim <
|
||||
RightDelim >
|
||||
EndArgument
|
||||
NextNoIndent 1
|
||||
LeftMargin MMN
|
||||
@ -130,10 +155,18 @@ Style Description
|
||||
Argument 1
|
||||
LabelString "Overlay Specifications|S"
|
||||
Tooltip "Overlay specifications for this list"
|
||||
LeftDelim [<
|
||||
RightDelim >]
|
||||
EndArgument
|
||||
Argument 2
|
||||
LabelString "Longest label|s"
|
||||
Tooltip "The longest label in this list"
|
||||
Tooltip "The longest label in this list (to determine the indendation width)"
|
||||
EndArgument
|
||||
Argument item:1
|
||||
LabelString "Item Overlay Specifications"
|
||||
Tooltip "Overlay specifications for this item"
|
||||
LeftDelim <
|
||||
RightDelim >
|
||||
EndArgument
|
||||
NextNoIndent 1
|
||||
LeftMargin MM
|
||||
@ -161,6 +194,12 @@ Style Part
|
||||
LatexType Command
|
||||
LatexName part
|
||||
Argument 1
|
||||
LabelString "Mode Specification|S"
|
||||
Tooltip "Specify in which mode (article, presentation etc.) this header appears"
|
||||
LeftDelim <
|
||||
RightDelim >
|
||||
EndArgument
|
||||
Argument 2
|
||||
LabelString "Short Title|S"
|
||||
Tooltip "The part as it appears in the table of contents/running headers"
|
||||
EndArgument
|
||||
@ -204,6 +243,12 @@ Style Section
|
||||
LabelString "Section \arabic{section}"
|
||||
RefPrefix sec
|
||||
Argument 1
|
||||
LabelString "Mode Specification|S"
|
||||
Tooltip "Specify in which mode (article, presentation etc.) this header appears"
|
||||
LeftDelim <
|
||||
RightDelim >
|
||||
EndArgument
|
||||
Argument 2
|
||||
LabelString "Short Title|S"
|
||||
Tooltip "The section as it appears in the table of contents/running headers"
|
||||
EndArgument
|
||||
@ -223,9 +268,16 @@ Style Section*
|
||||
CopyStyle Section
|
||||
Category Unnumbered
|
||||
Margin Static
|
||||
LatexName lyxframeend{}\section*
|
||||
LatexName lyxframeend{}\section
|
||||
LabelType No_Label
|
||||
ResetArgs 1
|
||||
Argument 1
|
||||
LabelString "Mode Specification|S"
|
||||
Tooltip "Specify in which mode (article, presentation etc.) this header appears"
|
||||
LeftDelim <
|
||||
RightDelim >
|
||||
EndArgument
|
||||
LaTeXParam *
|
||||
End
|
||||
|
||||
Style Subsection
|
||||
@ -246,6 +298,12 @@ Style Subsection
|
||||
LabelString "Subsection \arabic{section}.\arabic{subsection}"
|
||||
RefPrefix sub
|
||||
Argument 1
|
||||
LabelString "Mode Specification|S"
|
||||
Tooltip "Specify in which mode (article, presentation etc.) this header appears"
|
||||
LeftDelim <
|
||||
RightDelim >
|
||||
EndArgument
|
||||
Argument 2
|
||||
LabelString "Short Title|S"
|
||||
Tooltip "The subsection as it appears in the table of contents/running headers"
|
||||
EndArgument
|
||||
@ -265,9 +323,16 @@ Style Subsection*
|
||||
CopyStyle Subsection
|
||||
Category Unnumbered
|
||||
Margin Static
|
||||
LatexName lyxframeend{}\subsection*
|
||||
LatexName lyxframeend{}\subsection
|
||||
LabelType No_Label
|
||||
ResetArgs 1
|
||||
Argument 1
|
||||
LabelString "Mode Specification|S"
|
||||
Tooltip "Specify in which mode (article, presentation etc.) this header appears"
|
||||
LeftDelim <
|
||||
RightDelim >
|
||||
EndArgument
|
||||
LaTeXParam *
|
||||
End
|
||||
|
||||
Style Subsubsection
|
||||
@ -288,6 +353,12 @@ Style Subsubsection
|
||||
LabelString "Subsubsection \arabic{section}.\arabic{subsection}.\arabic{subsubsection}"
|
||||
RefPrefix sub
|
||||
Argument 1
|
||||
LabelString "Mode Specification|S"
|
||||
Tooltip "Specify in which mode (article, presentation etc.) this header appears"
|
||||
LeftDelim <
|
||||
RightDelim >
|
||||
EndArgument
|
||||
Argument 2
|
||||
LabelString "Short Title|S"
|
||||
Tooltip "The subsubsection as it appears in the table of contents/running headers"
|
||||
EndArgument
|
||||
@ -307,9 +378,16 @@ Style Subsubsection*
|
||||
CopyStyle Subsubsection
|
||||
Category Unnumbered
|
||||
Margin Static
|
||||
LatexName lyxframeend{}\subsubsection*
|
||||
LatexName lyxframeend{}\subsubsection
|
||||
LabelType No_Label
|
||||
ResetArgs 1
|
||||
Argument 1
|
||||
LabelString "Mode Specification|S"
|
||||
Tooltip "Specify in which mode (article, presentation etc.) this header appears"
|
||||
LeftDelim <
|
||||
RightDelim >
|
||||
EndArgument
|
||||
LaTeXParam *
|
||||
End
|
||||
|
||||
|
||||
@ -398,12 +476,20 @@ Style AgainFrame
|
||||
Category Frames
|
||||
KeepEmpty 0
|
||||
LatexType Command
|
||||
LatexName lyxframeend{}\lyxagainframe
|
||||
LatexName lyxframeend{}\againframe
|
||||
Argument 1
|
||||
LabelString "Overlay Specifications|S"
|
||||
Tooltip "Overlay specifications for this list"
|
||||
Tooltip "Overlay specifications for this frame"
|
||||
LeftDelim <
|
||||
RightDelim >
|
||||
EndArgument
|
||||
Argument 2
|
||||
LabelString "Default Overlay Specifications"
|
||||
Tooltip "Default overlay specifications within this frame"
|
||||
LeftDelim [<
|
||||
RightDelim >]
|
||||
EndArgument
|
||||
Argument 3
|
||||
LabelString "Frame Options"
|
||||
Tooltip "Frame options (see beamer manual)"
|
||||
EndArgument
|
||||
@ -428,13 +514,6 @@ Style AgainFrame
|
||||
Series Bold
|
||||
Size Largest
|
||||
EndFont
|
||||
Preamble
|
||||
\long\def\lyxagainframe#1{\@lyxagainframe#1\@lyxframestop}%
|
||||
\def\@lyxagainframe{\@ifnextchar<{\@@lyxagainframe}{\@@lyxagainframe<*>}}%
|
||||
\def\@@lyxagainframe<#1>{\@ifnextchar[{\@@@lyxagainframe<#1>}{\@@@lyxagainframe<#1>[]}}
|
||||
\long\def\@@@lyxagainframe<#1>[#2]#3\@lyxframestop{%
|
||||
\againframe<#1>[#2]{#3}}
|
||||
EndPreamble
|
||||
End
|
||||
|
||||
Style EndFrame
|
||||
@ -479,6 +558,12 @@ Style FrameSubtitle
|
||||
Series Bold
|
||||
Color Blue
|
||||
EndFont
|
||||
Argument 1
|
||||
LabelString "Overlay Specification|S"
|
||||
Tooltip "Specify the overlay settings (see beamer manual)"
|
||||
LeftDelim <
|
||||
RightDelim >
|
||||
EndArgument
|
||||
End
|
||||
|
||||
|
||||
@ -607,6 +692,10 @@ Style Overprint
|
||||
Family Roman
|
||||
Color latex
|
||||
EndFont
|
||||
Argument 1
|
||||
LabelString "Overprint Area Width"
|
||||
Tooltip "The width of the overprint area (default: text width)"
|
||||
EndArgument
|
||||
End
|
||||
|
||||
Style OverlayArea
|
||||
@ -628,6 +717,16 @@ Style OverlayArea
|
||||
Family Roman
|
||||
Color latex
|
||||
EndFont
|
||||
Argument 1
|
||||
LabelString "Overlay Area Width"
|
||||
Tooltip "The width of the overlay area"
|
||||
Mandatory 1
|
||||
EndArgument
|
||||
Argument 2
|
||||
LabelString "Overlay Area Height"
|
||||
Tooltip "The height of the overlay area"
|
||||
Mandatory 1
|
||||
EndArgument
|
||||
End
|
||||
|
||||
Style Uncover
|
||||
@ -638,7 +737,7 @@ Style Uncover
|
||||
ParIndent MM
|
||||
Align Left
|
||||
LabelType Static
|
||||
LatexName uncoverenv}%{
|
||||
LatexName uncoverenv
|
||||
LabelSep xx
|
||||
LabelString "Uncovered on slides"
|
||||
ParSkip 0.5
|
||||
@ -649,6 +748,12 @@ Style Uncover
|
||||
Family Roman
|
||||
Color Latex
|
||||
EndFont
|
||||
Argument 1
|
||||
LabelString "Overlay Specification|S"
|
||||
Tooltip "Specify the overlay settings (see beamer manual)"
|
||||
LeftDelim <
|
||||
RightDelim >
|
||||
EndArgument
|
||||
End
|
||||
|
||||
Style Only
|
||||
@ -659,7 +764,7 @@ Style Only
|
||||
ParIndent MM
|
||||
Align Left
|
||||
LabelType Static
|
||||
LatexName onlyenv}%{
|
||||
LatexName onlyenv
|
||||
LabelSep xx
|
||||
LabelString "Only on slides"
|
||||
ParSkip 0.5
|
||||
@ -670,6 +775,12 @@ Style Only
|
||||
Family Roman
|
||||
Color Latex
|
||||
EndFont
|
||||
Argument 1
|
||||
LabelString "Overlay Specification|S"
|
||||
Tooltip "Specify the overlay settings (see beamer manual)"
|
||||
LeftDelim <
|
||||
RightDelim >
|
||||
EndArgument
|
||||
End
|
||||
|
||||
|
||||
@ -950,7 +1061,7 @@ Style Quotation
|
||||
Category MainText
|
||||
Margin Static
|
||||
LatexType Environment
|
||||
LatexName quotation}%{
|
||||
LatexName quotation
|
||||
NextNoIndent 1
|
||||
LeftMargin MMM
|
||||
RightMargin MMM
|
||||
@ -962,13 +1073,19 @@ Style Quotation
|
||||
ParSep 0
|
||||
Align Block
|
||||
AlignPossible Block, Left, Right, Center
|
||||
Argument 1
|
||||
LabelString "Overlay Specification|S"
|
||||
Tooltip "Specify the overlay settings (see beamer manual)"
|
||||
LeftDelim <
|
||||
RightDelim >
|
||||
EndArgument
|
||||
End
|
||||
|
||||
Style Quote
|
||||
Category MainText
|
||||
Margin Static
|
||||
LatexType Environment
|
||||
LatexName quote}%{
|
||||
LatexName quote
|
||||
NextNoIndent 1
|
||||
LeftMargin MMM
|
||||
RightMargin MMM
|
||||
@ -978,6 +1095,12 @@ Style Quote
|
||||
Align Block
|
||||
AlignPossible Block, Left, Right, Center
|
||||
LabelType No_Label
|
||||
Argument 1
|
||||
LabelString "Overlay Specification|S"
|
||||
Tooltip "Specify the overlay settings (see beamer manual)"
|
||||
LeftDelim <
|
||||
RightDelim >
|
||||
EndArgument
|
||||
End
|
||||
|
||||
Style Verse
|
||||
@ -985,7 +1108,7 @@ Style Verse
|
||||
# In LyX this does not make sense.
|
||||
Category MainText
|
||||
LatexType Environment
|
||||
LatexName verse}%{
|
||||
LatexName verse
|
||||
Margin First_Dynamic
|
||||
NextNoIndent 1
|
||||
LeftMargin MMMM
|
||||
@ -997,6 +1120,12 @@ Style Verse
|
||||
Align Block
|
||||
AlignPossible Block, Left
|
||||
LabelType No_Label
|
||||
Argument 1
|
||||
LabelString "Overlay Specification|S"
|
||||
Tooltip "Specify the overlay settings (see beamer manual)"
|
||||
LeftDelim <
|
||||
RightDelim >
|
||||
EndArgument
|
||||
End
|
||||
|
||||
|
||||
@ -1013,7 +1142,7 @@ Style Corollary
|
||||
Align Left
|
||||
LabelType Static
|
||||
LabelSep xx
|
||||
LatexName corollary}%{
|
||||
LatexName corollary
|
||||
LabelString "Corollary."
|
||||
ParSkip 0.5
|
||||
TopSep 1
|
||||
@ -1025,23 +1154,33 @@ Style Corollary
|
||||
Color Blue
|
||||
Size Large
|
||||
EndFont
|
||||
Argument 1
|
||||
LabelString "Action Specification|S"
|
||||
Tooltip "Specify the overlay settings (see beamer manual)"
|
||||
LeftDelim <
|
||||
RightDelim >
|
||||
EndArgument
|
||||
Argument 2
|
||||
LabelString "Additional Theorem Text"
|
||||
Tooltip "Additional text appended to the theorem header"
|
||||
EndArgument
|
||||
End
|
||||
|
||||
Style Definition
|
||||
CopyStyle Corollary
|
||||
LatexName definition}%{
|
||||
LatexName definition
|
||||
LabelString "Definition."
|
||||
End
|
||||
|
||||
Style Definitions
|
||||
CopyStyle Corollary
|
||||
LatexName definitions}%{
|
||||
LatexName definitions
|
||||
LabelString "Definitions."
|
||||
End
|
||||
|
||||
Style Example
|
||||
CopyStyle Corollary
|
||||
LatexName example}%{
|
||||
LatexName example
|
||||
LabelString "Example."
|
||||
LabelFont
|
||||
Series Bold
|
||||
@ -1051,25 +1190,25 @@ End
|
||||
|
||||
Style Examples
|
||||
CopyStyle Corollary
|
||||
LatexName examples}%{
|
||||
LatexName examples
|
||||
LabelString "Examples."
|
||||
End
|
||||
|
||||
Style Fact
|
||||
CopyStyle Corollary
|
||||
LatexName fact}%{
|
||||
LatexName fact
|
||||
LabelString "Fact."
|
||||
End
|
||||
|
||||
Style Proof
|
||||
CopyStyle Corollary
|
||||
LatexName proof}%{
|
||||
LatexName proof
|
||||
LabelString "Proof."
|
||||
End
|
||||
|
||||
Style Theorem
|
||||
CopyStyle Corollary
|
||||
LatexName theorem}%{
|
||||
LatexName theorem
|
||||
LabelString "Theorem."
|
||||
End
|
||||
|
||||
@ -1154,6 +1293,12 @@ Style NoteItem
|
||||
Family Roman
|
||||
Color latex
|
||||
EndFont
|
||||
Argument 1
|
||||
LabelString "Overlay Specification|S"
|
||||
Tooltip "Specify the overlay settings (see beamer manual)"
|
||||
LeftDelim <
|
||||
RightDelim >
|
||||
EndArgument
|
||||
End
|
||||
|
||||
|
||||
@ -1161,6 +1306,22 @@ End
|
||||
# CHARSTYLES
|
||||
#
|
||||
|
||||
InsetLayout Flex:Emphasize
|
||||
LyXType charstyle
|
||||
LabelString Emphasize
|
||||
LatexType command
|
||||
LatexName emph
|
||||
Font
|
||||
Shape italic
|
||||
EndFont
|
||||
Argument 1
|
||||
LabelString "Action Specification|S"
|
||||
Tooltip "Specify the overlay settings (see beamer manual)"
|
||||
LeftDelim <
|
||||
RightDelim >
|
||||
EndArgument
|
||||
End
|
||||
|
||||
InsetLayout Flex:Alert
|
||||
LyXType charstyle
|
||||
LabelString Alert
|
||||
@ -1169,6 +1330,12 @@ InsetLayout Flex:Alert
|
||||
Font
|
||||
Color red
|
||||
EndFont
|
||||
Argument 1
|
||||
LabelString "Action Specification|S"
|
||||
Tooltip "Specify the overlay settings (see beamer manual)"
|
||||
LeftDelim <
|
||||
RightDelim >
|
||||
EndArgument
|
||||
End
|
||||
|
||||
InsetLayout Flex:Structure
|
||||
@ -1179,11 +1346,124 @@ InsetLayout Flex:Structure
|
||||
Font
|
||||
Color blue
|
||||
EndFont
|
||||
Argument 1
|
||||
LabelString "Action Specification|S"
|
||||
Tooltip "Specify the overlay settings (see beamer manual)"
|
||||
LeftDelim <
|
||||
RightDelim >
|
||||
EndArgument
|
||||
End
|
||||
|
||||
InsetLayout Flex:Only
|
||||
LyXType charstyle
|
||||
LabelString Only
|
||||
LatexType command
|
||||
LatexName only
|
||||
Font
|
||||
Color red
|
||||
EndFont
|
||||
Argument 1
|
||||
LabelString "Overlay Specification|S"
|
||||
Tooltip "Specify the overlay settings (see beamer manual)"
|
||||
LeftDelim <
|
||||
RightDelim >
|
||||
EndArgument
|
||||
End
|
||||
|
||||
InsetLayout Flex:Uncover
|
||||
LyXType charstyle
|
||||
LabelString Uncover
|
||||
LatexType command
|
||||
LatexName uncover
|
||||
Font
|
||||
Color red
|
||||
EndFont
|
||||
Argument 1
|
||||
LabelString "Overlay Specification|S"
|
||||
Tooltip "Specify the overlay settings (see beamer manual)"
|
||||
LeftDelim <
|
||||
RightDelim >
|
||||
EndArgument
|
||||
End
|
||||
|
||||
InsetLayout Flex:Visible
|
||||
LyXType charstyle
|
||||
LabelString Visible
|
||||
LatexType command
|
||||
LatexName visible
|
||||
Font
|
||||
Color red
|
||||
EndFont
|
||||
Argument 1
|
||||
LabelString "Overlay Specification|S"
|
||||
Tooltip "Specify the overlay settings (see beamer manual)"
|
||||
LeftDelim <
|
||||
RightDelim >
|
||||
EndArgument
|
||||
End
|
||||
|
||||
InsetLayout Flex:Invisible
|
||||
LyXType charstyle
|
||||
LabelString Invisible
|
||||
LatexType command
|
||||
LatexName invisible
|
||||
Font
|
||||
Color red
|
||||
EndFont
|
||||
Argument 1
|
||||
LabelString "Overlay Specification|S"
|
||||
Tooltip "Specify the overlay settings (see beamer manual)"
|
||||
LeftDelim <
|
||||
RightDelim >
|
||||
EndArgument
|
||||
End
|
||||
|
||||
InsetLayout Flex:Alternative
|
||||
LyXType charstyle
|
||||
LabelString Alternative
|
||||
LatexType command
|
||||
LatexName alt
|
||||
Font
|
||||
Color red
|
||||
EndFont
|
||||
Argument 1
|
||||
LabelString "Overlay Specification|S"
|
||||
Tooltip "Specify the overlay settings (see beamer manual)"
|
||||
LeftDelim <
|
||||
RightDelim >
|
||||
EndArgument
|
||||
Argument 2
|
||||
LabelString "Default Text"
|
||||
Tooltip "Enter the default text here"
|
||||
Mandatory 1
|
||||
EndArgument
|
||||
End
|
||||
|
||||
InsetLayout Flex:Beamer_Note
|
||||
LyXType custom
|
||||
LabelString Note
|
||||
LatexType command
|
||||
LatexName note
|
||||
Decoration Classic
|
||||
Font
|
||||
Color blue
|
||||
EndFont
|
||||
Argument 1
|
||||
LabelString "Overlay Specification|S"
|
||||
Tooltip "Specify the overlay settings (see beamer manual)"
|
||||
LeftDelim <
|
||||
RightDelim >
|
||||
EndArgument
|
||||
Argument 2
|
||||
LabelString "Note Options"
|
||||
Tooltip "Specifiy note options (see beamer manual)"
|
||||
EndArgument
|
||||
End
|
||||
|
||||
InsetLayout Flex:ArticleMode
|
||||
LyXType custom
|
||||
LatexName mode<article>
|
||||
LatexName mode
|
||||
LatexParam <article>
|
||||
LatexType command
|
||||
Decoration classic
|
||||
LabelString Article
|
||||
|
@ -25,12 +25,12 @@ import sys, os
|
||||
|
||||
# Uncomment only what you need to import, please.
|
||||
|
||||
from parser_tools import del_token, find_token, find_token_backwards, find_end_of, \
|
||||
from parser_tools import del_token, find_token, find_token_exact, find_token_backwards, find_end_of, \
|
||||
find_end_of_inset, find_end_of_layout, find_re, get_option_value, get_containing_layout, \
|
||||
get_value, get_quoted_value, set_option_value
|
||||
|
||||
#from parser_tools import find_token, find_end_of, find_tokens, \
|
||||
#find_token_exact, find_end_of_inset, find_end_of_layout, \
|
||||
#find_end_of_inset, find_end_of_layout, \
|
||||
#is_in_inset, del_token, check_token
|
||||
|
||||
from lyx2lyx_tools import add_to_preamble, put_cmd_in_ert, get_ert
|
||||
@ -1826,6 +1826,663 @@ def revert_garamondx(document):
|
||||
document.header[i] = "\\font_roman default"
|
||||
|
||||
|
||||
def convert_beamerargs(document):
|
||||
" Converts beamer arguments to new layout "
|
||||
|
||||
beamer_classes = ["beamer", "article-beamer", "scrarticle-beamer"]
|
||||
if document.textclass not in beamer_classes:
|
||||
return
|
||||
|
||||
shifted_layouts = ["Part", "Section", "Subsection", "Subsubsection"]
|
||||
list_layouts = ["Itemize", "Enumerate", "Description"]
|
||||
rx = re.compile(r'^\\begin_inset Argument (\d+)$')
|
||||
|
||||
i = 0
|
||||
while True:
|
||||
i = find_token(document.body, "\\begin_inset Argument", i)
|
||||
if i == -1:
|
||||
return
|
||||
# Find containing paragraph layout
|
||||
parent = get_containing_layout(document.body, i)
|
||||
if parent == False:
|
||||
document.warning("Malformed lyx document: Can't find parent paragraph layout")
|
||||
i = i + 1
|
||||
continue
|
||||
parbeg = parent[1]
|
||||
parend = parent[2]
|
||||
layoutname = parent[0]
|
||||
for p in range(parbeg, parend):
|
||||
if layoutname in shifted_layouts:
|
||||
m = rx.match(document.body[p])
|
||||
if m:
|
||||
argnr = int(m.group(1))
|
||||
argnr += 1
|
||||
document.body[p] = "\\begin_inset Argument %d" % argnr
|
||||
if layoutname == "AgainFrame":
|
||||
m = rx.match(document.body[p])
|
||||
if m:
|
||||
document.body[p] = "\\begin_inset Argument 3"
|
||||
if document.body[p + 4] == "\\begin_inset ERT":
|
||||
if document.body[p + 9].startswith("<"):
|
||||
# This is an overlay specification
|
||||
# strip off the <
|
||||
document.body[p + 9] = document.body[p + 9][1:]
|
||||
if document.body[p + 9].endswith(">"):
|
||||
# strip off the >
|
||||
document.body[p + 9] = document.body[p + 9][:-1]
|
||||
# Shift this one
|
||||
document.body[p] = "\\begin_inset Argument 2"
|
||||
if layoutname in list_layouts:
|
||||
m = rx.match(document.body[p])
|
||||
if m:
|
||||
if m.group(1) == "1":
|
||||
if document.body[p + 4] == "\\begin_inset ERT":
|
||||
if document.body[p + 9].startswith("<"):
|
||||
# This is an overlay specification
|
||||
# strip off the <
|
||||
document.body[p + 9] = document.body[p + 9][1:]
|
||||
if document.body[p + 9].endswith(">"):
|
||||
# strip off the >
|
||||
document.body[p + 9] = document.body[p + 9][:-1]
|
||||
elif layoutname != "Itemize":
|
||||
# Shift this one
|
||||
document.body[p] = "\\begin_inset Argument 2"
|
||||
i = i + 1
|
||||
|
||||
|
||||
def convert_againframe_args(document):
|
||||
" Converts beamer AgainFrame to new layout "
|
||||
|
||||
# FIXME: This currently only works if the arguments are in one single ERT
|
||||
|
||||
beamer_classes = ["beamer", "article-beamer", "scrarticle-beamer"]
|
||||
if document.textclass not in beamer_classes:
|
||||
return
|
||||
|
||||
i = 0
|
||||
while True:
|
||||
i = find_token(document.body, "\\begin_layout AgainFrame", i)
|
||||
if i == -1:
|
||||
break
|
||||
j = find_end_of_layout(document.body, i)
|
||||
if i != -1:
|
||||
if document.body[i + 1] == "\\begin_inset ERT":
|
||||
if document.body[i + 6].startswith("[<"):
|
||||
# This is a default overlay specification
|
||||
# strip off the [<
|
||||
document.body[i + 6] = document.body[i + 6][2:]
|
||||
if document.body[i + 6].endswith(">]"):
|
||||
# strip off the >]
|
||||
document.body[i + 6] = document.body[i + 6][:-2]
|
||||
elif document.body[i + 6].endswith("]"):
|
||||
# divide the args
|
||||
tok = document.body[i + 6].find('>][')
|
||||
if tok != -1:
|
||||
subst = [document.body[i + 6][:tok],
|
||||
'\\end_layout', '', '\\end_inset', '', '', '\\begin_inset Argument 3',
|
||||
'status collapsed', '', '\\begin_layout Plain Layout',
|
||||
document.body[i + 6][tok + 3:-1]]
|
||||
document.body[i + 6 : i + 7] = subst
|
||||
# Convert to ArgInset
|
||||
document.body[i + 1] = "\\begin_inset Argument 2"
|
||||
i = j
|
||||
continue
|
||||
elif document.body[i + 6].startswith("<"):
|
||||
# This is an overlay specification
|
||||
# strip off the <
|
||||
document.body[i + 6] = document.body[i + 6][1:]
|
||||
if document.body[i + 6].endswith(">"):
|
||||
# strip off the >
|
||||
document.body[i + 6] = document.body[i + 6][:-1]
|
||||
# Convert to ArgInset
|
||||
document.body[i + 1] = "\\begin_inset Argument 1"
|
||||
elif document.body[i + 6].endswith(">]"):
|
||||
# divide the args
|
||||
tok = document.body[i + 6].find('>[<')
|
||||
if tok != -1:
|
||||
document.body[i + 6 : i + 7] = [document.body[i + 6][:tok],
|
||||
'\\end_layout', '', '\\end_inset', '', '', '\\begin_inset Argument 2',
|
||||
'status collapsed', '', '\\begin_layout Plain Layout',
|
||||
document.body[i + 6][tok + 3:-2]]
|
||||
# Convert to ArgInset
|
||||
document.body[i + 1] = "\\begin_inset Argument 1"
|
||||
elif document.body[i + 6].endswith("]"):
|
||||
# divide the args
|
||||
tok = document.body[i + 6].find('>[<')
|
||||
if tok != -1:
|
||||
# divide the args
|
||||
tokk = document.body[i + 6].find('>][')
|
||||
if tokk != -1:
|
||||
document.body[i + 6 : i + 7] = [document.body[i + 6][:tok],
|
||||
'\\end_layout', '', '\\end_inset', '', '', '\\begin_inset Argument 2',
|
||||
'status collapsed', '', '\\begin_layout Plain Layout',
|
||||
document.body[i + 6][tok + 3:tokk],
|
||||
'\\end_layout', '', '\\end_inset', '', '', '\\begin_inset Argument 3',
|
||||
'status collapsed', '', '\\begin_layout Plain Layout',
|
||||
document.body[i + 6][tokk + 3:-1]]
|
||||
else:
|
||||
tokk = document.body[i + 6].find('>[')
|
||||
if tokk != -1:
|
||||
document.warning(document.body[i + 6][tokk + 2:-1])
|
||||
document.body[i + 6 : i + 7] = [document.body[i + 6][:tokk],
|
||||
'\\end_layout', '', '\\end_inset', '', '', '\\begin_inset Argument 3',
|
||||
'status collapsed', '', '\\begin_layout Plain Layout',
|
||||
document.body[i + 6][tokk + 2:-1]]
|
||||
# Convert to ArgInset
|
||||
document.body[i + 1] = "\\begin_inset Argument 1"
|
||||
i = j
|
||||
continue
|
||||
elif document.body[i + 6].startswith("["):
|
||||
# This is an ERT option
|
||||
# strip off the [
|
||||
document.body[i + 6] = document.body[i + 6][1:]
|
||||
if document.body[i + 6].endswith("]"):
|
||||
# strip off the ]
|
||||
document.body[i + 6] = document.body[i + 6][:-1]
|
||||
# Convert to ArgInset
|
||||
document.body[i + 1] = "\\begin_inset Argument 3"
|
||||
i = j
|
||||
continue
|
||||
i = j
|
||||
|
||||
|
||||
def convert_corollary_args(document):
|
||||
" Converts beamer corrolary-style ERT arguments native InsetArgs "
|
||||
|
||||
beamer_classes = ["beamer", "article-beamer", "scrarticle-beamer"]
|
||||
if document.textclass not in beamer_classes:
|
||||
return
|
||||
|
||||
corollary_layouts = ["Corollary", "Definition", "Definitions", "Example", "Examples", "Fact", "Proof", "Theorem"]
|
||||
for lay in corollary_layouts:
|
||||
i = 0
|
||||
while True:
|
||||
i = find_token_exact(document.body, "\\begin_layout " + lay, i)
|
||||
if i == -1:
|
||||
break
|
||||
j = find_end_of_layout(document.body, i)
|
||||
if i != -1:
|
||||
if document.body[i + 1] == "\\begin_inset ERT":
|
||||
if document.body[i + 6].startswith("<"):
|
||||
# This is an overlay specification
|
||||
# strip off the <
|
||||
document.body[i + 6] = document.body[i + 6][1:]
|
||||
if document.body[i + 6].endswith(">"):
|
||||
# strip off the >
|
||||
document.body[i + 6] = document.body[i + 6][:-1]
|
||||
elif document.body[i + 6].endswith("]"):
|
||||
# divide the args
|
||||
tok = document.body[i + 6].find('>[')
|
||||
if tok != -1:
|
||||
subst = [document.body[i + 6][:tok],
|
||||
'\\end_layout', '', '\\end_inset', '', '', '\\begin_inset Argument 2',
|
||||
'status collapsed', '', '\\begin_layout Plain Layout',
|
||||
document.body[i + 6][tok + 2:-1]]
|
||||
document.body[i + 6 : i + 7] = subst
|
||||
# Convert to ArgInset
|
||||
document.body[i + 1] = "\\begin_inset Argument 1"
|
||||
i = j
|
||||
continue
|
||||
elif document.body[i + 6].startswith("["):
|
||||
# This is an ERT option
|
||||
# strip off the [
|
||||
document.body[i + 6] = document.body[i + 6][1:]
|
||||
if document.body[i + 6].endswith("]"):
|
||||
# strip off the ]
|
||||
document.body[i + 6] = document.body[i + 6][:-1]
|
||||
# Convert to ArgInset
|
||||
document.body[i + 1] = "\\begin_inset Argument 2"
|
||||
i = j
|
||||
continue
|
||||
i = j
|
||||
|
||||
|
||||
|
||||
def convert_quote_args(document):
|
||||
" Converts beamer quote style ERT args to native InsetArgs "
|
||||
|
||||
beamer_classes = ["beamer", "article-beamer", "scrarticle-beamer"]
|
||||
if document.textclass not in beamer_classes:
|
||||
return
|
||||
|
||||
quote_layouts = ["Uncover", "Only", "Quotation", "Quote", "Verse"]
|
||||
for lay in quote_layouts:
|
||||
i = 0
|
||||
while True:
|
||||
i = find_token(document.body, "\\begin_layout " + lay, i)
|
||||
if i == -1:
|
||||
break
|
||||
j = find_end_of_layout(document.body, i)
|
||||
if i != -1:
|
||||
if document.body[i + 1] == "\\begin_inset ERT":
|
||||
if document.body[i + 6].startswith("<"):
|
||||
# This is an overlay specification
|
||||
# strip off the <
|
||||
document.body[i + 6] = document.body[i + 6][1:]
|
||||
if document.body[i + 6].endswith(">"):
|
||||
# strip off the >
|
||||
document.body[i + 6] = document.body[i + 6][:-1]
|
||||
# Convert to ArgInset
|
||||
document.body[i + 1] = "\\begin_inset Argument 1"
|
||||
i = j
|
||||
|
||||
|
||||
def revert_beamerargs(document):
|
||||
" Reverts beamer arguments to old layout "
|
||||
|
||||
beamer_classes = ["beamer", "article-beamer", "scrarticle-beamer"]
|
||||
if document.textclass not in beamer_classes:
|
||||
return
|
||||
|
||||
i = 0
|
||||
list_layouts = ["Itemize", "Enumerate", "Description"]
|
||||
headings = ["Part", "Section", "Section*", "Subsection", "Subsection*",
|
||||
"Subsubsection", "Subsubsection*", "FrameSubtitle", "NoteItem"]
|
||||
quote_layouts = ["Uncover", "Only", "Quotation", "Quote", "Verse"]
|
||||
corollary_layouts = ["Corollary", "Definition", "Definitions", "Example", "Examples", "Fact", "Proof", "Theorem"]
|
||||
rx = re.compile(r'^\\begin_inset Argument (\S+)$')
|
||||
|
||||
while True:
|
||||
i = find_token(document.body, "\\begin_inset Argument", i)
|
||||
if i == -1:
|
||||
return
|
||||
# Find containing paragraph layout
|
||||
parent = get_containing_layout(document.body, i)
|
||||
if parent == False:
|
||||
document.warning("Malformed lyx document: Can't find parent paragraph layout")
|
||||
i = i + 1
|
||||
continue
|
||||
parbeg = parent[1]
|
||||
parend = parent[2]
|
||||
layoutname = parent[0]
|
||||
realparend = parend
|
||||
for p in range(parbeg, parend):
|
||||
if p >= realparend:
|
||||
i = realparend
|
||||
break
|
||||
if layoutname in headings:
|
||||
m = rx.match(document.body[p])
|
||||
if m:
|
||||
argnr = m.group(1)
|
||||
if argnr == "1":
|
||||
# Find containing paragraph layout
|
||||
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)
|
||||
argcontent = document.body[beginPlain + 1 : endPlain]
|
||||
# Adjust range end
|
||||
realparend = realparend - len(document.body[p : endInset + 1])
|
||||
# Remove arg inset
|
||||
del document.body[p : endInset + 1]
|
||||
if layoutname == "FrameSubtitle":
|
||||
pre = put_cmd_in_ert("\\" + layoutname.lower() + "<") + argcontent + put_cmd_in_ert(">")
|
||||
elif layoutname == "NoteItem":
|
||||
pre = put_cmd_in_ert("\\note<") + argcontent + put_cmd_in_ert(">[item]")
|
||||
elif layoutname.endswith('*'):
|
||||
pre = put_cmd_in_ert("\\lyxframeend\\" + layoutname.lower()[:-1] + "<") + argcontent + put_cmd_in_ert(">*")
|
||||
else:
|
||||
pre = put_cmd_in_ert("\\lyxframeend\\" + layoutname.lower() + "<") + argcontent + put_cmd_in_ert(">")
|
||||
secarg = find_token(document.body, "\\begin_inset Argument 2", parbeg, parend)
|
||||
if secarg != -1:
|
||||
# Find containing paragraph layout
|
||||
beginPlain = find_token(document.body, "\\begin_layout Plain Layout", secarg)
|
||||
endPlain = find_end_of_layout(document.body, beginPlain)
|
||||
endInset = find_end_of_inset(document.body, secarg)
|
||||
argcontent = document.body[beginPlain + 1 : endPlain]
|
||||
# Adjust range end
|
||||
realparend = realparend - len(document.body[secarg : endInset + 1])
|
||||
del document.body[secarg : endInset + 1]
|
||||
pre += put_cmd_in_ert("[") + argcontent + put_cmd_in_ert("]")
|
||||
pre += put_cmd_in_ert("{")
|
||||
document.body[parbeg] = "\\begin_layout Standard"
|
||||
document.body[parbeg + 1 : parbeg + 1] = pre
|
||||
pe = find_end_of_layout(document.body, parbeg)
|
||||
post = put_cmd_in_ert("}")
|
||||
document.body[pe : pe] = post
|
||||
realparend += len(pre) + len(post)
|
||||
if layoutname == "AgainFrame":
|
||||
m = rx.match(document.body[p])
|
||||
if m:
|
||||
argnr = m.group(1)
|
||||
if argnr == "3":
|
||||
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
|
||||
realparend = realparend - len(document.body[p : endInset + 1])
|
||||
# Remove arg inset
|
||||
del document.body[p : endInset + 1]
|
||||
subst = put_cmd_in_ert("[") + content + put_cmd_in_ert("]")
|
||||
document.body[parbeg + 1:parbeg + 1] = subst
|
||||
if layoutname == "Overprint":
|
||||
m = rx.match(document.body[p])
|
||||
if m:
|
||||
argnr = m.group(1)
|
||||
if argnr == "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
|
||||
realparend = realparend - len(document.body[p : endInset + 1])
|
||||
# Remove arg inset
|
||||
del document.body[p : endInset + 1]
|
||||
subst = put_cmd_in_ert("[") + content + put_cmd_in_ert("]")
|
||||
document.body[parbeg + 1:parbeg + 1] = subst
|
||||
if layoutname == "OverlayArea":
|
||||
m = rx.match(document.body[p])
|
||||
if m:
|
||||
argnr = m.group(1)
|
||||
if argnr == "2":
|
||||
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
|
||||
realparend = realparend - len(document.body[p : endInset + 1])
|
||||
# Remove arg inset
|
||||
del document.body[p : endInset + 1]
|
||||
subst = put_cmd_in_ert("{") + content + put_cmd_in_ert("}")
|
||||
document.body[parbeg + 1:parbeg + 1] = subst
|
||||
if layoutname in list_layouts:
|
||||
m = rx.match(document.body[p])
|
||||
if m:
|
||||
argnr = m.group(1)
|
||||
if argnr == "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
|
||||
realparend = realparend - len(document.body[p : endInset + 1])
|
||||
# Remove arg inset
|
||||
del document.body[p : endInset + 1]
|
||||
subst = put_cmd_in_ert("<") + content + put_cmd_in_ert(">")
|
||||
document.body[parbeg + 1:parbeg + 1] = subst
|
||||
elif argnr == "item:1":
|
||||
j = find_end_of_inset(document.body, i)
|
||||
# Find containing paragraph layout
|
||||
beginPlain = find_token(document.body, "\\begin_layout Plain Layout", i)
|
||||
endPlain = find_end_of_layout(document.body, beginPlain)
|
||||
content = document.body[beginPlain + 1 : endPlain]
|
||||
del document.body[i:j+1]
|
||||
subst = put_cmd_in_ert("[") + content + put_cmd_in_ert("]")
|
||||
document.body[parbeg + 1 : parbeg + 1] = subst
|
||||
elif argnr == "item:2":
|
||||
j = find_end_of_inset(document.body, i)
|
||||
# Find containing paragraph layout
|
||||
beginPlain = find_token(document.body, "\\begin_layout Plain Layout", i)
|
||||
endPlain = find_end_of_layout(document.body, beginPlain)
|
||||
content = document.body[beginPlain + 1 : endPlain]
|
||||
del document.body[i:j+1]
|
||||
subst = put_cmd_in_ert("<") + content + put_cmd_in_ert(">")
|
||||
document.body[parbeg + 1:parbeg + 1] = subst
|
||||
if layoutname in quote_layouts:
|
||||
m = rx.match(document.body[p])
|
||||
if m:
|
||||
argnr = m.group(1)
|
||||
if argnr == "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
|
||||
realparend = realparend - len(document.body[p : endInset + 1])
|
||||
# Remove arg inset
|
||||
del document.body[p : endInset + 1]
|
||||
subst = put_cmd_in_ert("<") + content + put_cmd_in_ert(">")
|
||||
document.body[parbeg + 1:parbeg + 1] = subst
|
||||
if layoutname in corollary_layouts:
|
||||
m = rx.match(document.body[p])
|
||||
if m:
|
||||
argnr = m.group(1)
|
||||
if argnr == "2":
|
||||
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
|
||||
realparend = realparend - len(document.body[p : endInset + 1])
|
||||
# Remove arg inset
|
||||
del document.body[p : endInset + 1]
|
||||
subst = put_cmd_in_ert("[") + content + put_cmd_in_ert("]")
|
||||
document.body[parbeg + 1:parbeg + 1] = subst
|
||||
|
||||
i = realparend
|
||||
|
||||
|
||||
def revert_beamerargs2(document):
|
||||
" Reverts beamer arguments to old layout, step 2 "
|
||||
|
||||
beamer_classes = ["beamer", "article-beamer", "scrarticle-beamer"]
|
||||
if document.textclass not in beamer_classes:
|
||||
return
|
||||
|
||||
i = 0
|
||||
shifted_layouts = ["Part", "Section", "Subsection", "Subsubsection"]
|
||||
corollary_layouts = ["Corollary", "Definition", "Definitions", "Example", "Examples", "Fact", "Proof", "Theorem"]
|
||||
rx = re.compile(r'^\\begin_inset Argument (\S+)$')
|
||||
|
||||
while True:
|
||||
i = find_token(document.body, "\\begin_inset Argument", i)
|
||||
if i == -1:
|
||||
return
|
||||
# Find containing paragraph layout
|
||||
parent = get_containing_layout(document.body, i)
|
||||
if parent == False:
|
||||
document.warning("Malformed lyx document: Can't find parent paragraph layout")
|
||||
i = i + 1
|
||||
continue
|
||||
parbeg = parent[1]
|
||||
parend = parent[2]
|
||||
layoutname = parent[0]
|
||||
realparend = parend
|
||||
for p in range(parbeg, parend):
|
||||
if p >= realparend:
|
||||
i = realparend
|
||||
break
|
||||
if layoutname in shifted_layouts:
|
||||
m = rx.match(document.body[p])
|
||||
if m:
|
||||
argnr = m.group(1)
|
||||
if argnr == "2":
|
||||
document.body[p] = "\\begin_inset Argument 1"
|
||||
if layoutname in corollary_layouts:
|
||||
m = rx.match(document.body[p])
|
||||
if m:
|
||||
argnr = m.group(1)
|
||||
if argnr == "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
|
||||
realparend = realparend - len(document.body[p : endInset + 1])
|
||||
# Remove arg inset
|
||||
del document.body[p : endInset + 1]
|
||||
subst = put_cmd_in_ert("<") + content + put_cmd_in_ert(">")
|
||||
document.body[parbeg + 1:parbeg + 1] = subst
|
||||
if layoutname == "OverlayArea":
|
||||
m = rx.match(document.body[p])
|
||||
if m:
|
||||
argnr = m.group(1)
|
||||
if argnr == "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
|
||||
realparend = realparend - len(document.body[p : endInset + 1])
|
||||
# Remove arg inset
|
||||
del document.body[p : endInset + 1]
|
||||
subst = put_cmd_in_ert("{") + content + put_cmd_in_ert("}")
|
||||
document.body[parbeg + 1:parbeg + 1] = subst
|
||||
if layoutname == "AgainFrame":
|
||||
m = rx.match(document.body[p])
|
||||
if m:
|
||||
argnr = m.group(1)
|
||||
if argnr == "2":
|
||||
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
|
||||
realparend = realparend - len(document.body[p : endInset + 1])
|
||||
# Remove arg inset
|
||||
del document.body[p : endInset + 1]
|
||||
subst = put_cmd_in_ert("[<") + content + put_cmd_in_ert(">]")
|
||||
document.body[parbeg + 1:parbeg + 1] = subst
|
||||
i = realparend
|
||||
|
||||
|
||||
def revert_beamerargs3(document):
|
||||
" Reverts beamer arguments to old layout, step 3 "
|
||||
|
||||
beamer_classes = ["beamer", "article-beamer", "scrarticle-beamer"]
|
||||
if document.textclass not in beamer_classes:
|
||||
return
|
||||
|
||||
rx = re.compile(r'^\\begin_inset Argument (\S+)$')
|
||||
i = 0
|
||||
while True:
|
||||
i = find_token(document.body, "\\begin_inset Argument", i)
|
||||
if i == -1:
|
||||
return
|
||||
# Find containing paragraph layout
|
||||
parent = get_containing_layout(document.body, i)
|
||||
if parent == False:
|
||||
document.warning("Malformed lyx document: Can't find parent paragraph layout")
|
||||
i = i + 1
|
||||
continue
|
||||
parbeg = parent[1]
|
||||
parend = parent[2]
|
||||
layoutname = parent[0]
|
||||
realparend = parend
|
||||
for p in range(parbeg, parend):
|
||||
if p >= realparend:
|
||||
i = realparend
|
||||
break
|
||||
if layoutname == "AgainFrame":
|
||||
m = rx.match(document.body[p])
|
||||
if m:
|
||||
argnr = m.group(1)
|
||||
if argnr == "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
|
||||
realparend = realparend - len(document.body[p : endInset + 1])
|
||||
# Remove arg inset
|
||||
del document.body[p : endInset + 1]
|
||||
subst = put_cmd_in_ert("<") + content + put_cmd_in_ert(">")
|
||||
document.body[parbeg + 1:parbeg + 1] = subst
|
||||
i = realparend
|
||||
|
||||
|
||||
def revert_beamerflex(document):
|
||||
" Reverts beamer Flex insets "
|
||||
|
||||
beamer_classes = ["beamer", "article-beamer", "scrarticle-beamer"]
|
||||
if document.textclass not in beamer_classes:
|
||||
return
|
||||
|
||||
new_flexes = {"Emphasize" : "\\emph", "Only" : "\\only", "Uncover" : "\\uncover",
|
||||
"Visible" : "\\visible", "Invisible" : "\\invisible",
|
||||
"Alternative" : "\\alt", "Beamer_Note" : "\\note"}
|
||||
old_flexes = {"Alert" : "\\alert", "Structure" : "\\structure"}
|
||||
rx = re.compile(r'^\\begin_inset Flex (.+)$')
|
||||
|
||||
i = 0
|
||||
while True:
|
||||
i = find_token(document.body, "\\begin_inset Flex", i)
|
||||
if i == -1:
|
||||
return
|
||||
m = rx.match(document.body[i])
|
||||
if m:
|
||||
flextype = m.group(1)
|
||||
z = find_end_of_inset(document.body, i)
|
||||
if z == -1:
|
||||
document.warning("Can't find end of Flex " + flextype + " inset.")
|
||||
i += 1
|
||||
continue
|
||||
if flextype in new_flexes:
|
||||
pre = put_cmd_in_ert(new_flexes[flextype])
|
||||
arg = find_token(document.body, "\\begin_inset Argument 1", i, z)
|
||||
if arg != -1:
|
||||
argend = find_end_of_inset(document.body, arg)
|
||||
if argend == -1:
|
||||
document.warning("Can't find end of Argument!")
|
||||
i += 1
|
||||
continue
|
||||
# Find containing paragraph layout
|
||||
beginPlain = find_token(document.body, "\\begin_layout Plain Layout", arg)
|
||||
endPlain = find_end_of_layout(document.body, beginPlain)
|
||||
argcontent = document.body[beginPlain + 1 : endPlain]
|
||||
# Adjust range end
|
||||
z = z - len(document.body[arg : argend + 1])
|
||||
# Remove arg inset
|
||||
del document.body[arg : argend + 1]
|
||||
pre += put_cmd_in_ert("<") + argcontent + put_cmd_in_ert(">")
|
||||
arg = find_token(document.body, "\\begin_inset Argument 2", i, z)
|
||||
if arg != -1:
|
||||
argend = find_end_of_inset(document.body, arg)
|
||||
if argend == -1:
|
||||
document.warning("Can't find end of Argument!")
|
||||
i += 1
|
||||
continue
|
||||
# Find containing paragraph layout
|
||||
beginPlain = find_token(document.body, "\\begin_layout Plain Layout", arg)
|
||||
endPlain = find_end_of_layout(document.body, beginPlain)
|
||||
argcontent = document.body[beginPlain + 1 : endPlain]
|
||||
# Adjust range end
|
||||
z = z - len(document.body[arg : argend + 1])
|
||||
# Remove arg inset
|
||||
del document.body[arg : argend + 1]
|
||||
pre += put_cmd_in_ert("[") + argcontent + put_cmd_in_ert("]")
|
||||
pre += put_cmd_in_ert("{")
|
||||
beginPlain = find_token(document.body, "\\begin_layout Plain Layout", i)
|
||||
endPlain = find_end_of_layout(document.body, beginPlain)
|
||||
# Adjust range end
|
||||
z = z - len(document.body[i : beginPlain + 1])
|
||||
z += len(pre)
|
||||
document.body[i : beginPlain + 1] = pre
|
||||
post = put_cmd_in_ert("}")
|
||||
document.body[z - 2 : z + 1] = post
|
||||
elif flextype in old_flexes:
|
||||
pre = put_cmd_in_ert(old_flexes[flextype])
|
||||
arg = find_token(document.body, "\\begin_inset Argument 1", i, z)
|
||||
if arg == -1:
|
||||
i += 1
|
||||
continue
|
||||
argend = find_end_of_inset(document.body, arg)
|
||||
if argend == -1:
|
||||
document.warning("Can't find end of Argument!")
|
||||
i += 1
|
||||
continue
|
||||
# Find containing paragraph layout
|
||||
beginPlain = find_token(document.body, "\\begin_layout Plain Layout", arg)
|
||||
endPlain = find_end_of_layout(document.body, beginPlain)
|
||||
argcontent = document.body[beginPlain + 1 : endPlain]
|
||||
# Adjust range end
|
||||
z = z - len(document.body[arg : argend + 1])
|
||||
# Remove arg inset
|
||||
del document.body[arg : argend + 1]
|
||||
pre += put_cmd_in_ert("<") + argcontent + put_cmd_in_ert(">")
|
||||
pre += put_cmd_in_ert("{")
|
||||
beginPlain = find_token(document.body, "\\begin_layout Plain Layout", i)
|
||||
endPlain = find_end_of_layout(document.body, beginPlain)
|
||||
# Adjust range end
|
||||
z = z - len(document.body[i : beginPlain + 1])
|
||||
z += len(pre)
|
||||
document.body[i : beginPlain + 1] = pre
|
||||
post = put_cmd_in_ert("}")
|
||||
document.body[z - 2 : z + 1] = post
|
||||
|
||||
i += 1
|
||||
|
||||
|
||||
##
|
||||
# Conversion hub
|
||||
#
|
||||
@ -1868,10 +2525,12 @@ convert = [
|
||||
[447, [convert_IEEEtran, convert_AASTeX, convert_AGUTeX, convert_IJMP, convert_SIGPLAN, convert_SIGGRAPH, convert_EuropeCV]],
|
||||
[448, [convert_literate]],
|
||||
[449, []],
|
||||
[450, []]
|
||||
[450, []],
|
||||
[451, [convert_beamerargs, convert_againframe_args, convert_corollary_args, convert_quote_args]]
|
||||
]
|
||||
|
||||
revert = [
|
||||
[450, [revert_beamerargs, revert_beamerargs2, revert_beamerargs3, revert_beamerflex]],
|
||||
[449, [revert_garamondx, revert_garamondx_newtxmath]],
|
||||
[448, [revert_itemargs]],
|
||||
[447, [revert_literate]],
|
||||
|
@ -85,6 +85,8 @@ Format LaTeX feature LyX feature
|
||||
449 \item[<arg>] \begin_inset Argument item:<nr>
|
||||
450 garamondx.sty, ugm LaTeX font, \font_roman, \font_osf,
|
||||
[garamondx]{newtxmath} \font_math
|
||||
451 beamer overlay arguments InsetArgument
|
||||
\command<arg>, \begin{env}<arg>
|
||||
|
||||
|
||||
General
|
||||
|
@ -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 450 // spitz: support for URW Garamond
|
||||
#define LYX_FORMAT_TEX2LYX 450 // spitz: support for URW Garamond
|
||||
#define LYX_FORMAT_LYX 451 // spitz: support for overlay args in beamer
|
||||
#define LYX_FORMAT_TEX2LYX 451 // spitz: support for overlay args in beamer
|
||||
|
||||
#if LYX_FORMAT_TEX2LYX != LYX_FORMAT_LYX
|
||||
#ifndef _MSC_VER
|
||||
|
Loading…
Reference in New Issue
Block a user