Improve portability of build

* Extracted sed latex-to-xml transformations to perl script
* Replaced sed character classes with posix equivalents
* Specified locale LC_ALL=C to sort per CLL 3.1
* Replaced usage of non-standard grep -P
* HTML builds run on OS X (tested on 10.8.5)