mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-22 10:00:33 +00:00
Add support for beamer lemma environment.
File fomat change.
This commit is contained in:
parent
98ab605041
commit
9a702f195d
@ -11,6 +11,10 @@ adjustments are made to tex2lyx and bugs are fixed in lyx2lyx.
|
||||
|
||||
-----------------------
|
||||
|
||||
2014-08-31 Jürgen Spitzmüller <spitz@lyx.org>
|
||||
* Format incremented to 479
|
||||
Support for beamer lemma environment.
|
||||
|
||||
2014-08-25 Uwe Stöhr <uwestoehr@web.de>
|
||||
* Format incremented to 478: support for the LaTeX math commands
|
||||
\x***arrow
|
||||
|
@ -1226,6 +1226,12 @@ Style Fact
|
||||
LabelString "Fact."
|
||||
End
|
||||
|
||||
Style Lemma
|
||||
CopyStyle Corollary
|
||||
LatexName lemma
|
||||
LabelString "Lemma."
|
||||
End
|
||||
|
||||
Style Proof
|
||||
CopyStyle Corollary
|
||||
LatexName proof
|
||||
|
@ -85,7 +85,7 @@ format_relation = [("0_06", [200], minor_versions("0.6" , 4)),
|
||||
("1_6", range(277,346), minor_versions("1.6" , 10)),
|
||||
("2_0", range(346,414), minor_versions("2.0", 8)),
|
||||
("2_1", range(414,475), minor_versions("2.1", 0)),
|
||||
("2_2", range(475,479), minor_versions("2.2", 0))
|
||||
("2_2", range(475,480), minor_versions("2.2", 0))
|
||||
]
|
||||
|
||||
####################################################################
|
||||
|
@ -30,8 +30,8 @@ import sys, os
|
||||
# find_token_backwards, is_in_inset, get_value, get_quoted_value, \
|
||||
# del_token, check_token, get_option_value
|
||||
|
||||
from lyx2lyx_tools import add_to_preamble#, insert_to_preamble, \
|
||||
# put_cmd_in_ert, lyx2latex, latex_length, revert_flex_inset, \
|
||||
from lyx2lyx_tools import add_to_preamble, put_cmd_in_ert#, \
|
||||
# insert_to_preamble, lyx2latex, latex_length, revert_flex_inset, \
|
||||
# revert_font_attrs, hex2ratio, str2bool
|
||||
|
||||
from parser_tools import find_token, find_token_backwards, find_re, \
|
||||
@ -328,11 +328,90 @@ mathtools_commands = ["xhookrightarrow", "xhookleftarrow", "xRightarrow", \
|
||||
"xLeftarrow", "xleftharpoondown", "xleftharpoonup", \
|
||||
"xleftrightarrow", "xLeftrightarrow", "xleftrightharpoons", \
|
||||
"xmapsto"]
|
||||
|
||||
def revert_xarrow(document):
|
||||
"remove use_package mathtools"
|
||||
revert_use_package(document, "mathtools", mathtools_commands, False)
|
||||
|
||||
|
||||
def revert_beamer_lemma(document):
|
||||
" Reverts beamer lemma layout to ERT "
|
||||
|
||||
beamer_classes = ["beamer", "article-beamer", "scrarticle-beamer"]
|
||||
if document.textclass not in beamer_classes:
|
||||
return
|
||||
|
||||
consecutive = False
|
||||
i = 0
|
||||
while True:
|
||||
i = find_token(document.body, "\\begin_layout Lemma", 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 Lemma layout")
|
||||
i += 1
|
||||
continue
|
||||
arg1 = find_token(document.body, "\\begin_inset Argument 1", i, j)
|
||||
endarg1 = find_end_of_inset(document.body, arg1)
|
||||
arg2 = find_token(document.body, "\\begin_inset Argument 2", i, j)
|
||||
endarg2 = find_end_of_inset(document.body, arg2)
|
||||
subst1 = []
|
||||
subst2 = []
|
||||
if arg1 != -1:
|
||||
beginPlain1 = find_token(document.body, "\\begin_layout Plain Layout", arg1, endarg1)
|
||||
if beginPlain1 == -1:
|
||||
document.warning("Malformed LyX document: Can't find arg1 plain Layout")
|
||||
i += 1
|
||||
continue
|
||||
endPlain1 = find_end_of_inset(document.body, beginPlain1)
|
||||
content1 = document.body[beginPlain1 + 1 : endPlain1 - 2]
|
||||
subst1 = put_cmd_in_ert("<") + content1 + put_cmd_in_ert(">")
|
||||
if arg2 != -1:
|
||||
beginPlain2 = find_token(document.body, "\\begin_layout Plain Layout", arg2, endarg2)
|
||||
if beginPlain2 == -1:
|
||||
document.warning("Malformed LyX document: Can't find arg2 plain Layout")
|
||||
i += 1
|
||||
continue
|
||||
endPlain2 = find_end_of_inset(document.body, beginPlain2)
|
||||
content2 = document.body[beginPlain2 + 1 : endPlain2 - 2]
|
||||
subst2 = put_cmd_in_ert("[") + content2 + put_cmd_in_ert("]")
|
||||
|
||||
# remove Arg insets
|
||||
if arg1 < arg2:
|
||||
del document.body[arg2 : endarg2 + 1]
|
||||
if arg1 != -1:
|
||||
del document.body[arg1 : endarg1 + 1]
|
||||
if arg2 < arg1:
|
||||
del document.body[arg1 : endarg1 + 1]
|
||||
if arg2 != -1:
|
||||
del document.body[arg2 : endarg2 + 1]
|
||||
|
||||
# index of end layout has probably changed
|
||||
j = find_end_of_layout(document.body, i)
|
||||
if j == -1:
|
||||
document.warning("Malformed LyX document: Can't find end of Lemma layout")
|
||||
i += 1
|
||||
continue
|
||||
|
||||
begcmd = []
|
||||
|
||||
# if this is not a consecutive env, add start command
|
||||
if not consecutive:
|
||||
begcmd = put_cmd_in_ert("\\begin{lemma}")
|
||||
|
||||
# has this a consecutive lemma?
|
||||
consecutive = document.body[j + 2] == "\\begin_layout Lemma"
|
||||
|
||||
# if this is not followed by a consecutive env, add end command
|
||||
if not consecutive:
|
||||
document.body[j : j + 1] = put_cmd_in_ert("\\end{lemma}") + ["\\end_layout"]
|
||||
|
||||
document.body[i : i + 1] = ["\\begin_layout Standard", ""] + begcmd + subst1 + subst2
|
||||
|
||||
i = j
|
||||
|
||||
|
||||
##
|
||||
# Conversion hub
|
||||
#
|
||||
@ -345,10 +424,12 @@ convert = [
|
||||
# want to hardcode amsmath off.
|
||||
[476, []],
|
||||
[477, []],
|
||||
[478, []]
|
||||
[478, []],
|
||||
[479, []]
|
||||
]
|
||||
|
||||
revert = [
|
||||
[478, [revert_beamer_lemma]],
|
||||
[477, [revert_xarrow]],
|
||||
[476, [revert_swissgerman]],
|
||||
[475, [revert_smash]],
|
||||
|
@ -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 478 // uwestoehr: mathtools' x***arrow commands
|
||||
#define LYX_FORMAT_TEX2LYX 478
|
||||
#define LYX_FORMAT_LYX 479 // spitz: beamer Lemma layout
|
||||
#define LYX_FORMAT_TEX2LYX 479
|
||||
|
||||
#if LYX_FORMAT_TEX2LYX != LYX_FORMAT_LYX
|
||||
#ifndef _MSC_VER
|
||||
|
Loading…
Reference in New Issue
Block a user