mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-22 13:18:28 +00:00
- text.cpp: - fix tex2lyx parsing of verbatim environments
- 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
This commit is contained in:
parent
c9892a3a3e
commit
df95041141
@ -481,6 +481,30 @@ string const Parser::verbatimEnvironment(string const & name)
|
||||
}
|
||||
|
||||
|
||||
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();
|
||||
|
@ -196,6 +196,12 @@ public:
|
||||
* 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.
|
||||
|
@ -293,10 +293,11 @@ verbatim:
|
||||
verbat im % $ 02/19/12
|
||||
hjkh
|
||||
jkh \ blah
|
||||
atesta
|
||||
\begin{centering}
|
||||
|
||||
|
||||
zzz
|
||||
\end{raggedleft}
|
||||
|
||||
\end{verbatim}
|
||||
and bibliography:
|
||||
|
@ -1344,8 +1344,8 @@ void parse_environment(Parser & p, ostream & os, bool outer,
|
||||
}
|
||||
|
||||
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 == '\\')
|
||||
|
Loading…
Reference in New Issue
Block a user