Jean-Marc Lasgouttes wrote:

> It looks good, except this bit that I do not like much:

Me neither. But if the goal is real roundtrip support, something like this
is needed. The problem is that lyx generates a newline at some places (like
before \end{qoute} etc. that does not correspond to a space in the lyx
file. If the requirements on the roundtrip support are less strict, one can
ignore the "spaces may be removed" case, and this function will become much
simpler. One has to keep in mind that in this case a lot of unnecessary
spaces are added also for non-lyx generated files. I tried to isolate the
ugly stuff in this function and keep the rest of the code clean.

> +         (next.cs() == "end" && (context.layout->latextype ==
> LATEX_ITEM_ENVIRONMENT ||
> +                                 context.layout->latextype ==
> LATEX_LIST_ENVIRONMENT ||
> +                                 active_environment() == "quotation" ||
> +                                 active_environment() == "quote" ||
> +                                 active_environment() == "verse" ||
> +                                 // LyX emits a newline before \end{lyxcode}.
> +                                 // This newline must be ignored,
> +                                 // otherwise LyX will add an additional protected 
> space.
> +                                 (active_environment() == "lyxcode" && curr.cat() ==
> catNewline))) ||
> 
> 
> What features are your trying to test for exactly? What is so special
> about quotation and verse?

They are environments that ignore spaces before the \end{...}. This is an
example of the "spaces may be removed" case. I am not so sure how to handle
that, therefore the following comment:
// Or should we make a negative list? The alignment environments like center
would be included

> If you want to test for lyxcode-like environments (we have also the
> Scrap environment in literate programming mode), the right way is to
> test something like context.layout->free_spacing.

Ok.

> Despite the comment above the function, I am not sure that I
> understand the logic.
> 
> Also, if there are cases where LyX' LaTeX output is weird, you may ask
> to change it rather than cope with it...

But this would not help for existing documents. The problem here is not
weird output, but different semantics of spaces in the lyx file format:
Between \begin_layout LyX-Code \end_layout a space means a "~" latexwise,
and outside a space means a space latexwise.


Georg

Reply via email to