Ref in references support

When we encounter a ref tag inside the mw-data of a references
tag, we pass it off to the converter and store it as nested data.

In toDomElements we convert any nested children and write them
back to mw-data if changed.

As refs in references are invisible we exclude them when generating
the references list in ve.ce.MWReferenceListNode.

Bug: 51741
Change-Id: I31d06616849a00449df0fc77f3b33e46207cdc7f
This commit is contained in:
Ed Sanders 2013-07-25 18:11:50 +01:00
parent faeb27c477
commit 6d921067d7
3 changed files with 179 additions and 102 deletions

View file

@ -149,12 +149,27 @@ ve.ce.MWReferenceListNode.prototype.update = function () {
index = nodes.indexOrder[i]; index = nodes.indexOrder[i];
firstNode = nodes.firstNodes[index]; firstNode = nodes.firstNodes[index];
$li = $( '<li>' );
key = internalList.keys[index]; key = internalList.keys[index];
keyedNodes = nodes.keyedNodes[key] || []; keyedNodes = nodes.keyedNodes[key] || [];
for ( j = 0, jLen = keyedNodes.length; j < jLen; j++ ) { // Exclude references defined inside the reference list node
if ( keyedNodes.length > 1 ) { /*jshint loopfunc:true */
keyedNodes = keyedNodes.filter( function ( node ) {
while ( ( node = node.parent ) && node !== null ) {
if ( node instanceof ve.dm.MWReferenceListNode ) {
return false;
}
}
return true;
} );
if ( !keyedNodes.length ) {
continue;
}
$li = $( '<li>' );
if ( keyedNodes.length > 1 ) {
for ( j = 0, jLen = keyedNodes.length; j < jLen; j++ ) {
$li.append( $li.append(
$( '<sup>' ).append( $( '<sup>' ).append(
$( '<a>' ).text( ( i + 1 ) + '.' + j ) $( '<a>' ).text( ( i + 1 ) + '.' + j )

View file

@ -9,37 +9,40 @@
* DataModel MediaWiki reference list node. * DataModel MediaWiki reference list node.
* *
* @class * @class
* @extends ve.dm.LeafNode * @extends ve.dm.BranchNode
* @constructor * @constructor
* @param {number} [length] Length of content data in document; ignored and overridden to 0 * @param {number} [length] Length of content data in document; ignored and overridden to 0
* @param {Object} [element] Reference to element in linear model * @param {Object} [element] Reference to element in linear model
*/ */
ve.dm.MWReferenceListNode = function VeDmMWReferenceListNode( length, element ) { ve.dm.MWReferenceListNode = function VeDmMWReferenceListNode( length, element ) {
// Parent constructor // Parent constructor
ve.dm.LeafNode.call( this, 0, element ); ve.dm.BranchNode.call( this, 0, element );
}; };
/* Inheritance */ /* Inheritance */
ve.inheritClass( ve.dm.MWReferenceListNode, ve.dm.LeafNode ); ve.inheritClass( ve.dm.MWReferenceListNode, ve.dm.BranchNode );
/* Static members */ /* Static members */
ve.dm.MWReferenceListNode.static.name = 'mwReferenceList'; ve.dm.MWReferenceListNode.static.name = 'mwReferenceList';
ve.dm.MWReferenceListNode.static.handlesOwnChildren = true;
ve.dm.MWReferenceListNode.static.matchTagNames = null; ve.dm.MWReferenceListNode.static.matchTagNames = null;
ve.dm.MWReferenceListNode.static.matchRdfaTypes = [ 'mw:Extension/references' ]; ve.dm.MWReferenceListNode.static.matchRdfaTypes = [ 'mw:Extension/references' ];
ve.dm.MWReferenceListNode.static.storeHtmlAttributes = false; ve.dm.MWReferenceListNode.static.storeHtmlAttributes = false;
ve.dm.MWReferenceListNode.static.toDataElement = function ( domElements ) { ve.dm.MWReferenceListNode.static.toDataElement = function ( domElements, converter ) {
var mwDataJSON = domElements[0].getAttribute( 'data-mw' ), var referenceListData, $contents, contentsData,
mwDataJSON = domElements[0].getAttribute( 'data-mw' ),
mwData = mwDataJSON ? JSON.parse( mwDataJSON ) : {}, mwData = mwDataJSON ? JSON.parse( mwDataJSON ) : {},
refGroup = mwData.attrs && mwData.attrs.group || '', refGroup = mwData.attrs && mwData.attrs.group || '',
listGroup = 'mwReference/' + refGroup; listGroup = 'mwReference/' + refGroup;
return { referenceListData = {
'type': this.name, 'type': this.name,
'attributes': { 'attributes': {
'mw': mwData, 'mw': mwData,
@ -50,11 +53,23 @@ ve.dm.MWReferenceListNode.static.toDataElement = function ( domElements ) {
'listGroup': listGroup 'listGroup': listGroup
} }
}; };
if ( mwData.body && mwData.body.html ) {
$contents = $( '<div>' ).append( mwData.body.html );
contentsData = converter.getDataFromDomRecursionClean( $contents[0] );
return [ referenceListData ].
concat( contentsData ).
concat( [ { 'type': '/' + this.name } ] );
} else {
return referenceListData;
}
}; };
ve.dm.MWReferenceListNode.static.toDomElements = function ( dataElement, doc ) { ve.dm.MWReferenceListNode.static.toDomElements = function ( data, doc, converter ) {
var el, els, mwData, originalMw, var el, els, mwData, originalMw, wrapper, contentsHtml, originalHtml,
attribs = dataElement.attributes; dataElement = data[0],
attribs = dataElement.attributes,
contentsData = data.slice( 1, -1 );
if ( attribs.domElements ) { if ( attribs.domElements ) {
// If there's more than 1 element, preserve entire array, not just first element // If there's more than 1 element, preserve entire array, not just first element
@ -80,6 +95,17 @@ ve.dm.MWReferenceListNode.static.toDomElements = function ( dataElement, doc ) {
} }
el.setAttribute( 'typeof', 'mw:Extension/references' ); el.setAttribute( 'typeof', 'mw:Extension/references' );
if ( contentsData.length > 2 ) {
wrapper = doc.createElement( 'div' );
converter.getDomSubtreeFromData( data.slice( 1, -1 ), wrapper );
contentsHtml = $( wrapper ).html(); // Returns '' if wrapper is empty
originalHtml = ve.getProp( mwData, 'body', 'html' ) || '';
// Only set body.html if contentsHtml and originalHtml are actually different
if ( !$( '<div>' ).html( originalHtml ).get( 0 ).isEqualNode( wrapper ) ) {
ve.setProp( mwData, 'body', 'html', contentsHtml );
}
}
// If mwData and originalMw are the same, use originalMw to prevent reserialization. // If mwData and originalMw are the same, use originalMw to prevent reserialization.
// Reserialization has the potential to reorder keys and so change the DOM unnecessarily // Reserialization has the potential to reorder keys and so change the DOM unnecessarily
originalMw = attribs.originalMw; originalMw = attribs.originalMw;

View file

@ -126,6 +126,18 @@ ve.dm.mwExample.MWTransclusion.mixedStoreItems = {
'value': $( ve.dm.mwExample.MWTransclusion.mixed ).toArray() 'value': $( ve.dm.mwExample.MWTransclusion.mixed ).toArray()
}; };
ve.dm.mwExample.MWReference = {
'referenceList':
'<ol class="references" typeof="mw:Extension/references" about="#mwt7" data-parsoid="{}"' +
'data-mw="{&quot;name&quot;:&quot;references&quot;,&quot;body&quot;:{' +
'&quot;extsrc&quot;:&quot;<ref name=\\&quot;foo\\&quot;>Ref in refs</ref>' +
'&quot;,&quot;html&quot;:&quot;<span about=\\&quot;#mwt8\\&quot; class=\\&quot;reference\\&quot; ' +
'data-mw=\\&quot;{&amp;quot;name&amp;quot;:&amp;quot;ref&amp;quot;,&amp;quot;body&amp;quot;:{&amp;quot;html&amp;quot;:&amp;quot;Ref in refs&amp;quot;},' +
'&amp;quot;attrs&amp;quot;:{&amp;quot;name&amp;quot;:&amp;quot;foo&amp;quot;}}\\&quot; ' +
'rel=\\&quot;dc:references\\&quot; typeof=\\&quot;mw:Extension/ref\\&quot;>' +
'<a href=\\&quot;#cite_note-foo-3\\&quot;>[3]</a></span>&quot;},&quot;attrs&quot;:{}}"></ol>'
};
ve.dm.mwExample.mwNowikiAnnotation = { ve.dm.mwExample.mwNowikiAnnotation = {
'type': 'mwNowiki', 'type': 'mwNowiki',
'attributes': { 'attributes': {
@ -823,45 +835,35 @@ ve.dm.mwExample.domToDataCases = {
] ]
}, },
'mw:Reference': { 'mw:Reference': {
// Wikitext:
// Foo<ref name="bar" /> Baz<ref name="quux">Quux</ref> Whee<ref name="bar">[[Bar]]</ref> Yay<ref group="g1">No name</ref> Quux<ref name="bar">Different content</ref> Foo<ref group="g1">No name</ref> Bar<ref name="foo" />
// <references><ref name="foo">Ref in refs</ref></references>
'html': 'html':
'<body>' + '<body>' +
'<p>Foo' + '<p>Foo' +
'<span id="cite_ref-bar-1-0" class="reference" about="#mwt5" typeof="mw:Extension/ref" ' + '<span about="#mwt1" class="reference" data-mw="{&quot;name&quot;:&quot;ref&quot;,&quot;attrs&quot;:{&quot;name&quot;:&quot;bar&quot;}}" id="cite_ref-bar-1-0" rel="dc:references" typeof="mw:Extension/ref" data-parsoid="{}">' +
'data-parsoid="{}" ' + '<a href="#cite_note-bar-1">[1]</a>' +
'data-mw="{&quot;name&quot;:&quot;ref&quot;,&quot;attrs&quot;:{&quot;name&quot;:&quot;bar&quot;}}">' +
'<a href="#cite_note-bar-1" data-parsoid="{}">[1]</a>' +
'</span>' + '</span>' +
' Baz' + ' Baz' +
'<span id="cite_ref-quux-2-0" class="reference" about="#mwt6" typeof="mw:Extension/ref" ' + '<span about="#mwt2" class="reference" data-mw="{&quot;name&quot;:&quot;ref&quot;,&quot;body&quot;:{&quot;html&quot;:&quot;Quux&quot;},&quot;attrs&quot;:{&quot;name&quot;:&quot;quux&quot;}}" id="cite_ref-quux-2-0" rel="dc:references" typeof="mw:Extension/ref" data-parsoid="{}">' +
'data-parsoid="{}" ' +
'data-mw="{&quot;name&quot;:&quot;ref&quot;,&quot;body&quot;:{&quot;html&quot;:&quot;Quux&quot;},&quot;attrs&quot;:{&quot;name&quot;:&quot;quux&quot;}}">' +
'<a href="#cite_note-quux-2" data-parsoid="{}">[2]</a>' +
'</span>' + '</span>' +
' Whee' + ' Whee' +
'<span id="cite_ref-bar-1-1" class="reference" about="#mwt7" typeof="mw:Extension/ref" ' + '<span about="#mwt3" class="reference" data-mw="{&quot;name&quot;:&quot;ref&quot;,&quot;body&quot;:{&quot;html&quot;:&quot;' +
'data-parsoid="{}" ' + '<a rel=\\&quot;mw:WikiLink\\&quot; href=\\&quot;./Bar\\&quot;>Bar' +
'data-mw="{&quot;name&quot;:&quot;ref&quot;,&quot;body&quot;:{&quot;html&quot;:&quot;<a rel=\\&quot;mw:WikiLink\\&quot; ' + '</a>&quot;},&quot;attrs&quot;:{&quot;name&quot;:&quot;bar&quot;}}" id="cite_ref-bar-1-1" rel="dc:references" typeof="mw:Extension/ref" data-parsoid="{}">' +
'href=\\&quot;./Bar\\&quot;>Bar</a>&quot;},&quot;attrs&quot;:{&quot;name&quot;:&quot;bar&quot;}}">' +
'<a href="#cite_note-bar-1" data-parsoid="{}">[1]</a>' +
'</span>' + '</span>' +
' Yay' + ' Yay' +
'<span id="cite_ref-3-0" class="reference" about="#mwt8" typeof="mw:Extension/ref" ' + '<span about="#mwt4" class="reference" data-mw="{&quot;name&quot;:&quot;ref&quot;,&quot;body&quot;:{&quot;html&quot;:&quot;No name&quot;},&quot;attrs&quot;:{&quot;group&quot;:&quot;g1&quot;}}" id="cite_ref-1-0" rel="dc:references" typeof="mw:Extension/ref" data-parsoid="{}">' +
'data-parsoid="{}" ' +
'data-mw="{&quot;name&quot;:&quot;ref&quot;,&quot;body&quot;:{&quot;html&quot;:&quot;No name&quot;},&quot;attrs&quot;:{&quot;group&quot;:&quot;g1&quot;}}">' +
'<a href="#cite_note-3" data-parsoid="{}">[3]</a>' +
'</span>' + '</span>' +
' Quux' + ' Quux' +
'<span id="cite_ref-bar-1-2" class="reference" about="#mwt9" typeof="mw:Extension/ref" ' + '<span about="#mwt5" class="reference" data-mw="{&quot;name&quot;:&quot;ref&quot;,&quot;body&quot;:{&quot;html&quot;:&quot;Different content&quot;},&quot;attrs&quot;:{&quot;name&quot;:&quot;bar&quot;}}" id="cite_ref-bar-1-2" rel="dc:references" typeof="mw:Extension/ref" data-parsoid="{}">' +
'data-parsoid="{}" ' + '</span>' +
'data-mw="{&quot;name&quot;:&quot;ref&quot;,&quot;body&quot;:{&quot;html&quot;:&quot;Different content&quot;},&quot;attrs&quot;:{&quot;name&quot;:&quot;bar&quot;}}">' + ' Foo' +
'<a href="#cite_note-bar-1" data-parsoid="{}">[1]</a>'+ '<span about="#mwt6" class="reference" data-mw="{&quot;name&quot;:&quot;ref&quot;,&quot;attrs&quot;:{&quot;name&quot;:&quot;foo&quot;}}" ' +
'id="cite_ref-foo-3-0" rel="dc:references" typeof="mw:Extension/ref" data-parsoid="{}">' +
'</span>' + '</span>' +
'</p>' + '</p>' +
'<ol class="references" about="#mwt12" typeof="mw:Extension/references" ' + ve.dm.mwExample.MWReference.referenceList +
'data-mw="{&quot;name&quot;:&quot;references&quot;,&quot;attrs&quot;:{}}" ' +
'data-parsoid="{}">' +
'<li id="cite_note-quux-2"><a href="#cite_ref-quux-2-0">u2191</a>Quux</li>' +
'</ol>' +
'</body>', '</body>',
'data': [ 'data': [
{ 'type': 'paragraph' }, { 'type': 'paragraph' },
@ -869,31 +871,31 @@ ve.dm.mwExample.domToDataCases = {
{ {
'type': 'mwReference', 'type': 'mwReference',
'attributes': { 'attributes': {
'about': '#mwt5', 'about': '#mwt1',
'listIndex': 0, 'listIndex': 0,
'listGroup': 'mwReference/', 'listGroup': 'mwReference/',
'listKey': 'bar', 'listKey': 'bar',
'refGroup': '', 'refGroup': '',
'mw': { 'name': 'ref', 'attrs': { 'name': 'bar' } }, 'mw': { 'name': 'ref', 'attrs': { 'name': 'bar' } },
'originalMw': '{"name":"ref","attrs":{"name":"bar"}}', 'originalMw': '{"name":"ref","attrs":{"name":"bar"}}',
'childDomElements': $( '<a href="#cite_note-bar-1" data-parsoid="{}">[1]</a>' ).toArray(), 'childDomElements': $( '<a href="#cite_note-bar-1">[1]</a>' ).toArray(),
'contentsUsed': false 'contentsUsed': false
}, },
'htmlAttributes': [ 'htmlAttributes': [
{ {
'values': { 'values': {
'about': '#mwt5', 'about': '#mwt1',
'class': 'reference', 'class': 'reference',
'data-mw': '{"name":"ref","attrs":{"name":"bar"}}', 'data-mw': '{"name":"ref","attrs":{"name":"bar"}}',
'data-parsoid': '{}', 'data-parsoid': '{}',
'id': 'cite_ref-bar-1-0', 'id': 'cite_ref-bar-1-0',
'rel': 'dc:references',
'typeof': 'mw:Extension/ref' 'typeof': 'mw:Extension/ref'
}, },
'children': [ 'children': [
{ {
'values': { 'values': {
'href': '#cite_note-bar-1', 'href': '#cite_note-bar-1'
'data-parsoid': '{}'
} }
} }
] ]
@ -905,34 +907,27 @@ ve.dm.mwExample.domToDataCases = {
{ {
'type': 'mwReference', 'type': 'mwReference',
'attributes': { 'attributes': {
'about': '#mwt6', 'about': '#mwt2',
'listIndex': 1, 'listIndex': 1,
'listGroup': 'mwReference/', 'listGroup': 'mwReference/',
'listKey': 'quux', 'listKey': 'quux',
'refGroup': '', 'refGroup': '',
'mw': { 'name': 'ref', 'body': { 'html': 'Quux' }, 'attrs': { 'name': 'quux' } }, 'mw': { 'name': 'ref', 'body': { 'html': 'Quux' }, 'attrs': { 'name': 'quux' } },
'originalMw': '{"name":"ref","body":{"html":"Quux"},"attrs":{"name":"quux"}}', 'originalMw': '{"name":"ref","body":{"html":"Quux"},"attrs":{"name":"quux"}}',
'childDomElements': $( '<a href="#cite_note-quux-2" data-parsoid="{}">[2]</a>' ).toArray(), 'childDomElements': [],
'contentsUsed': true 'contentsUsed': true
}, },
'htmlAttributes': [ 'htmlAttributes': [
{ {
'values': { 'values': {
'about': '#mwt6', 'about': '#mwt2',
'class': 'reference', 'class': 'reference',
'data-mw': '{"name":"ref","body":{"html":"Quux"},"attrs":{"name":"quux"}}', 'data-mw': '{"name":"ref","body":{"html":"Quux"},"attrs":{"name":"quux"}}',
'data-parsoid': '{}', 'data-parsoid': '{}',
'id': 'cite_ref-quux-2-0', 'id': 'cite_ref-quux-2-0',
'rel': 'dc:references',
'typeof': 'mw:Extension/ref' 'typeof': 'mw:Extension/ref'
}, }
'children': [
{
'values': {
'href': '#cite_note-quux-2',
'data-parsoid': '{}'
}
}
]
} }
] ]
}, },
@ -941,34 +936,27 @@ ve.dm.mwExample.domToDataCases = {
{ {
'type': 'mwReference', 'type': 'mwReference',
'attributes': { 'attributes': {
'about': '#mwt7', 'about': '#mwt3',
'listIndex': 0, 'listIndex': 0,
'listGroup': 'mwReference/', 'listGroup': 'mwReference/',
'listKey': 'bar', 'listKey': 'bar',
'refGroup': '', 'refGroup': '',
'mw': { 'name': 'ref', 'body': { 'html': '<a rel="mw:WikiLink" href="./Bar">Bar</a>' }, 'attrs': { 'name': 'bar' } }, 'mw': { 'name': 'ref', 'body': { 'html': '<a rel="mw:WikiLink" href="./Bar">Bar</a>' }, 'attrs': { 'name': 'bar' } },
'originalMw': '{"name":"ref","body":{"html":"<a rel=\\"mw:WikiLink\\" href=\\"./Bar\\">Bar</a>"},"attrs":{"name":"bar"}}', 'originalMw': '{"name":"ref","body":{"html":"<a rel=\\"mw:WikiLink\\" href=\\"./Bar\\">Bar</a>"},"attrs":{"name":"bar"}}',
'childDomElements': $( '<a href="#cite_note-bar-1" data-parsoid="{}">[1]</a>' ).toArray(), 'childDomElements': [],
'contentsUsed': true 'contentsUsed': true
}, },
'htmlAttributes': [ 'htmlAttributes': [
{ {
'values': { 'values': {
'about': '#mwt7', 'about': '#mwt3',
'class': 'reference', 'class': 'reference',
'data-mw': '{"name":"ref","body":{"html":"<a rel=\\"mw:WikiLink\\" href=\\"./Bar\\">Bar</a>"},"attrs":{"name":"bar"}}', 'data-mw': '{"name":"ref","body":{"html":"<a rel=\\"mw:WikiLink\\" href=\\"./Bar\\">Bar</a>"},"attrs":{"name":"bar"}}',
'data-parsoid': '{}', 'data-parsoid': '{}',
'id': 'cite_ref-bar-1-1', 'id': 'cite_ref-bar-1-1',
'rel': 'dc:references',
'typeof': 'mw:Extension/ref' 'typeof': 'mw:Extension/ref'
}, }
'children': [
{
'values': {
'href': '#cite_note-bar-1',
'data-parsoid': '{}'
}
}
]
} }
] ]
}, },
@ -977,34 +965,27 @@ ve.dm.mwExample.domToDataCases = {
{ {
'type': 'mwReference', 'type': 'mwReference',
'attributes': { 'attributes': {
'about': '#mwt8', 'about': '#mwt4',
'listIndex': 2, 'listIndex': 2,
'listGroup': 'mwReference/g1', 'listGroup': 'mwReference/g1',
'listKey': null, 'listKey': null,
'refGroup': 'g1', 'refGroup': 'g1',
'mw': { 'name': 'ref', 'body': { 'html': 'No name' }, 'attrs': { 'group': 'g1' } }, 'mw': { 'name': 'ref', 'body': { 'html': 'No name' }, 'attrs': { 'group': 'g1' } },
'originalMw': '{"name":"ref","body":{"html":"No name"},"attrs":{"group":"g1"}}', 'originalMw': '{"name":"ref","body":{"html":"No name"},"attrs":{"group":"g1"}}',
'childDomElements': $( '<a href="#cite_note-3" data-parsoid="{}">[3]</a>' ).toArray(), 'childDomElements': [],
'contentsUsed': true 'contentsUsed': true
}, },
'htmlAttributes': [ 'htmlAttributes': [
{ {
'values': { 'values': {
'about': '#mwt8', 'about': '#mwt4',
'class': 'reference', 'class': 'reference',
'data-mw': '{"name":"ref","body":{"html":"No name"},"attrs":{"group":"g1"}}', 'data-mw': '{"name":"ref","body":{"html":"No name"},"attrs":{"group":"g1"}}',
'data-parsoid': '{}', 'data-parsoid': '{}',
'id': 'cite_ref-3-0', 'id': 'cite_ref-1-0',
'rel': 'dc:references',
'typeof': 'mw:Extension/ref' 'typeof': 'mw:Extension/ref'
}, }
'children': [
{
'values': {
'href': '#cite_note-3',
'data-parsoid': '{}'
}
}
]
} }
] ]
}, },
@ -1013,34 +994,56 @@ ve.dm.mwExample.domToDataCases = {
{ {
'type': 'mwReference', 'type': 'mwReference',
'attributes': { 'attributes': {
'about': '#mwt9', 'about': '#mwt5',
'listIndex': 0, 'listIndex': 0,
'listGroup': 'mwReference/', 'listGroup': 'mwReference/',
'listKey': 'bar', 'listKey': 'bar',
'refGroup': '', 'refGroup': '',
'mw': { 'name': 'ref', 'body': { 'html': 'Different content' }, 'attrs': { 'name': 'bar' } }, 'mw': { 'name': 'ref', 'body': { 'html': 'Different content' }, 'attrs': { 'name': 'bar' } },
'originalMw': '{"name":"ref","body":{"html":"Different content"},"attrs":{"name":"bar"}}', 'originalMw': '{"name":"ref","body":{"html":"Different content"},"attrs":{"name":"bar"}}',
'childDomElements': $( '<a href="#cite_note-bar-1" data-parsoid="{}">[1]</a>' ).toArray(), 'childDomElements': [],
'contentsUsed': false 'contentsUsed': false
}, },
'htmlAttributes': [ 'htmlAttributes': [
{ {
'values': { 'values': {
'about': '#mwt9', 'about': '#mwt5',
'class': 'reference', 'class': 'reference',
'data-mw': '{"name":"ref","body":{"html":"Different content"},"attrs":{"name":"bar"}}', 'data-mw': '{"name":"ref","body":{"html":"Different content"},"attrs":{"name":"bar"}}',
'data-parsoid': '{}', 'data-parsoid': '{}',
'id': 'cite_ref-bar-1-2', 'id': 'cite_ref-bar-1-2',
'rel': 'dc:references',
'typeof': 'mw:Extension/ref' 'typeof': 'mw:Extension/ref'
}, }
'children': [ }
{ ]
'values': { },
'href': '#cite_note-bar-1', { 'type': '/mwReference' },
'data-parsoid': '{}' ' ', 'F', 'o', 'o',
} {
} 'type': 'mwReference',
] 'attributes': {
'about': '#mwt6',
'listGroup': 'mwReference/',
'listIndex': 3,
'listKey': 'foo',
'refGroup': '',
'mw': { 'name': 'ref', 'attrs': { 'name': 'foo' } },
'originalMw': '{"name":"ref","attrs":{"name":"foo"}}',
'childDomElements': [],
'contentsUsed': false
},
'htmlAttributes': [
{
'values': {
'about': '#mwt6',
'class': 'reference',
'data-mw': '{"name":"ref","attrs":{"name":"foo"}}',
'data-parsoid': '{}',
'id': 'cite_ref-foo-3-0',
'rel': 'dc:references',
'typeof': 'mw:Extension/ref'
}
} }
] ]
}, },
@ -1049,22 +1052,50 @@ ve.dm.mwExample.domToDataCases = {
{ {
'type': 'mwReferenceList', 'type': 'mwReferenceList',
'attributes': { 'attributes': {
'about': '#mwt12', 'about': '#mwt7',
'mw': { 'mw': {
'name': 'references', 'name': 'references',
'attrs': {} 'attrs': {},
'body': {
'extsrc': '<ref name="foo">Ref in refs</ref>',
'html': '<span about="#mwt8" class="reference" data-mw="{&quot;name&quot;:&quot;ref&quot;,&quot;body&quot;:{&quot;html&quot;:&quot;Ref in refs&quot;},&quot;attrs&quot;:{&quot;name&quot;:&quot;foo&quot;}}" rel="dc:references" typeof="mw:Extension/ref"><a href="#cite_note-foo-3">[3]</a></span>'
}
}, },
'originalMw': '{"name":"references","attrs":{}}', 'originalMw': '{"name":"references","body":{"extsrc":"<ref name=\\"foo\\">Ref in refs</ref>","html":"<span about=\\"#mwt8\\" class=\\"reference\\" data-mw=\\"{&quot;name&quot;:&quot;ref&quot;,&quot;body&quot;:{&quot;html&quot;:&quot;Ref in refs&quot;},&quot;attrs&quot;:{&quot;name&quot;:&quot;foo&quot;}}\\" rel=\\"dc:references\\" typeof=\\"mw:Extension/ref\\"><a href=\\"#cite_note-foo-3\\">[3]</a></span>"},"attrs":{}}',
'domElements': $( 'domElements': $( ve.dm.mwExample.MWReference.referenceList ).toArray(),
'<ol class="references" about="#mwt12" typeof="mw:Extension/references" '+
'data-mw="{&quot;name&quot;:&quot;references&quot;,&quot;attrs&quot;:{}}" ' +
'data-parsoid="{}">'+
'<li id="cite_note-quux-2"><a href="#cite_ref-quux-2-0">u2191</a>Quux</li>' +
'</ol>' ).toArray(),
'listGroup': 'mwReference/', 'listGroup': 'mwReference/',
'refGroup': '' 'refGroup': ''
} }
}, },
{ 'type': 'paragraph', 'internal': { 'generated': 'wrapper' } },
{
'type': 'mwReference',
'attributes': {
'about': '#mwt8',
'childDomElements': $( '<a href="#cite_note-foo-3">[3]</a>' ).toArray(),
'contentsUsed': true,
'listGroup': 'mwReference/',
'listIndex': 3,
'listKey': 'foo',
'mw': { 'name': 'ref', 'attrs': { 'name': 'foo' }, 'body': { 'html': 'Ref in refs' } },
'originalMw': '{"name":"ref","body":{"html":"Ref in refs"},"attrs":{"name":"foo"}}',
'refGroup': ''
},
'htmlAttributes': [ {
'children': [ { 'values': {
'href': '#cite_note-foo-3'
} } ],
'values': {
'about': '#mwt8',
'class': 'reference',
'data-mw': '{"name":"ref","body":{"html":"Ref in refs"},"attrs":{"name":"foo"}}',
'rel': 'dc:references',
'typeof': 'mw:Extension/ref'
}
} ]
},
{ 'type': '/mwReference' },
{ 'type': '/paragraph' },
{ 'type': '/mwReferenceList' }, { 'type': '/mwReferenceList' },
{ 'type': 'internalList' }, { 'type': 'internalList' },
{ 'type': 'internalItem' }, { 'type': 'internalItem' },
@ -1129,6 +1160,11 @@ ve.dm.mwExample.domToDataCases = {
'N', 'o', ' ', 'n', 'a', 'm', 'e', 'N', 'o', ' ', 'n', 'a', 'm', 'e',
{ 'type': '/paragraph' }, { 'type': '/paragraph' },
{ 'type': '/internalItem' }, { 'type': '/internalItem' },
{ 'type': 'internalItem' },
{ 'type': 'paragraph', 'internal': { 'generated': 'wrapper' } },
'R', 'e', 'f', ' ', 'i', 'n', ' ', 'r', 'e', 'f', 's',
{ 'type': '/paragraph' },
{ 'type': '/internalItem' },
{ 'type': '/internalList' } { 'type': '/internalList' }
] ]
}, },