mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Cite
synced 2024-11-24 15:04:02 +00:00
Improved template roundtripping based on WT ranges on DOM nodes.
- Fixed several bugs in the DSR computation. - Deleted comment tokens from template output. - Eliminated TSR info from template output. - Rearranged order of DOM post passes. - Updated template encapsulation to use DSR values. - There are still a few missing pieces and scenarios that are not handled properly. Change-Id: I644914902ec1d27418138b107abe765f81178398
This commit is contained in:
parent
0520effd3d
commit
760d63d033
|
@ -62,20 +62,24 @@ Cite.prototype.handleRef = function ( tokens ) {
|
|||
|
||||
var refId = "#mwt" + this.manager.env.generateUID(),
|
||||
text = this.manager.env.text,
|
||||
start = startTsr[0],
|
||||
end = endTsr ? endTsr[1] : text.length;
|
||||
var res = [
|
||||
new TagTk('span', [
|
||||
span = new TagTk('span', [
|
||||
new KV('id', linkback),
|
||||
new KV('class', 'reference'),
|
||||
new KV('about', refId),
|
||||
new KV('typeof', 'mw:Object/Ext/Cite')
|
||||
],
|
||||
{
|
||||
tsr: [start, end],
|
||||
src: endTsr ? text.substring(start, end) : text.substring(start)
|
||||
}
|
||||
),
|
||||
]);
|
||||
|
||||
if (startTsr) {
|
||||
var start = startTsr[0],
|
||||
end = endTsr ? endTsr[1] : text.length;
|
||||
span.dataAttribs = {
|
||||
tsr: [start, end],
|
||||
src: endTsr ? text.substring(start, end) : text.substring(start)
|
||||
};
|
||||
}
|
||||
|
||||
var res = [
|
||||
span,
|
||||
new TagTk( 'a', [
|
||||
new KV('href', '#' + ref.target)
|
||||
]
|
||||
|
@ -104,15 +108,15 @@ Cite.prototype.onReferences = function ( token, manager ) {
|
|||
if ( token.constructor === EndTagTk ) {
|
||||
return {};
|
||||
}
|
||||
|
||||
|
||||
//console.warn( 'references refGroups:' + JSON.stringify( this.refGroups, null, 2 ) );
|
||||
|
||||
var refGroups = this.refGroups;
|
||||
|
||||
|
||||
var arrow = '↑';
|
||||
var renderLine = function( ref ) {
|
||||
var out = [ new TagTk('li', [new KV('id', ref.target)] ) ];
|
||||
if (ref.linkbacks.length == 1) {
|
||||
if (ref.linkbacks.length === 1) {
|
||||
out = out.concat([
|
||||
new TagTk( 'a', [
|
||||
new KV('href', '#' + ref.linkbacks[0])
|
||||
|
@ -147,7 +151,7 @@ Cite.prototype.onReferences = function ( token, manager ) {
|
|||
//console.warn( 'renderLine res: ' + JSON.stringify( out, null, 2 ));
|
||||
return out;
|
||||
};
|
||||
|
||||
|
||||
var res;
|
||||
|
||||
var options = $.extend({
|
||||
|
@ -217,6 +221,6 @@ Cite.prototype.getRefGroup = function(group) {
|
|||
return refGroups[group];
|
||||
};
|
||||
|
||||
if (typeof module == "object") {
|
||||
if (typeof module === "object") {
|
||||
module.exports.Cite = Cite;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue