Perfect timing! I have about 200 Google Documents that I've always planned to move over to a repository on Github. The only thing holding me back was the poor .txt exports of Google Documents.
Wow. I was looking into Google Apps scripts earlier and dismissed it because of lacking support across Google Docs products.<p>Seems like things have improved lately. I might look into this again.
Google Apps script proved to be extremley useful recently when I created a small menu item that created Calendar events from a spreadsheet. Took a lunch break and 30 lines of JS to make a really efficient enterprisey interface to make large amounts of events. You can even send invites with the API!
I have tried this with several documents. No luck. I get "TypeError: Cannot call method "getActiveSection" of null." Same when I select something or not.