mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-15 02:23:58 +00:00
Pre and link target improvements
* Don't explicitly add the newline in the pre, as we preserve newline tokens now. This avoids doubling of newlines when round-tripping. * Use the sHref attribute even if the href contains spaces. Change-Id: I8bec8fbfd6a7836bf2e5eec20869a0edd95c93b6
This commit is contained in:
parent
ee2ddbd3cb
commit
92f753a365
|
@ -122,9 +122,7 @@ WSP._linkHandler = function( state, token ) {
|
|||
var attribDict = state.env.KVtoHash( token.attribs );
|
||||
if ( attribDict.rel && attribDict.href !== undefined ) {
|
||||
var target = decodeURIComponent(
|
||||
attribDict.href.substr( state.env.wgScriptPath.length + 1 )
|
||||
.replace( /_/g, ' ' )
|
||||
);
|
||||
attribDict.href.substr( state.env.wgScriptPath.length + 1 ) );
|
||||
if ( token.dataAttribs.sHref ) {
|
||||
//console.warn( JSON.stringify( token.dataAttribs.sHref ) );
|
||||
var normalizedOrigHref = state.env.resolveTitle(
|
||||
|
@ -134,6 +132,8 @@ WSP._linkHandler = function( state, token ) {
|
|||
if ( normalizedOrigHref === target ) {
|
||||
target = token.dataAttribs.sHref;
|
||||
}
|
||||
} else {
|
||||
target = target.replace( /_/g, ' ' )
|
||||
}
|
||||
|
||||
if ( attribDict.rel === 'mw:wikiLink' ) {
|
||||
|
@ -268,7 +268,7 @@ WSP.tagToWikitext = {
|
|||
// XXX: support indent variant instead by registering a newline handler?
|
||||
pre: {
|
||||
start: function( state, token ) {
|
||||
state.textHandler = function( t ) { return t.replace( '\n', '\n ' ); };
|
||||
state.textHandler = function( t ) { return t.replace( /\n/g, '\n ' ); };
|
||||
return '';
|
||||
},
|
||||
end: function( state, token) { state.textHandler = null; return ''; }
|
||||
|
|
|
@ -1107,7 +1107,7 @@ pre_indent_in_tags
|
|||
/ & { return stops.dec('pre'); }
|
||||
|
||||
pre_indent_line = space l:inlineline {
|
||||
return [ '\n' ].concat(l);
|
||||
return l;
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
Loading…
Reference in a new issue