support for verbatim: step 2: tex2lyx support

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@40785 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Uwe Stöhr 2012-02-20 23:38:13 +00:00
parent 6869d5205f
commit 05446b232f
2 changed files with 24 additions and 1 deletions

View 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);

View 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."