Reset the Cite extension state with the end token

This should hopefully fix some spurious semantic diffs that are purely based
on ref numbering, which changes if the references are not reset.

Change-Id: I37b1f4cfe69538e1c5ccc81fdad3084c01151700
This commit is contained in:
Gabriel Wicke 2012-11-16 10:03:01 -08:00
parent 3144feec25
commit f4841b86ab

View file

@ -13,7 +13,7 @@ var TokenCollector = require( './ext.util.TokenCollector.js' ).TokenCollector,
function Cite ( manager, options ) {
this.manager = manager;
this.options = options;
this.refGroups = {};
this.reset();
// Set up the collector for ref sections
new TokenCollector(
manager,
@ -26,8 +26,17 @@ function Cite ( manager, options ) {
// And register for references tags
manager.addTransform( this.onReferences.bind(this), "Cite:onReferences",
this.referencesRank, 'tag', 'references' );
// And register for cleanup
manager.addTransform( this.reset.bind(this), "Cite:reset",
this.referencesRank, 'end' );
}
Cite.prototype.reset = function ( token ) {
this.refGroups = {};
return { token: token };
};
// Cite should be the first thing to run in pahse 3 so the <ref>-</ref>
// content tokens are pulled out of the token stream and dont pollute
// the main token stream with any unbalanced tags/pres and the like.