Back in the old days they wrote software which wrote documents (in fact the company I work for actually does this) and wrote software which parsed documents. If you need to interact with a document, you write an application which processes it and creates another document!
That neatly assumes that documents are data and not code.
That neatly assumes that documents are data and not code.