Am 21.02.2012 22:09, schrieb Georg Baum:
this is far more complicated than what you implemented. Believe me, if it
was that easy I would have added verbatim support a long time ago.
I think we could not support verbatim before as we had no feature to convert to.
+ else if (name == "verbatim") {
+ eat_whitespace(p, os, parent_context, false);
eat_whitespace is wrong here.
Sorry. Fixed now.
+ os<< "\n\\begin_layout Verbatim\n";
+ string const s = p.verbatimEnvironment("verbatim");
The environment nesting in verbatimEnvironment() is not suitable for
verbatim environments. Instead, you need to implement exactly the same
algorithm as used by TeX for detecting the environment end. In order to do
this, you probably also need to temporarily change the cat codes in the
parser.
Why not. I played around with all constructs that came into my mind and verbatimEnvironment does
what I want.
Can you give ma an example TeX code where my code fails?
"\n\\end_layout\n\\begin_layout Verbatim\n";
+ } else
+ os<< *it;
This test for consecutive space looks wrong. In a verbatim block you should
be able to write as many consecutive spaces (even at the end), and LyX
should output them as is.
But it does. I only had to add this special code for the case it is at the end
because of
http://www.lyx.org/trac/ticket/8049
If this special treatment is really needed the
verbatim implementation in LyX looks wrong.
What exactly?
+ os<< "\n\\end_layout\n\n";
+ p.skip_spaces();
+ skip_braces(p); // eat {} that might by set by LyX
behind comments
skip_braces() is wrong.
Why? We are now behind \end{verbatim} so if there are braces we can eat then,
no?
Note that you do not escape backslashes, but this is needed in the .lyx file
format.
Thanks for the hint. I did this now.
Please add a test case as well.
Also done now.
regards Uwe