From: Uwe Stöhr Date: Mon, 27 Feb 2012 00:55:57 +0000 (+0000) Subject: - text.cpp: escape backslashes in verbatim, fix a thinko X-Git-Tag: 2.1.0beta1~2020 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=8bca3e510f74511ed0d4d6123b00a7f00b556a94;p=features.git - text.cpp: escape backslashes in verbatim, fix a thinko - test-structure.tex: add verbatim testcase git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@40798 a592a061-630c-0410-9148-cb99ea01b6c8 --- diff --git a/src/tex2lyx/test/test-structure.tex b/src/tex2lyx/test/test-structure.tex index 6ca87694a8..ec61f6fc43 100644 --- a/src/tex2lyx/test/test-structure.tex +++ b/src/tex2lyx/test/test-structure.tex @@ -288,6 +288,17 @@ labelings: \item [label~2] second item \item [{$\left[\textrm{ }\right]^{x}$}] Label with space, math and ] in it \end{lyxlist} +verbatim: +\begin{verbatim} +verbat im % $ 02/19/12 +hjkh +jkh \ blah +atesta + + +zzz + +\end{verbatim} and bibliography: \begin{thebibliography}{9} \bibitem{FOO} Edward Bar. \emph{The Foo Book}. (1999) diff --git a/src/tex2lyx/text.cpp b/src/tex2lyx/text.cpp index e57784fc07..17e19486be 100644 --- a/src/tex2lyx/text.cpp +++ b/src/tex2lyx/text.cpp @@ -1344,19 +1344,20 @@ void parse_environment(Parser & p, ostream & os, bool outer, } 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') { + if (*it == '\\') + os << "\\backslash "; + else 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 + } else os << *it; } os << "\n\\end_layout\n\n";