Updates to cite to reflect spec for references and ref

* Updated references output DOM to match spec better.
* Also refactored some repetitive DOM code into helper functions.
* Turned on tpl encapsulation inside extensions.
* Verified output on the example in the spec and the example in
  commit 5e35a522.

Change-Id: I1b894759d2cd89b6453156e6b0246f6cc8f0d60b
Merge "Updates to cite to reflect spec for references and ref"