mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Cite
synced 2024-11-24 15:04:02 +00:00
MWReferenceNode: Generate 'sup' tags by default
Bug: T45094 Change-Id: I8973328095f36cce2cebbf335ee7421187eedfad
This commit is contained in:
parent
fbcd9e41df
commit
366d44926a
|
@ -18,113 +18,113 @@ ve.dm.citeExample.domToDataCases = {
|
|||
// <references group="g1"><ref group="g1" name="foo">Ref in refs</ref></references>
|
||||
body:
|
||||
'<p>Foo' +
|
||||
'<span about="#mwt1" class="reference" data-mw="{"name":"ref","attrs":{"name":"bar"}}" id="cite_ref-bar-1-0" rel="dc:references" typeof="mw:Extension/ref" data-parsoid="{}">' +
|
||||
'<sup about="#mwt1" class="reference" data-mw="{"name":"ref","attrs":{"name":"bar"}}" id="cite_ref-bar-1-0" rel="dc:references" typeof="mw:Extension/ref" data-parsoid="{}">' +
|
||||
'<a href="#cite_note-bar-1">[1]</a>' +
|
||||
'</span>' +
|
||||
'</sup>' +
|
||||
' Baz' +
|
||||
'<span about="#mwt2" class="reference" data-mw="{"name":"ref","body":{"html":"Quux"},"attrs":{"group":"g1","name":":0"}}" id="cite_ref-quux-2-0" rel="dc:references" typeof="mw:Extension/ref" data-parsoid="{}">' +
|
||||
'<sup about="#mwt2" class="reference" data-mw="{"name":"ref","body":{"html":"Quux"},"attrs":{"group":"g1","name":":0"}}" id="cite_ref-quux-2-0" rel="dc:references" typeof="mw:Extension/ref" data-parsoid="{}">' +
|
||||
'<a href="#cite_note-.3A0-2">[g1 1]</a>' +
|
||||
'</span>' +
|
||||
'</sup>' +
|
||||
' Whee' +
|
||||
'<span about="#mwt3" class="reference" data-mw="{"name":"ref","body":{"html":"' +
|
||||
'<sup about="#mwt3" class="reference" data-mw="{"name":"ref","body":{"html":"' +
|
||||
'<a rel=\\"mw:WikiLink\\" href=\\"./Bar\\">Bar' +
|
||||
'</a>"},"attrs":{"name":"bar"}}" id="cite_ref-bar-1-1" rel="dc:references" typeof="mw:Extension/ref" data-parsoid="{}">' +
|
||||
'<a href="#cite_note-bar-1">[1]</a>' +
|
||||
'</span>' +
|
||||
'</sup>' +
|
||||
' Yay' +
|
||||
// This reference has .body.id instead of .body.html
|
||||
'<span about="#mwt4" class="reference" data-mw="{"name":"ref","body":{"id":"mw-cite-3"},"attrs":{"group":"g1"}}" id="cite_ref-1-0" rel="dc:references" typeof="mw:Extension/ref" data-parsoid="{}">' +
|
||||
'<sup about="#mwt4" class="reference" data-mw="{"name":"ref","body":{"id":"mw-cite-3"},"attrs":{"group":"g1"}}" id="cite_ref-1-0" rel="dc:references" typeof="mw:Extension/ref" data-parsoid="{}">' +
|
||||
'<a href="#cite_note-3">[g1 2]</a>' +
|
||||
'</span>' +
|
||||
'</sup>' +
|
||||
' Quux' +
|
||||
'<span about="#mwt5" class="reference" data-mw="{"name":"ref","body":{"html":"Different content"},"attrs":{"name":"bar"}}" id="cite_ref-bar-1-2" rel="dc:references" typeof="mw:Extension/ref" data-parsoid="{}">' +
|
||||
'<sup about="#mwt5" class="reference" data-mw="{"name":"ref","body":{"html":"Different content"},"attrs":{"name":"bar"}}" id="cite_ref-bar-1-2" rel="dc:references" typeof="mw:Extension/ref" data-parsoid="{}">' +
|
||||
'<a href="#cite_note-bar-1">[1]</a>' +
|
||||
'</span>' +
|
||||
'</sup>' +
|
||||
' Foo' +
|
||||
'<span about="#mwt6" class="reference" data-mw="{"name":"ref","attrs":{"group":"g1","name":"foo"}}" ' +
|
||||
'<sup about="#mwt6" class="reference" data-mw="{"name":"ref","attrs":{"group":"g1","name":"foo"}}" ' +
|
||||
'id="cite_ref-foo-4" rel="dc:references" typeof="mw:Extension/ref" data-parsoid="{}">' +
|
||||
'<a href="#cite_ref-foo-4">[g1 3]</a>' +
|
||||
'</span>' +
|
||||
'</sup>' +
|
||||
'</p>' +
|
||||
// The HTML below is enriched to wrap reference contents in <span id="mw-cite-[...]">
|
||||
// which Parsoid doesn't do yet, but T88290 asks for
|
||||
'<ol class="references" typeof="mw:Extension/references" about="#mwt7" data-parsoid="{}"' +
|
||||
'data-mw="{"name":"references","body":{' +
|
||||
'"html":"<span about=\\"#mwt8\\" class=\\"reference\\" ' +
|
||||
'"html":"<sup 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;group&quot;:&quot;g1&quot;,&quot;name&quot;:&quot;foo&quot;}}\\" ' +
|
||||
'rel=\\"dc:references\\" typeof=\\"mw:Extension/ref\\">' +
|
||||
'<a href=\\"#cite_note-foo-3\\">[3]</a></span>"},"attrs":{"group":"g1"}}">' +
|
||||
'<a href=\\"#cite_note-foo-3\\">[3]</a></sup>"},"attrs":{"group":"g1"}}">' +
|
||||
'<li about="#cite_note-.3A0-2" id="cite_note-.3A0-2"><span rel="mw:referencedBy"><a href="#cite_ref-.3A0_2-0">↑</a></span> <span id="mw-cite-:0">Quux</span></li>' +
|
||||
'<li about="#cite_note-3" id="cite_note-3"><span rel="mw:referencedBy"><a href="#cite_ref-3">↑</a></span> <span id="mw-cite-3">No name</span></li>' +
|
||||
'<li about="#cite_note-foo-4" id="cite_note-foo-4"><span rel="mw:referencedBy"><a href="#cite_ref-foo_4-0">↑</a></span> <span id="mw-cite-foo">Ref in refs</span></li>' +
|
||||
'</ol>',
|
||||
fromDataBody:
|
||||
'<p>Foo' +
|
||||
'<span data-mw="{"name":"ref","attrs":{"name":"bar"}}" typeof="mw:Extension/ref">' +
|
||||
'</span>' +
|
||||
'<sup data-mw="{"name":"ref","attrs":{"name":"bar"}}" typeof="mw:Extension/ref">' +
|
||||
'</sup>' +
|
||||
' Baz' +
|
||||
'<span data-mw="{"name":"ref","body":{"html":"Quux"},"attrs":{"group":"g1","name":":0"}}" typeof="mw:Extension/ref">' +
|
||||
'</span>' +
|
||||
'<sup data-mw="{"name":"ref","body":{"html":"Quux"},"attrs":{"group":"g1","name":":0"}}" typeof="mw:Extension/ref">' +
|
||||
'</sup>' +
|
||||
' Whee' +
|
||||
'<span data-mw="{"name":"ref","body":{"html":"' +
|
||||
'<sup data-mw="{"name":"ref","body":{"html":"' +
|
||||
'<a rel=\\"mw:WikiLink\\" href=\\"./Bar\\">Bar' +
|
||||
'</a>"},"attrs":{"name":"bar"}}" typeof="mw:Extension/ref">' +
|
||||
'</span>' +
|
||||
'</sup>' +
|
||||
' Yay' +
|
||||
'<span data-mw="{"name":"ref","body":{"id":"mw-cite-3"},"attrs":{"group":"g1"}}" typeof="mw:Extension/ref">' +
|
||||
'</span>' +
|
||||
'<sup data-mw="{"name":"ref","body":{"id":"mw-cite-3"},"attrs":{"group":"g1"}}" typeof="mw:Extension/ref">' +
|
||||
'</sup>' +
|
||||
' Quux' +
|
||||
'<span data-mw="{"name":"ref","body":{"html":"Different content"},"attrs":{"name":"bar"}}" typeof="mw:Extension/ref">' +
|
||||
'</span>' +
|
||||
'<sup data-mw="{"name":"ref","body":{"html":"Different content"},"attrs":{"name":"bar"}}" typeof="mw:Extension/ref">' +
|
||||
'</sup>' +
|
||||
' Foo' +
|
||||
'<span data-mw="{"name":"ref","attrs":{"group":"g1","name":"foo"}}" ' +
|
||||
'<sup data-mw="{"name":"ref","attrs":{"group":"g1","name":"foo"}}" ' +
|
||||
'typeof="mw:Extension/ref">' +
|
||||
'</span>' +
|
||||
'</sup>' +
|
||||
'</p>' +
|
||||
'<div typeof="mw:Extension/references" ' +
|
||||
'data-mw="{"name":"references","attrs":{"group":"g1"},"body":{' +
|
||||
'"html":"<span typeof=\\"mw:Extension/ref\\" ' +
|
||||
'"html":"<sup typeof=\\"mw:Extension/ref\\" ' +
|
||||
'data-mw=\\"{&quot;name&quot;:&quot;ref&quot;,&quot;body&quot;:{&quot;html&quot;:&quot;Ref in refs&quot;},' +
|
||||
'&quot;attrs&quot;:{&quot;group&quot;:&quot;g1&quot;,&quot;name&quot;:&quot;foo&quot;}}\\">' +
|
||||
'</span>"}}">' +
|
||||
'</sup>"}}">' +
|
||||
'</div>',
|
||||
clipboardBody:
|
||||
'<p>Foo' +
|
||||
'<span typeof="mw:Extension/ref" data-mw="{"name":"ref","attrs":{"name":"bar"}}" class="mw-ref">' +
|
||||
'<sup typeof="mw:Extension/ref" data-mw="{"name":"ref","attrs":{"name":"bar"}}" class="mw-ref">' +
|
||||
'<a style="counter-reset: mw-Ref 1;"><span class="mw-reflink-text">[1]</span></a>' +
|
||||
'</span>' +
|
||||
'</sup>' +
|
||||
' Baz' +
|
||||
'<span typeof="mw:Extension/ref" data-mw="{"name":"ref","body":{"html":"Quux"},"attrs":{"group":"g1","name":":0"}}" class="mw-ref">' +
|
||||
'<sup typeof="mw:Extension/ref" data-mw="{"name":"ref","body":{"html":"Quux"},"attrs":{"group":"g1","name":":0"}}" class="mw-ref">' +
|
||||
'<a data-mw-group="g1" style="counter-reset: mw-Ref 1;"><span class="mw-reflink-text">[g1 1]</span></a>' +
|
||||
'</span>' +
|
||||
'</sup>' +
|
||||
' Whee' +
|
||||
'<span typeof="mw:Extension/ref" data-mw="{"name":"ref","body":{"html":"' +
|
||||
'<sup typeof="mw:Extension/ref" data-mw="{"name":"ref","body":{"html":"' +
|
||||
'<a href=\\"./Bar\\" rel=\\"mw:WikiLink\\">Bar' +
|
||||
'</a>"},"attrs":{"name":"bar"}}" class="mw-ref">' +
|
||||
'<a style="counter-reset: mw-Ref 1;"><span class="mw-reflink-text">[1]</span></a>' +
|
||||
'</span>' +
|
||||
'</sup>' +
|
||||
' Yay' +
|
||||
// This reference has .body.id instead of .body.html
|
||||
'<span typeof="mw:Extension/ref" data-mw="{"name":"ref","body":{"id":"mw-cite-3","html":"No name"},"attrs":{"group":"g1"}}" class="mw-ref">' +
|
||||
'<sup typeof="mw:Extension/ref" data-mw="{"name":"ref","body":{"id":"mw-cite-3","html":"No name"},"attrs":{"group":"g1"}}" class="mw-ref">' +
|
||||
'<a data-mw-group="g1" style="counter-reset: mw-Ref 2;"><span class="mw-reflink-text">[g1 2]</span></a>' +
|
||||
'</span>' +
|
||||
'</sup>' +
|
||||
' Quux' +
|
||||
'<span typeof="mw:Extension/ref" data-mw="{"name":"ref","body":{"html":"Different content"},"attrs":{"name":"bar"}}" class="mw-ref">' +
|
||||
'<sup typeof="mw:Extension/ref" data-mw="{"name":"ref","body":{"html":"Different content"},"attrs":{"name":"bar"}}" class="mw-ref">' +
|
||||
'<a style="counter-reset: mw-Ref 1;"><span class="mw-reflink-text">[1]</span></a>' +
|
||||
'</span>' +
|
||||
'</sup>' +
|
||||
' Foo' +
|
||||
'<span typeof="mw:Extension/ref" data-mw="{"name":"ref","attrs":{"group":"g1","name":"foo"}}" class="mw-ref">' +
|
||||
'<sup typeof="mw:Extension/ref" data-mw="{"name":"ref","attrs":{"group":"g1","name":"foo"}}" class="mw-ref">' +
|
||||
'<a data-mw-group="g1" style="counter-reset: mw-Ref 3;"><span class="mw-reflink-text">[g1 3]</span></a>' +
|
||||
'</span>' +
|
||||
'</sup>' +
|
||||
'</p>' +
|
||||
// The HTML below is enriched to wrap reference contents in <span id="mw-cite-[...]">
|
||||
// which Parsoid doesn't do yet, but T88290 asks for
|
||||
'<div typeof="mw:Extension/references"' +
|
||||
'data-mw="{"name":"references","attrs":{"group":"g1"},"body":{' +
|
||||
'"html":"<span typeof=\\"mw:Extension/ref\\" ' +
|
||||
'"html":"<sup typeof=\\"mw:Extension/ref\\" ' +
|
||||
'data-mw=\\"{&quot;name&quot;:&quot;ref&quot;,&quot;attrs&quot;:{&quot;group&quot;:&quot;g1&quot;,&quot;name&quot;:&quot;foo&quot;},&quot;body&quot;:{&quot;html&quot;:&quot;Ref in refs&quot;}}' +
|
||||
'\\" class=\\"mw-ref\\"><a data-mw-group=\\"g1\\" style=\\"counter-reset: mw-Ref 3;\\"><span class=\\"mw-reflink-text\\">[g1 3]</span></a></span>"}}">' +
|
||||
'\\" class=\\"mw-ref\\"><a data-mw-group=\\"g1\\" style=\\"counter-reset: mw-Ref 3;\\"><span class=\\"mw-reflink-text\\">[g1 3]</span></a></sup>"}}">' +
|
||||
'</div>',
|
||||
head: '<base href="http://example.com" />',
|
||||
data: [
|
||||
|
@ -222,10 +222,10 @@ ve.dm.citeExample.domToDataCases = {
|
|||
name: 'references',
|
||||
attrs: { group: 'g1' },
|
||||
body: {
|
||||
html: '<span about="#mwt8" class="reference" data-mw="{"name":"ref","body":{"html":"Ref in refs"},"attrs":{"group":"g1","name":"foo"}}" rel="dc:references" typeof="mw:Extension/ref"><a href="#cite_note-foo-3">[3]</a></span>'
|
||||
html: '<sup about="#mwt8" class="reference" data-mw="{"name":"ref","body":{"html":"Ref in refs"},"attrs":{"group":"g1","name":"foo"}}" rel="dc:references" typeof="mw:Extension/ref"><a href="#cite_note-foo-3">[3]</a></sup>'
|
||||
}
|
||||
},
|
||||
originalMw: '{"name":"references","body":{"html":"<span about=\\"#mwt8\\" class=\\"reference\\" data-mw=\\"{"name":"ref","body":{"html":"Ref in refs"},"attrs":{"group":"g1","name":"foo"}}\\" rel=\\"dc:references\\" typeof=\\"mw:Extension/ref\\"><a href=\\"#cite_note-foo-3\\">[3]</a></span>"},"attrs":{"group":"g1"}}',
|
||||
originalMw: '{"name":"references","body":{"html":"<sup about=\\"#mwt8\\" class=\\"reference\\" data-mw=\\"{"name":"ref","body":{"html":"Ref in refs"},"attrs":{"group":"g1","name":"foo"}}\\" rel=\\"dc:references\\" typeof=\\"mw:Extension/ref\\"><a href=\\"#cite_note-foo-3\\">[3]</a></sup>"},"attrs":{"group":"g1"}}',
|
||||
listGroup: 'mwReference/g1',
|
||||
refGroup: 'g1',
|
||||
isResponsive: true
|
||||
|
@ -310,20 +310,20 @@ ve.dm.citeExample.domToDataCases = {
|
|||
]
|
||||
},
|
||||
'mw:Reference with metadata': {
|
||||
body: '<p><span about="#mwt2" class="reference" ' +
|
||||
body: '<p><sup about="#mwt2" class="reference" ' +
|
||||
'data-mw="{"name":"ref","body":' +
|
||||
'{"html":"Foo<!-- bar -->"},"attrs":{}}" ' +
|
||||
'id="cite_ref-1-0" rel="dc:references" typeof="mw:Extension/ref" data-parsoid="{}">' +
|
||||
'<a href="#cite_note-bar-1" data-parsoid="{}">[1]</a></span></p>',
|
||||
fromDataBody: '<p><span ' +
|
||||
'<a href="#cite_note-bar-1" data-parsoid="{}">[1]</a></sup></p>',
|
||||
fromDataBody: '<p><sup ' +
|
||||
'data-mw="{"name":"ref","body":' +
|
||||
'{"html":"Foo<!-- bar -->"},"attrs":{}}" ' +
|
||||
'typeof="mw:Extension/ref"></span></p>',
|
||||
clipboardBody: '<p><span typeof="mw:Extension/ref" ' +
|
||||
'typeof="mw:Extension/ref"></sup></p>',
|
||||
clipboardBody: '<p><sup typeof="mw:Extension/ref" ' +
|
||||
'data-mw="{"attrs":{},"body":' +
|
||||
'{"html":"Foo<span rel=\\"ve:Comment\\" data-ve-comment=\\" bar \\">&nbsp;</span>"},"name":"ref"}" ' +
|
||||
' class="mw-ref">' +
|
||||
'<a style="counter-reset: mw-Ref 1;"><span class="mw-reflink-text">[1]</span></a></span></p>',
|
||||
'<a style="counter-reset: mw-Ref 1;"><span class="mw-reflink-text">[1]</span></a></sup></p>',
|
||||
head: '<base href="http://example.com" />',
|
||||
data: [
|
||||
{ type: 'paragraph' },
|
||||
|
|
|
@ -104,7 +104,7 @@ ve.dm.MWReferenceNode.static.toDomElements = function ( dataElement, doc, conver
|
|||
var itemNodeHtml, originalHtml, mwData, i, iLen, keyedNodes, setContents, contentsAlreadySet,
|
||||
originalMw, listKeyParts, name, group, $link,
|
||||
isForClipboard = converter.isForClipboard(),
|
||||
el = doc.createElement( 'span' ),
|
||||
el = doc.createElement( 'sup' ),
|
||||
itemNodeWrapper = doc.createElement( 'div' ),
|
||||
originalHtmlWrapper = doc.createElement( 'div' ),
|
||||
itemNode = converter.internalList.getItemNode( dataElement.attributes.listIndex ),
|
||||
|
|
Loading…
Reference in a new issue