Re: r40785 - in lyx-devel/trunk/src: . tex2lyx
Le 21/02/2012 00:38, uwesto...@lyx.org a écrit : Log: support for verbatim: step 2: tex2lyx support OK, so this is the thing I missed in my previous message, where I complained about missing verbatim support. + else if (name == verbatim) { Of course eventually, you do not want to do that, but rather find the layout and chack whether it has pass_thru==1. This will avoid further hardcoding for Verbatim and friends later. + eat_whitespace(p, os, parent_context, false); + os \n\\begin_layout Verbatim\n; I was about to complain that you are introducing the only explicit \begin_layout in the code, but I am wrong: you already did it for subfloat :( Please do not do that, and try to re use the Context stuff. Copy what is done in another place. + 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; Isn't it what the COntext class is done for? + // reset to Standard layout + os \n\\begin_layout Standard\n; Can't you see something is wrong when you introduce the only occurence of this string in tex2lyx code? I would really appreciate if you could rewrite this code to adhere to general tex2lyx tools (unless of course there is a reason to do it as you did). JMarc
Re: r40785 - in lyx-devel/trunk/src: . tex2lyx
Le 21/02/2012 00:38, uwesto...@lyx.org a écrit : Log: support for verbatim: step 2: tex2lyx support OK, so this is the thing I missed in my previous message, where I complained about missing verbatim support. + else if (name == "verbatim") { Of course eventually, you do not want to do that, but rather find the layout and chack whether it has pass_thru==1. This will avoid further hardcoding for Verbatim and friends later. + eat_whitespace(p, os, parent_context, false); + os<< "\n\\begin_layout Verbatim\n"; I was about to complain that you are introducing the only explicit \begin_layout in the code, but I am wrong: you already did it for subfloat :( Please do not do that, and try to re use the Context stuff. Copy what is done in another place. + 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"; Isn't it what the COntext class is done for? + // reset to Standard layout + os<< "\n\\begin_layout Standard\n"; Can't you see something is wrong when you introduce the only occurence of this string in tex2lyx code? I would really appreciate if you could rewrite this code to adhere to general tex2lyx tools (unless of course there is a reason to do it as you did). JMarc