In the intro to programming course I took at University the final assignment we had was something similar (Format Text) we had to write a program that when given three arguments (a text file to read from, an int specifying the characters per line and an int specifying the lines per page) would output the text file formatted correctly breaking on words etc.<p>From memory there were other requirements indenting the first word of each paragraph things like that.<p>As the article alludes to it was a surprisingly complex problem - we also had to worry about memory allocation as we were using C. I remember I was quite proud when I got the sample text (which was a few paragraphs from &quot;The Hobbit&quot;) to render correctly.<p>I&#x27;ve never thought about writing a code formatter I just trust emacs to format my code for me. I&#x27;d be interested in digging up my old code and seeing how easily I could modify it to operate on source code.