mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-15 10:35:48 +00:00
Basic rt support for indent pre variant
* Added a generic stx_v 'syntax variant' round-trip attribute * For pre, use stx:'html' vs. no syntax annotation. This might not be 100% safe for arbitrary html input, so we might want to flip this to stx:'wiki' later. * 181 round-trip tests passing Change-Id: If6080917a3a7c069066db3db60efe59b1f6c28d8
This commit is contained in:
parent
c52c24b0cb
commit
b2adee0ae7
|
@ -193,7 +193,7 @@ WSP.tagToWikitext = {
|
||||||
tbody: {},
|
tbody: {},
|
||||||
th: {
|
th: {
|
||||||
start: function ( state, token ) {
|
start: function ( state, token ) {
|
||||||
if ( token.dataAttribs.t_stx === 'row' ) {
|
if ( token.dataAttribs.stx_v === 'row' ) {
|
||||||
return WSP._serializeTableTag("!!", ' |', state, token);
|
return WSP._serializeTableTag("!!", ' |', state, token);
|
||||||
} else {
|
} else {
|
||||||
return WSP._serializeTableTag("\n!", ' |', state, token);
|
return WSP._serializeTableTag("\n!", ' |', state, token);
|
||||||
|
@ -212,7 +212,7 @@ WSP.tagToWikitext = {
|
||||||
},
|
},
|
||||||
td: {
|
td: {
|
||||||
start: function ( state, token ) {
|
start: function ( state, token ) {
|
||||||
if ( token.dataAttribs.t_stx === 'row' ) {
|
if ( token.dataAttribs.stx_v === 'row' ) {
|
||||||
return WSP._serializeTableTag("||", ' |', state, token);
|
return WSP._serializeTableTag("||", ' |', state, token);
|
||||||
} else {
|
} else {
|
||||||
return WSP._serializeTableTag("\n|", ' |', state, token);
|
return WSP._serializeTableTag("\n|", ' |', state, token);
|
||||||
|
@ -237,7 +237,14 @@ WSP.tagToWikitext = {
|
||||||
h4: { start: id("\n\n===="), end: id("====\n") },
|
h4: { start: id("\n\n===="), end: id("====\n") },
|
||||||
h5: { start: id("\n\n====="), end: id("=====\n") },
|
h5: { start: id("\n\n====="), end: id("=====\n") },
|
||||||
h6: { start: id("\n\n======"), end: id("======\n") },
|
h6: { start: id("\n\n======"), end: id("======\n") },
|
||||||
pre: { start: id("<pre>"), end: id("</pre>") },
|
// XXX: support indent variant instead by registering a newline handler?
|
||||||
|
pre: {
|
||||||
|
start: function( state, token ) {
|
||||||
|
state.textHandler = function( t ) { return t.replace( '\n', '\n ' ); };
|
||||||
|
return '';
|
||||||
|
},
|
||||||
|
end: function( state, token) { state.textHandler = null; return ''; }
|
||||||
|
},
|
||||||
a: { start: WSP._linkHandler, end: WSP._linkEndHandler },
|
a: { start: WSP._linkHandler, end: WSP._linkEndHandler },
|
||||||
meta: {
|
meta: {
|
||||||
start: function ( state, token ) {
|
start: function ( state, token ) {
|
||||||
|
@ -347,7 +354,11 @@ WSP._serializeToken = function ( state, token ) {
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case String:
|
case String:
|
||||||
|
if ( state.textHandler ) {
|
||||||
|
res = state.textHandler( token );
|
||||||
|
} else {
|
||||||
res = token;
|
res = token;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case CommentTk:
|
case CommentTk:
|
||||||
res = '<!--' + token.value + '-->';
|
res = '<!--' + token.value + '-->';
|
||||||
|
|
|
@ -1081,7 +1081,7 @@ pre
|
||||||
("</pre>" / eof) {
|
("</pre>" / eof) {
|
||||||
// return nowiki tags as well?
|
// return nowiki tags as well?
|
||||||
//console.warn('inpre');
|
//console.warn('inpre');
|
||||||
return [ new TagTk( 'pre', attribs ) ]
|
return [ new TagTk( 'pre', attribs, { stx: 'html' } ) ]
|
||||||
.concat(ts, [ new EndTagTk( 'pre' ) ]);
|
.concat(ts, [ new EndTagTk( 'pre' ) ]);
|
||||||
}
|
}
|
||||||
/ "</pre>" { return "</pre>"; }
|
/ "</pre>" { return "</pre>"; }
|
||||||
|
@ -1446,7 +1446,7 @@ table_row_tag
|
||||||
table_data_tags
|
table_data_tags
|
||||||
= pipe
|
= pipe
|
||||||
td:table_data_tag
|
td:table_data_tag
|
||||||
tds:( pipe_pipe tdt:table_data_tag { tdt[0].dataAttribs.t_stx = 'row'; return tdt } )* {
|
tds:( pipe_pipe tdt:table_data_tag { tdt[0].dataAttribs.stx_v = 'row'; return tdt } )* {
|
||||||
return td.concat(tds);
|
return td.concat(tds);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1470,7 +1470,7 @@ table_heading_tags
|
||||||
= //& { console.warn( 'th enter @' + input.substr(pos, 10)); return true; }
|
= //& { console.warn( 'th enter @' + input.substr(pos, 10)); return true; }
|
||||||
"!"
|
"!"
|
||||||
th:table_heading_tag
|
th:table_heading_tag
|
||||||
ths:( "!!" tht:table_heading_tag { tht[0].dataAttribs.t_stx = 'row'; return tht } )* {
|
ths:( "!!" tht:table_heading_tag { tht[0].dataAttribs.stx_v = 'row'; return tht } )* {
|
||||||
//console.warn( 'thts: ' + pp(th.concat(ths)));
|
//console.warn( 'thts: ' + pp(th.concat(ths)));
|
||||||
return th.concat(ths);
|
return th.concat(ths);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue