>>>>> "Juergen" == Juergen Spitzmueller <[EMAIL PROTECTED]> writes:
>> Ha! I knew the question would eventually arise... The problem is >> that ideally, we do not want to detect the characters around the >> inset, but the latex output around the inset. It is especially >> difficult to detect what is going to be output later. Juergen> OK, I'm beginning to understand the problem. Thanks for the Juergen> explanation. Here is a clean way to make this work, and more: We need to define our own variant of an ostream, that has knowledge of how TeX works. It would be a normal ostream with the following additional opeartions, implemented either as member functions or iomanip thingies (I don't care). The names I propose are bogus. - macrowoargs(): this is to be used to indicated that you have output a macro without args with a alphabetical name, like "\foo". Action: just set a flag When the next character is given, the flag requires to take the following action: * c == ' ': output "{}" before c * c alphabetical: output ' ' before c * otherwise, just output c The flag is then reset - unwantedligature(string liglist): this is to be used to indicate that the latest character may produce an unwanted ligature with any of the characters in liglist. Action: remember liglist When the next character is given, if it is in liglist, output \textcompwordmark{} before it and reset liglist. - breakline(): This allows to break lines without fearing to add a paragraph break. This can simplify a lot of code and improve output quality. Action: output a \n if and only if we are not at the beginning of the line. - breakpar(): this allows to obtain a paragraph break without adding to many empty lines. Action: output \n\n if not at the beginning of line; \n if at beginning of line but not beginning of paragraph; nothing otherwise. - other features may be automatic wrapping of lines and automaic texrow accounting (or whatever scheme Lars wants to implement). Those two mean a big simplification of code. Note that implementing this `latexostream' can begin with any one of the features enumerated above, since they do not depend on each other. Basically, the big work is to write the class (probably easy, but I do not know ostream interface well enough to know which method(s) should be reimplemented) and change all of our latex() methods to take a latexostream as argument instead of std::ostream. After this is done, the changes can be done gradually. Do this look like a plan? Now, we only have to find someone to implement it :) JMarc