Thanks to this great site I've learned that in LaTeX one should always use \[...\] pair for equations typesetting instead of $$...$$. Unfortunately it is too late: I already have a big text with this obsolete markup, split in multiple source files.
So what is the most elegant way of fixing this issue? I definitely need some preprocessor, and think that awk might be the tool of choice. What do you suggest?
$$doublets so far: Are they always/usually/rarely/never at the start and end of a line, or can they be anywhere? The less structure you've been using so far in handling your TeX input, the more elaborate the replacement rule will have to be. Please advise on this aspect of your typing habits. – Mico Aug 14 '14 at 15:08\prettymath{...}, which expands to\[...\], because this easier to detect the next time you want to change such mathematical markup – Aug 14 '14 at 15:08$$...$$style should not only gobbled away, but disappear completely, as if never been written at all – Aug 14 '14 at 15:20\[and all even ones with\]. – JPi Aug 14 '14 at 15:22$$ … $$which seems to behave worse than\[ … \]. But if it behaved correctly… what's wrong with that input? – Manuel Aug 14 '14 at 15:22$$...$$or the end code of it? It's not that easy – Aug 14 '14 at 15:28awkprogram - be sure to back up the original first. – Ethan Bolker Aug 14 '14 at 15:54awkwhich can be run from the command line on multiple files in one go - no need to open each one and apply the script separately. But this makes it essential that backups are created since you will lose the ability to revert if you simply replace files in place. – cfr Aug 14 '14 at 16:01$$is never part of a comment or, if it is, that it is always matched if so. As others have said, a general solution would require a sophisticated approach with a degree of complexity which is almost certainly unnecessary if the OP, like most people, has at least some formatting habits so at least some regularities in their source code. – cfr Aug 14 '14 at 16:05