A client asked me if I knew of a way to remove the spurious line feeds in a text that you copy from, say, a PDF into the textarea editing box for the wiki. The problem, which you may have seen, is that highlighting a couple of paragraphs of text in the source document and then pasting them into a textarea in your browser will end up with funny, unintended line breaks.
For example, copy the first paragraph of the second section of this paper and then pasting it into a textarea using Firefox gives this result:
The text should be divided into sections, each with a separate heading and consecutive numbering. Note, how- ever, that single secondary, tertiary, and quaternary sec- tions remain unnumbered. Each section heading should be placed on a separate line using the appropriate L A T E X com- mands. For more detailed information on different sections and their formatting see the Authors’ Guide.
After looking around a bit, I found lots of people talking about pasting problems, but no one offering a solution that would work in the browser instead of just on one particular web page.
After reading about JavaScript and pasting, poking around in the Firefox addons, I figured I knew enough to address the problem with GreaseMonkey.
jsfiddle provided a nice REPL for testing my code and it wasn’t too hard after that to put this together in GreaseMonkey and upload the result to UserScripts.org (after I recovered the password to my long-dormant account).
So, after all that, here is the result of the previous paste:
The text should be divided into sections, each with a separate heading and consecutive numbering. Note, however, that single secondary, tertiary, and quaternary sections remain unnumbered. Each section heading should be placed on a separate line using the appropriate L A T E X commands. For more detailed information on different sections and their formatting see the Authors’ Guide.
Hopefully this will be useful to others.