(Bug 49555) Support nested refs

* After trying various hacks, came up with a relatively simple
  fix/hack to support nested refs.

  The fix looks for {{#tag:ref..}} and short-circuits full
  pipeline expansion and converts that to an extension tag
  in place.

* Tested with the following wikitext which parses and RTs correctly

A <ref name='foo' />
B {{#tag:ref|nested ref <ref>bar</ref> |name=foo}}
<references />

* Also tested on en:Fomitiporia_ellipsoidea from the bug report
  and verified correct parse and round tripping.

* Verified that the nested ref in <ref> foo <ref>bar</ref> </ref>
  continues to be parsed as plain text.

* No change in parser test results -- have to make another
  round of updates to parser tests.

Change-Id: I43bb8b710bd10a9ddbea27818ff8aaf97ddb3fdc
This commit is contained in:
Subramanya Sastry 2013-06-18 14:48:57 -05:00
parent 7d93200a91
commit 53bbcbb37e

View file

@ -92,7 +92,7 @@ Ref.prototype.reset = function() { };
*/
Ref.prototype.handleRef = function ( manager, pipelineOpts, refTok, cb ) {
// Nested <ref> tags are not supported
if (pipelineOpts.extTag === "ref") {
if (!pipelineOpts.inTagRef && pipelineOpts.extTag === "ref" && pipelineOpts.wrapTemplates) {
cb({ tokens: [refTok.getAttribute("source")] });
return;
}
@ -123,6 +123,7 @@ Ref.prototype.handleRef = function ( manager, pipelineOpts, refTok, cb ) {
// Full pipeline for processing ref-content
pipelineType: 'text/x-mediawiki/full',
pipelineOpts: {
inTagRef: refTok.getAttribute("inTagRef"),
extTag: "ref"
},
res: [],