- Parser.cpp: - new function to parse verbatim environments
- test/test-structure.tex: updated example
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@40850
a592a061-630c-0410-9148-
cb99ea01b6c8
}
+string const Parser::plainEnvironment(string const & name)
+{
+ if (!good())
+ return string();
+
+ ostringstream os;
+ for (Token t = get_token(); good(); t = get_token()) {
+ if (t.cat() == catBegin) {
+ putback();
+ os << '{' << verbatim_item() << '}';
+ } else if (t.asInput() == "\\end") {
+ string const end = getArg('{', '}');
+ if (end == name)
+ return os.str();
+ else
+ os << "\\end{" << end << '}';
+ } else
+ os << t.asInput();
+ }
+ cerr << "unexpected end of input" << endl;
+ return os.str();
+}
+
+
void Parser::tokenize_one()
{
catInit();
* is parsed but not returned.
*/
std::string const verbatimEnvironment(std::string const & name);
+ /*
+ * The same as verbatimEnvironment(std::string const & name) but
+ * \begin and \end commands inside the name environment are not parsed.
+ * This function is designed to parse verbatim environments.
+ */
+ std::string const plainEnvironment(std::string const & name);
/*!
* Returns the character of the current token and increments
* the token position.
verbat im % $ 02/19/12
hjkh
jkh \ blah
-atesta
+\begin{centering}
zzz
+\end{raggedleft}
\end{verbatim}
and bibliography:
}
else if (name == "verbatim") {
- os << "\n\\begin_layout Verbatim\n";
- string const s = p.verbatimEnvironment("verbatim");
+ os << "\n\\end_layout\n\n\\begin_layout Verbatim\n";
+ string const s = p.plainEnvironment("verbatim");
string::const_iterator it2 = s.begin();
for (string::const_iterator it = s.begin(), et = s.end(); it != et; ++it) {
if (*it == '\\')