jgm/pandoc — pull request #1377 by jkr (2014-06-28 08:17:22+00:00)
Title: New DocxContext Monad, and rewriting anchor ids

This pull request actually contains two changes:

1. The first is the introduction of a toplevel mond (DocxContext) which is a `ReaderT State`, and keeps some environment information, as well as recording some state. The second change (below) and future insertions (e.g. smart `Quoted` blocks) will need state, so I figured while I was at it, I might as well get rid of all the `ReaderOptions` and `Docx` arguments threading through the whole thing.

2. The second change was the initial motivation for the first. Word generates its own anchors for headers. These are sensible enough, but it makes for noisy markdown output. This rewrites header links as `uniqueIdent`-generated auto ids. The result is that the markdown writer suppresses them. Since users don't choose their own header anchors in word, no information is lost. (The only issue is that internal links to non-header anchors *might* be rewritten, if they are the same as a prior auto_id, and since those *are* written by the user, a bit of info is changed. But since such links aren't defined in pandoc, and are implemented by spans, that seems worth the risk.)

If you have any reservations about (2), I can resubmit with only the patches for (1). Though I would make a case for it.