Moved ref-index generation to DOM post-pass

* When I last fixed Cite in commit 7fdfd973, I didn't take it
  all the way through. I was assigning ref indexes in the
  async pipeline which is incorrect since ref-tokens and
  references-tokens should be processed in the same order
  as they show up in the input.

* I now moved ref-index assignment to the DOM post processor
  phase where they always belonged.

* Fixed references and cite reset functions to only reset a
  specific group, if necessary.

* Pipelines processing template transclusions should propagate
  the extension tag if the transclusion showed up in the context of
  extension source so that any extension-specific constraints are
  respected. (Ex: ref-tags in reference-extension context are handled
  differently -- and this should continue to be true even when the
  tags show up via transcluded content)

* These fixes were tested on the following snippet from 7fdfd973.
  Where this snippet was generating buggy output earlier, it is now
  being handled correctly.

---------------------------
X1<ref name="x" /> X2<ref name="x" />
<references>
<ref name="x">x</ref>
</references>

Y<ref name="y">{{echo|y}}</ref>
Z<ref name="z" />
<references>
{{echo|<ref name="z">z</ref>}}
</references>

A<ref name="a">a</ref>
B<ref name="b" />
<references>
{{echo|<ref name="b">b</ref>}}
</references>

C<ref name="c">c</ref>
D<ref name="d" />
<references>
<ref name="d">{{echo|d}}</ref>
</references>
---------------------------
X1<ref name="x" /> X2<ref name="x" />

Change-Id: I838d188c90b526878a72e4baf1e54cac644aadfc
Merge "Moved ref-index generation to DOM post-pass"