mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-25 06:46:26 +00:00
Fix round-tripping of invalid external links somewhat
* Don't consider them for auto-numbered links * Don't insert a trailing space if the content is empty These links are still wrapped in nowiki on round-tripping since the valid/invalid url determination is done in the LinkHandler and not the Tokenizer as it is configuration-dependent. Not incorrect for rendering (and perhaps easier to understand for humans too), but might still introduce a dirty diff. We'll still need reconciliation / damage tracking in the end ;) Change-Id: I959ebc1b7f81d110a1141bb38ba5ee97f52ebf96
This commit is contained in:
parent
198e55a32b
commit
e1a7d10063
|
@ -412,11 +412,11 @@ ExternalLinkHandler.prototype.onExtLink = function ( token, manager, cb ) {
|
|||
//console.warn('extlink href: ' + href );
|
||||
//console.warn( 'content: ' + JSON.stringify( content, null, 2 ) );
|
||||
// validate the href
|
||||
if ( ! content.length ) {
|
||||
content = ['[' + this.linkCount + ']'];
|
||||
this.linkCount++;
|
||||
}
|
||||
if ( this.imageParser.tokenizeURL( href ) ) {
|
||||
if ( ! content.length ) {
|
||||
content = ['[' + this.linkCount + ']'];
|
||||
this.linkCount++;
|
||||
}
|
||||
if ( content.length === 1 &&
|
||||
content[0].constructor === String &&
|
||||
this.imageParser.tokenizeURL( content[0] ) &&
|
||||
|
@ -446,8 +446,14 @@ ExternalLinkHandler.prototype.onExtLink = function ( token, manager, cb ) {
|
|||
].concat( content, [ new EndTagTk( 'a' )])
|
||||
} );
|
||||
} else {
|
||||
var tokens = ['[', href ];
|
||||
if ( content.length ) {
|
||||
tokens = tokens.concat( [' '], content );
|
||||
}
|
||||
tokens.push(']');
|
||||
|
||||
cb( {
|
||||
tokens: ['[', href, ' ' ].concat( content, [']'] )
|
||||
tokens: tokens
|
||||
} );
|
||||
}
|
||||
};
|
||||
|
|
|
@ -1548,7 +1548,7 @@ table_data_tags
|
|||
td:table_data_tag
|
||||
tagEndPos:({return pos})
|
||||
tds:( pipe_pipe tdt:table_data_tag { tdt[0].dataAttribs.stx_v = 'row'; return tdt } )* {
|
||||
td[0].dataAttribs.tsr = [pos0, tagEndPos];
|
||||
td[0].dataAttribs.tsr[0] = pos0;
|
||||
return td.concat(tds);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue