Am Samstag, 19. August 2006 20:28 schrieb Jean-Marc Lasgouttes: > This approach allows to remove all the hardcoded LyX strings that we > had, which is really a good thing. OTOH, it is quite heuristic and > probably fragile. It may be that the real-world use of LyX is outside > of what this algorithm can understand.
I would not worry about that too much until we get a bug report: People who mess with the generated .tex file and add stuff inside the LyX section are also able to move it further down for tex2lyx, or to remove all LyX generated stuff by hand before running tex2lyx. > One possibility would be to add a flag to disable this 'smart' checking. That would probably be good. And maybe a message "Ignoring LyX generated preamble ..." where the ignored stuff appears. > The only real bug I am aware of is that there is no mark in the > LaTeX/LyX format indicating the end of the user preamble. This is why > we always have a final \makeatother at the end of preamble. That is not the only @-related problem: Since LyX encloses the user-generated preamble in \makeatletter .. \makeatother we need to undo that for non-lyx files, i.e. enclose the output preamble in \makeatother .. \makeatletter. > I could > get rid of it since we track the catcode of @. Also, the special > language commands as defined in lib/language will be kept in preamble. > This breaks round trip with some languages. It should not be too difficult to ignore these if adding language.[Ch] to tex2lyx does not pull in too many other files. > Comments very welcome (Georg?). I am not planning to apply it to > 1.4.3, so don't worry too much yet. I think you should put it in, but instead of the many if (!in_lyx_preamble) tests I think I would prefer to create a special stream that could be switched between the real stream and a nullstream (or debug stream) and use that for h_preamble ()similar to what we du in support/debugstream. [Ch]. That would reduce the number of tests for in_lyx_preamble and would enable us to output the ignored stuff. Georg