]> git.lyx.org Git - features.git/commitdiff
support for verbatim: step 2: tex2lyx support
authorUwe Stöhr <uwestoehr@web.de>
Mon, 20 Feb 2012 23:38:13 +0000 (23:38 +0000)
committerUwe Stöhr <uwestoehr@web.de>
Mon, 20 Feb 2012 23:38:13 +0000 (23:38 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@40785 a592a061-630c-0410-9148-cb99ea01b6c8

src/tex2lyx/text.cpp
src/version.h

index 4f834f2baae13af73f2107662d7484f0530e2c44..e57784fc0782f7963716993b14b0be2076528ef1 100644 (file)
@@ -1343,6 +1343,29 @@ void parse_environment(Parser & p, ostream & os, bool outer,
                preamble.registerAutomaticallyLoadedPackage("verbatim");
        }
 
+       else if (name == "verbatim") {
+               eat_whitespace(p, os, parent_context, false);
+               os << "\n\\begin_layout Verbatim\n";
+               string const s = p.verbatimEnvironment("verbatim");
+               string::const_iterator it2 = s.begin();
+               for (string::const_iterator it = s.begin(), et = s.end(); it != et; ++it) {
+                       if (*it == '\n') {
+                               it2 = it + 1;
+                               // avoid adding an empty paragraph at the end
+                               // if there are 2 consecutive spaces at the end ignore it
+                               // because LyX will re-add a \n
+                               if ((it + 1 != et) && (it + 2 != et || *it2 != '\n'))
+                                       os << "\n\\end_layout\n\\begin_layout Verbatim\n";
+                       } else
+                               os << *it;
+               }
+               os << "\n\\end_layout\n\n";
+               p.skip_spaces();
+               skip_braces(p); // eat {} that might by set by LyX behind comments
+               // reset to Standard layout
+               os << "\n\\begin_layout Standard\n";
+       }
+
        else if (name == "lyxgreyedout") {
                eat_whitespace(p, os, parent_context, false);
                parent_context.check_layout(os);
index b9bc0da5d595340670af62944c2dec145527c3e5..9bd5a56aff1f5ada9055e223fa061b529d7298e0 100644 (file)
@@ -31,7 +31,7 @@ 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 426 // uwestoehr: support for verbatim
-#define LYX_FORMAT_TEX2LYX 425 // uwestoehr: support for the package cancel
+#define LYX_FORMAT_TEX2LYX 426 // uwestoehr: support for verbatim
 
 #if LYX_FORMAT_FOR_TEX2LYX != LYX_FORMAT_FOR_LYX
 #warning "tex2lyx produces an out of date file format."