unitedstates/citation — pull request #70 by konklone (2014-05-06 21:57:11+00:00)
Title: Refactor of citation extraction

This removes [XRegExp](http://xregexp.com/) from Citation entirely, and refactors the main extraction/replacement work to use a combined regex that knows which matches came from which citator.

Some ramifications:

* This removes named captures from all citator regexes. This makes the regexes sort of both more and less readable at the same time.
* All citation patterns now have an associated `fields` array that gives a name to every capture, *in the order they appear in the regex*. This array is used for two things:
* To know how many captures a given regex expects, so that indexes of each pattern can be ascertained before combining each active pattern into a master regex. This is required for bookkeeping these indexes.
* To do a quick transformation on captured data before passing them onto a pattern's `processor`, which can keep the same method signature it used to when we were using named captures. From the `processor`'s point of view, it's getting the same object of named captures it used to before this PR.
* Find and replace continues to function as normal, and it's still not obvious how we'd handle replacement for judicial cites from walverine. I opened https://github.com/adelevie/walverine/issues/10 to discuss that.

And pleasingly:

* The library is now much smaller when browserified! The min/gz'd version went from 52K to 30K, and the min'd version went from 200K to 144K. Most of the remaining bulk is now walverine, so the next step is have `gulp` produce a walverine-less version for those who don't need it, tracked in https://github.com/unitedstates/citation/issues/69.
* The library is now much faster! The tests are operating at something like double speed. Terrific-o.

The next step is to start making replacement work better when filters and other options are added, to add replacement where possible for the CLI and the HTTP version, and to resolve the other issues tracked in #26.