From: Uwe Stöhr Date: Mon, 20 Feb 2012 23:38:13 +0000 (+0000) Subject: support for verbatim: step 2: tex2lyx support X-Git-Tag: 2.1.0beta1~2033 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=05446b232f7716fecdea26af61b3fa1de0274c4d;p=features.git support for verbatim: step 2: tex2lyx support git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@40785 a592a061-630c-0410-9148-cb99ea01b6c8 --- diff --git a/src/tex2lyx/text.cpp b/src/tex2lyx/text.cpp index 4f834f2baa..e57784fc07 100644 --- a/src/tex2lyx/text.cpp +++ b/src/tex2lyx/text.cpp @@ -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); diff --git a/src/version.h b/src/version.h index b9bc0da5d5..9bd5a56aff 100644 --- a/src/version.h +++ b/src/version.h @@ -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."