From 5de43f24fb61e9452b2bbd367b0187e7e3ca8c82 Mon Sep 17 00:00:00 2001 From: Subramanya Sastry Date: Thu, 13 Jun 2013 11:27:27 -0500 Subject: [PATCH] Start aligning Parsoid cite with PHP cite behavior some more * Nested ref tags are not supported anymore. * Turned off pre and p-wrap handlers on ref content since the native cite extension seems to not do any of this on ref content. * No change in parser test results (because there are no tests yet). Other cleanup: * Removed the 'inBlockToken' hack from Cite since this is not necessary anymore. TODO: The use of this flag in TemplateHandler may not be needed either. Verify and get rid of it. * Leading whitespace in ref-content is still removed but this may not be strictly necessary. Change-Id: I3406236032abe36099a1e420f443277a95fe597b --- js/lib/ext.Cite.js | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/js/lib/ext.Cite.js b/js/lib/ext.Cite.js index 30390178f..646b1d54f 100644 --- a/js/lib/ext.Cite.js +++ b/js/lib/ext.Cite.js @@ -20,14 +20,17 @@ function processExtSource(manager, extToken, opts) { tagWidths = extToken.dataAttribs.tagWidths, content = extSrc.substring(tagWidths[0], extSrc.length - tagWidths[1]); + // FIXME: SSS: This stripping maybe be unecessary after all. + // // FIXME: Should this be specific to the extension + // // or is it okay to do this unconditionally for all? // Right now, this code is run only for ref and references, // so not a real problem, but if this is used on other extensions, // requires addressing. // - // Strip white-space only lines - var wsMatch = content.match(/^((?:\s*\n)?)((?:.|\n)*)$/), + // Strip all leading white-space + var wsMatch = content.match(/^(\s*)((?:.|\n)*)$/), leadingWS = wsMatch[1]; // Update content to normalized form @@ -43,10 +46,7 @@ function processExtSource(manager, extToken, opts) { var pipeline = manager.pipeFactory.getPipeline( opts.pipelineType, Util.extendProps({}, opts.pipelineOpts, { - wrapTemplates: true, - // SSS FIXME: Doesn't seem right. - // Should this be the default in all cases? - inBlockToken: true + wrapTemplates: true }) ); @@ -91,6 +91,11 @@ Ref.prototype.reset = function() { }; * Handle ref tokens */ Ref.prototype.handleRef = function ( manager, pipelineOpts, refTok, cb ) { + // Nested tags are not supported + if (pipelineOpts.extTag === "ref") { + cb({ tokens: [refTok.getAttribute("source")] }); + return; + } var inReferencesExt = pipelineOpts.extTag === "references", refOpts = $.extend({ name: null, group: null }, Util.KVtoHash(refTok.getAttribute("options"))), @@ -191,12 +196,7 @@ RefGroup.prototype.renderLine = function(refsList, ref) { }); li.innerHTML = ref.content; - // If ref-content has block nodes, wrap it in a div, else in a span - var contentNode = ownerDoc.createElement(DU.hasBlockContent(li) ? 'div' : 'span'); - - // Move all children from li to contentNode - DU.migrateChildren(li, contentNode); - li.appendChild(contentNode); + var contentNode = li.firstChild; // 'mw:referencedBy' span wrapper var span = ownerDoc.createElement('span');