Handle multiply-referenced ref-tags without duplicate ref-content.

* When named-ref-tags are used multiple times in a document, the
  Cite.onReferences function was outputting the ref-content once
  for each use in the references section. While this is "harmless"
  for regular ref-content, when the ref-content has templates
  (ex: {[cite .. }}), that template content is duplicated several
  times -- this also means that template expansions seen in the
  output no longer has unique ids. Occasionally, this trips up
  DOM passes (template encapsulation) which make the reasonable
  assumption that template ids are unique. It introduced an
  infinite loop in the code that detects template range nestings
  and overlaps. This is not triggered always, but only in certain
  scenarios. en:Euphoria (Enrique Iglesias album) was a page that
  sent the parser into an infinite loop.

* Now fixed by outputting ref-content once.

* In addition, added an error-check in the DOM post-pass that might
  get stuck in an infinite loop to output an error message.

* No change in parser test results.

* en:Euphoria (Enrique Iglesias album) now parses and rts without
  getting stuck in an infinite loop.  Possibly other pages as well.

Change-Id: I81a055999eefe3ca36dfb8a9cda3fee538ae6c65
Merge "Handle multiply-referenced ref-tags without duplicate ref-content."