mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-29 05:01:49 +00:00
support for verbatim: step 1: the layout and the lyx2lyx code,;fileformat change (next step is the beamer issue and last step tex2lyx support)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@40784 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
3018614da1
commit
6869d5205f
@ -11,6 +11,15 @@ adjustments are made to tex2lyx and bugs are fixed in lyx2lyx.
|
|||||||
|
|
||||||
-----------------------
|
-----------------------
|
||||||
|
|
||||||
|
2012-02-20 Uwe Stöhr <uwestoehr@web.de>
|
||||||
|
* Format incremented to 426 (r40784)
|
||||||
|
support for the verbatim environment
|
||||||
|
(added only a layout)
|
||||||
|
|
||||||
|
2012-01-23 Uwe Stöhr <uwestoehr@web.de>
|
||||||
|
* Format incremented to 425 (r40663)
|
||||||
|
support for the LaTeX-package cancel (fix bug 6819)
|
||||||
|
|
||||||
2012-01-09 Julien Rioux <jrioux@lyx.org>
|
2012-01-09 Julien Rioux <jrioux@lyx.org>
|
||||||
* Format incremented to 424 (r40592)
|
* Format incremented to 424 (r40592)
|
||||||
New buffer param \cite_engine_type to specify the type of
|
New buffer param \cite_engine_type to specify the type of
|
||||||
|
@ -71,6 +71,30 @@ Style Verse
|
|||||||
End
|
End
|
||||||
|
|
||||||
|
|
||||||
|
Style Verbatim
|
||||||
|
Category MainText
|
||||||
|
LatexType Environment
|
||||||
|
LatexName verbatim
|
||||||
|
NextNoIndent 1
|
||||||
|
ParbreakIsNewline 1
|
||||||
|
FreeSpacing 1
|
||||||
|
PassThru 1
|
||||||
|
NewLine 0
|
||||||
|
ParSkip 0.4
|
||||||
|
TopSep 0.7
|
||||||
|
BottomSep 0.7
|
||||||
|
ParSep 0.5
|
||||||
|
Align Block
|
||||||
|
AlignPossible Block
|
||||||
|
LabelType No_Label
|
||||||
|
Font
|
||||||
|
Family Typewriter
|
||||||
|
EndFont
|
||||||
|
HTMLTag <pre></pre>
|
||||||
|
HTMLItem p
|
||||||
|
End
|
||||||
|
|
||||||
|
|
||||||
Style --Separator--
|
Style --Separator--
|
||||||
Category MainText
|
Category MainText
|
||||||
KeepEmpty 1
|
KeepEmpty 1
|
||||||
|
@ -26,7 +26,8 @@ import sys, os
|
|||||||
# Uncomment only what you need to import, please.
|
# Uncomment only what you need to import, please.
|
||||||
|
|
||||||
from parser_tools import del_token, find_token, find_end_of, find_end_of_inset, \
|
from parser_tools import del_token, find_token, find_end_of, find_end_of_inset, \
|
||||||
find_re, get_option_value, get_value, get_quoted_value, set_option_value
|
find_end_of_layout, find_re, get_option_value, get_value, get_quoted_value, \
|
||||||
|
set_option_value
|
||||||
|
|
||||||
#from parser_tools import find_token, find_end_of, find_tokens, \
|
#from parser_tools import find_token, find_end_of, find_tokens, \
|
||||||
#find_token_exact, find_end_of_inset, find_end_of_layout, \
|
#find_token_exact, find_end_of_inset, find_end_of_layout, \
|
||||||
@ -471,6 +472,69 @@ def revert_cancel(document):
|
|||||||
i = j
|
i = j
|
||||||
|
|
||||||
|
|
||||||
|
def revert_verbatim(document):
|
||||||
|
" Revert verbatim einvironments completely to TeX-code. "
|
||||||
|
i = 0
|
||||||
|
consecutive = False
|
||||||
|
subst_end = ['\end_layout', '', '\\begin_layout Plain Layout',
|
||||||
|
'\end_layout', '',
|
||||||
|
'\\begin_layout Plain Layout', '', '',
|
||||||
|
'\\backslash', '',
|
||||||
|
'end{verbatim}',
|
||||||
|
'\\end_layout', '', '\\end_inset',
|
||||||
|
'', '', '\\end_layout']
|
||||||
|
subst_begin = ['\\begin_layout Standard', '\\noindent',
|
||||||
|
'\\begin_inset ERT', 'status collapsed', '',
|
||||||
|
'\\begin_layout Plain Layout', '', '', '\\backslash',
|
||||||
|
'begin{verbatim}',
|
||||||
|
'\\end_layout', '', '\\begin_layout Plain Layout', '']
|
||||||
|
while 1:
|
||||||
|
i = find_token(document.body, "\\begin_layout Verbatim", 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 Verbatim layout")
|
||||||
|
i += 1
|
||||||
|
continue
|
||||||
|
# delete all line breaks insets (there are no other insets)
|
||||||
|
l = i
|
||||||
|
while 1:
|
||||||
|
n = find_token(document.body, "\\begin_inset Newline newline", l)
|
||||||
|
if n == -1:
|
||||||
|
n = find_token(document.body, "\\begin_inset Newline linebreak", l)
|
||||||
|
if n == -1:
|
||||||
|
break
|
||||||
|
m = find_end_of_inset(document.body, n)
|
||||||
|
del(document.body[m:m+1])
|
||||||
|
document.body[n:n+1] = ['\end_layout', '', '\\begin_layout Plain Layout']
|
||||||
|
l += 1
|
||||||
|
j += 1
|
||||||
|
# consecutive verbatim environments need to be connected
|
||||||
|
k = find_token(document.body, "\\begin_layout Verbatim", j)
|
||||||
|
if k == j + 2 and consecutive == False:
|
||||||
|
consecutive = True
|
||||||
|
document.body[j:j+1] = ['\end_layout', '', '\\begin_layout Plain Layout']
|
||||||
|
document.body[i:i+1] = subst_begin
|
||||||
|
continue
|
||||||
|
if k == j + 2 and consecutive == True:
|
||||||
|
document.body[j:j+1] = ['\end_layout', '', '\\begin_layout Plain Layout']
|
||||||
|
del(document.body[i:i+1])
|
||||||
|
continue
|
||||||
|
if k != j + 2 and consecutive == True:
|
||||||
|
document.body[j:j+1] = subst_end
|
||||||
|
# the next paragraph must not be indented
|
||||||
|
document.body[j+19:j+19] = ['\\noindent']
|
||||||
|
del(document.body[i:i+1])
|
||||||
|
consecutive = False
|
||||||
|
continue
|
||||||
|
else:
|
||||||
|
document.body[j:j+1] = subst_end
|
||||||
|
# the next paragraph must not be indented
|
||||||
|
document.body[j+19:j+19] = ['\\noindent']
|
||||||
|
document.body[i:i+1] = subst_begin
|
||||||
|
|
||||||
|
|
||||||
##
|
##
|
||||||
# Conversion hub
|
# Conversion hub
|
||||||
#
|
#
|
||||||
@ -488,10 +552,12 @@ convert = [
|
|||||||
[422, [convert_use_packages]],
|
[422, [convert_use_packages]],
|
||||||
[423, [convert_use_mathtools]],
|
[423, [convert_use_mathtools]],
|
||||||
[424, [convert_cite_engine_type]],
|
[424, [convert_cite_engine_type]],
|
||||||
[425, []]
|
[425, []],
|
||||||
|
[426, []]
|
||||||
]
|
]
|
||||||
|
|
||||||
revert = [
|
revert = [
|
||||||
|
[425, [revert_verbatim]],
|
||||||
[424, [revert_cancel]],
|
[424, [revert_cancel]],
|
||||||
[423, [revert_cite_engine_type]],
|
[423, [revert_cite_engine_type]],
|
||||||
[422, [revert_use_mathtools]],
|
[422, [revert_use_mathtools]],
|
||||||
|
@ -30,7 +30,7 @@ extern char const * const lyx_version_info;
|
|||||||
|
|
||||||
// Do not remove the comment below, so we get merge conflict in
|
// Do not remove the comment below, so we get merge conflict in
|
||||||
// independent branches. Instead add your own.
|
// independent branches. Instead add your own.
|
||||||
#define LYX_FORMAT_LYX 425 // uwestoehr: support for the package cancel
|
#define LYX_FORMAT_LYX 426 // uwestoehr: support for verbatim
|
||||||
#define LYX_FORMAT_TEX2LYX 425 // uwestoehr: support for the package cancel
|
#define LYX_FORMAT_TEX2LYX 425 // uwestoehr: support for the package cancel
|
||||||
|
|
||||||
#if LYX_FORMAT_FOR_TEX2LYX != LYX_FORMAT_FOR_LYX
|
#if LYX_FORMAT_FOR_TEX2LYX != LYX_FORMAT_FOR_LYX
|
||||||
|
Loading…
Reference in New Issue
Block a user