OK, so we are going to support verbatim*
It's possible. If Uwe can post a complete patch, I can try doing it.
Here it is.
I don't think it is worth it to create a new function but I am not the
Python expert.
thanks and regards
Uwe
development/FORMAT | 5 ++
lib/layouts/stdlayouts.inc | 5 ++
lib/lyx2lyx/LyX.py | 2 +-
lib/lyx2lyx/lyx_2_2.py | 69 +++++++++++++++++++++-
src/tex2lyx/test/CJK.lyx.lyx | 2 +-
src/tex2lyx/test/CJKutf8.lyx.lyx | 2 +-
src/tex2lyx/test/DummyDocument.lyx.lyx | 2 +-
src/tex2lyx/test/Dummy~Document.lyx.lyx | 2 +-
src/tex2lyx/test/XeTeX-polyglossia.lyx.lyx | 2 +-
src/tex2lyx/test/algo2e.lyx.lyx | 2 +-
.../test/box-color-size-space-align.lyx.lyx | 2 +-
src/tex2lyx/test/test-insets-basic.lyx.lyx | 2 +-
src/tex2lyx/test/test-insets.lyx.lyx | 2 +-
src/tex2lyx/test/test-memoir.lyx.lyx | 2 +-
src/tex2lyx/test/test-modules.lyx.lyx | 2 +-
src/tex2lyx/test/test-refstyle-theorems.lyx.lyx | 2 +-
src/tex2lyx/test/test-scr.lyx.lyx | 2 +-
src/tex2lyx/test/test-structure.lyx.lyx | 2 +-
src/tex2lyx/test/test.lyx.lyx | 2 +-
src/tex2lyx/test/verbatim.lyx.lyx | 2 +-
src/version.h | 4 +-
21 files changed, 97 insertions(+), 20 deletions(-)
diff --git a/development/FORMAT b/development/FORMAT
index d41b8b5..c4d9b4d 100644
--- a/development/FORMAT
+++ b/development/FORMAT
@@ -11,6 +11,11 @@ adjustments are made to tex2lyx and bugs are fixed in
lyx2lyx.
-----------------------
+2015-11-24 Uwe Stöhr <uwesto...@web.de>
+ * Format incremented to 503
+ No new parameters.
+ Add environment "verbatim*" to stdlayouts.inc.
+
2015-11-18 Uwe Stöhr <uwesto...@web.de>
* Format incremented to 502
No new parameters.
diff --git a/lib/layouts/stdlayouts.inc b/lib/layouts/stdlayouts.inc
index f8367eb..4612cbd 100644
--- a/lib/layouts/stdlayouts.inc
+++ b/lib/layouts/stdlayouts.inc
@@ -95,3 +95,8 @@ Style Verbatim
HTMLItem p
End
+
+Style Verbatim*
+ CopyStyle Verbatim
+ LatexName verbatim*
+End
diff --git a/lib/lyx2lyx/LyX.py b/lib/lyx2lyx/LyX.py
index 6916184..d9ad0d6 100644
--- a/lib/lyx2lyx/LyX.py
+++ b/lib/lyx2lyx/LyX.py
@@ -85,7 +85,7 @@ format_relation = [("0_06", [200], minor_versions("0.6" ,
4)),
("1_6", list(range(277,346)), minor_versions("1.6" , 10)),
("2_0", list(range(346,414)), minor_versions("2.0" , 8)),
("2_1", list(range(414,475)), minor_versions("2.1" , 0)),
- ("2_2", list(range(475,503)), minor_versions("2.2" , 0))
+ ("2_2", list(range(475,504)), minor_versions("2.2" , 0))
]
####################################################################
diff --git a/lib/lyx2lyx/lyx_2_2.py b/lib/lyx2lyx/lyx_2_2.py
index e4d5387..d125cb1 100644
--- a/lib/lyx2lyx/lyx_2_2.py
+++ b/lib/lyx2lyx/lyx_2_2.py
@@ -2156,6 +2156,71 @@ def revert_solution(document):
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 open', '',
+ '\\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,
j)
+ if n == -1:
+ n = find_token(document.body, "\\begin_inset Newline
linebreak", l, j)
+ 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
+ # we deleted a line, so the end of the inset moved forward.
+ 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
#
@@ -2192,10 +2257,12 @@ convert = [
[499, [convert_moderncv]],
[500, []],
[501, [convert_fontsettings]],
- [502, []]
+ [502, []],
+ [503, []]
]
revert = [
+ [502, [revert_verbatim]],
[501, [revert_solution]],
[500, [revert_fontsettings]],
[499, [revert_achemso]],
diff --git a/src/tex2lyx/test/CJK.lyx.lyx b/src/tex2lyx/test/CJK.lyx.lyx
index 49c8dd5..46b602a 100644
--- a/src/tex2lyx/test/CJK.lyx.lyx
+++ b/src/tex2lyx/test/CJK.lyx.lyx
@@ -1,5 +1,5 @@
#LyX file created by tex2lyx 2.2
-\lyxformat 502
+\lyxformat 503
\begin_document
\begin_header
\origin roundtrip
diff --git a/src/tex2lyx/test/CJKutf8.lyx.lyx b/src/tex2lyx/test/CJKutf8.lyx.lyx
index 3da93b9..1db5855 100644
--- a/src/tex2lyx/test/CJKutf8.lyx.lyx
+++ b/src/tex2lyx/test/CJKutf8.lyx.lyx
@@ -1,5 +1,5 @@
#LyX file created by tex2lyx 2.2
-\lyxformat 502
+\lyxformat 503
\begin_document
\begin_header
\origin roundtrip
diff --git a/src/tex2lyx/test/DummyDocument.lyx.lyx
b/src/tex2lyx/test/DummyDocument.lyx.lyx
index 10c8258..effaf8b 100644
--- a/src/tex2lyx/test/DummyDocument.lyx.lyx
+++ b/src/tex2lyx/test/DummyDocument.lyx.lyx
@@ -1,5 +1,5 @@
#LyX file created by tex2lyx 2.2
-\lyxformat 502
+\lyxformat 503
\begin_document
\begin_header
\origin roundtrip
diff --git a/src/tex2lyx/test/Dummy~Document.lyx.lyx
b/src/tex2lyx/test/Dummy~Document.lyx.lyx
index b590ee9..cf3acba 100644
--- a/src/tex2lyx/test/Dummy~Document.lyx.lyx
+++ b/src/tex2lyx/test/Dummy~Document.lyx.lyx
@@ -1,5 +1,5 @@
#LyX file created by tex2lyx 2.2
-\lyxformat 502
+\lyxformat 503
\begin_document
\begin_header
\origin roundtrip
diff --git a/src/tex2lyx/test/XeTeX-polyglossia.lyx.lyx
b/src/tex2lyx/test/XeTeX-polyglossia.lyx.lyx
index f5fe7ea..6685a03 100644
--- a/src/tex2lyx/test/XeTeX-polyglossia.lyx.lyx
+++ b/src/tex2lyx/test/XeTeX-polyglossia.lyx.lyx
@@ -1,5 +1,5 @@
#LyX file created by tex2lyx 2.2
-\lyxformat 502
+\lyxformat 503
\begin_document
\begin_header
\origin roundtrip
diff --git a/src/tex2lyx/test/algo2e.lyx.lyx b/src/tex2lyx/test/algo2e.lyx.lyx
index 59fd2b0..9bbecd3 100644
--- a/src/tex2lyx/test/algo2e.lyx.lyx
+++ b/src/tex2lyx/test/algo2e.lyx.lyx
@@ -1,5 +1,5 @@
#LyX file created by tex2lyx 2.2
-\lyxformat 502
+\lyxformat 503
\begin_document
\begin_header
\origin roundtrip
diff --git a/src/tex2lyx/test/box-color-size-space-align.lyx.lyx
b/src/tex2lyx/test/box-color-size-space-align.lyx.lyx
index 6492204..5f56411 100644
--- a/src/tex2lyx/test/box-color-size-space-align.lyx.lyx
+++ b/src/tex2lyx/test/box-color-size-space-align.lyx.lyx
@@ -1,5 +1,5 @@
#LyX file created by tex2lyx 2.2
-\lyxformat 502
+\lyxformat 503
\begin_document
\begin_header
\origin roundtrip
diff --git a/src/tex2lyx/test/test-insets-basic.lyx.lyx
b/src/tex2lyx/test/test-insets-basic.lyx.lyx
index 984660a..366f7fb 100644
--- a/src/tex2lyx/test/test-insets-basic.lyx.lyx
+++ b/src/tex2lyx/test/test-insets-basic.lyx.lyx
@@ -1,5 +1,5 @@
#LyX file created by tex2lyx 2.2
-\lyxformat 502
+\lyxformat 503
\begin_document
\begin_header
\origin roundtrip
diff --git a/src/tex2lyx/test/test-insets.lyx.lyx
b/src/tex2lyx/test/test-insets.lyx.lyx
index d8bac4e..5b125a3 100644
--- a/src/tex2lyx/test/test-insets.lyx.lyx
+++ b/src/tex2lyx/test/test-insets.lyx.lyx
@@ -1,5 +1,5 @@
#LyX file created by tex2lyx 2.2
-\lyxformat 502
+\lyxformat 503
\begin_document
\begin_header
\origin roundtrip
diff --git a/src/tex2lyx/test/test-memoir.lyx.lyx
b/src/tex2lyx/test/test-memoir.lyx.lyx
index d05a2e2..9be82a5 100644
--- a/src/tex2lyx/test/test-memoir.lyx.lyx
+++ b/src/tex2lyx/test/test-memoir.lyx.lyx
@@ -1,5 +1,5 @@
#LyX file created by tex2lyx 2.2
-\lyxformat 502
+\lyxformat 503
\begin_document
\begin_header
\origin roundtrip
diff --git a/src/tex2lyx/test/test-modules.lyx.lyx
b/src/tex2lyx/test/test-modules.lyx.lyx
index 1a2dca7..fb49a44 100644
--- a/src/tex2lyx/test/test-modules.lyx.lyx
+++ b/src/tex2lyx/test/test-modules.lyx.lyx
@@ -1,5 +1,5 @@
#LyX file created by tex2lyx 2.2
-\lyxformat 502
+\lyxformat 503
\begin_document
\begin_header
\origin roundtrip
diff --git a/src/tex2lyx/test/test-refstyle-theorems.lyx.lyx
b/src/tex2lyx/test/test-refstyle-theorems.lyx.lyx
index 22e57d7..4a99ba8 100644
--- a/src/tex2lyx/test/test-refstyle-theorems.lyx.lyx
+++ b/src/tex2lyx/test/test-refstyle-theorems.lyx.lyx
@@ -1,5 +1,5 @@
#LyX file created by tex2lyx 2.2
-\lyxformat 502
+\lyxformat 503
\begin_document
\begin_header
\origin roundtrip
diff --git a/src/tex2lyx/test/test-scr.lyx.lyx
b/src/tex2lyx/test/test-scr.lyx.lyx
index a97578c..ac150e6 100644
--- a/src/tex2lyx/test/test-scr.lyx.lyx
+++ b/src/tex2lyx/test/test-scr.lyx.lyx
@@ -1,5 +1,5 @@
#LyX file created by tex2lyx 2.2
-\lyxformat 502
+\lyxformat 503
\begin_document
\begin_header
\origin roundtrip
diff --git a/src/tex2lyx/test/test-structure.lyx.lyx
b/src/tex2lyx/test/test-structure.lyx.lyx
index 2f9c095..d167f37 100644
--- a/src/tex2lyx/test/test-structure.lyx.lyx
+++ b/src/tex2lyx/test/test-structure.lyx.lyx
@@ -1,5 +1,5 @@
#LyX file created by tex2lyx 2.2
-\lyxformat 502
+\lyxformat 503
\begin_document
\begin_header
\origin roundtrip
diff --git a/src/tex2lyx/test/test.lyx.lyx b/src/tex2lyx/test/test.lyx.lyx
index 68b2dc6..935bced 100644
--- a/src/tex2lyx/test/test.lyx.lyx
+++ b/src/tex2lyx/test/test.lyx.lyx
@@ -1,5 +1,5 @@
#LyX file created by tex2lyx 2.2
-\lyxformat 502
+\lyxformat 503
\begin_document
\begin_header
\origin roundtrip
diff --git a/src/tex2lyx/test/verbatim.lyx.lyx
b/src/tex2lyx/test/verbatim.lyx.lyx
index 3d1f60c..4a43049 100644
--- a/src/tex2lyx/test/verbatim.lyx.lyx
+++ b/src/tex2lyx/test/verbatim.lyx.lyx
@@ -1,5 +1,5 @@
#LyX file created by tex2lyx 2.2
-\lyxformat 502
+\lyxformat 503
\begin_document
\begin_header
\origin roundtrip
diff --git a/src/version.h b/src/version.h
index 0871b0a..fff8c5a 100644
--- a/src/version.h
+++ b/src/version.h
@@ -32,8 +32,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 502 // uwestoehr: new environment "solution" in theorems
-#define LYX_FORMAT_TEX2LYX 502
+#define LYX_FORMAT_LYX 503 // uwestoehr: support for verbatim* environment
+#define LYX_FORMAT_TEX2LYX 503
#if LYX_FORMAT_TEX2LYX != LYX_FORMAT_LYX
#ifndef _MSC_VER