diff --git a/.gitignore b/.gitignore index a60c65ef30..80b08e8df4 100644 --- a/.gitignore +++ b/.gitignore @@ -3,5 +3,5 @@ *.kate-swp .*.swp -modules/parser/node_modules/ -api/npm-debug.log \ No newline at end of file +api/npm-debug.log +modules/parser/node_modules/ \ No newline at end of file diff --git a/VisualEditor.alias.php b/VisualEditor.alias.php index 058ac78321..b2657d8ea9 100644 --- a/VisualEditor.alias.php +++ b/VisualEditor.alias.php @@ -13,22 +13,37 @@ $specialPageAliases['en'] = array( 'VisualEditorSandbox' => array( 'VisualEditorSandbox' ), ); +/** Arabic (العربية) */ +$specialPageAliases['ar'] = array( + 'VisualEditorSandbox' => array( 'ملعب_المحرر_المرئي' ), +); + /** German (Deutsch) */ $specialPageAliases['de'] = array( 'VisualEditorSandbox' => array( 'WYSIWYG-Editor-Spielwiese' ), ); +/** Zazaki (Zazaki) */ +$specialPageAliases['diq'] = array( + 'VisualEditorSandbox' => array( 'AsengiyaDorakumdêVurneri' ), +); + /** Swiss German (Alemannisch) */ $specialPageAliases['gsw'] = array( 'VisualEditorSandbox' => array( 'WYSIWYG-Editor-Sandchaschte' ), ); -/** Interlingua (Interlingua) */ +/** Interlingua (interlingua) */ $specialPageAliases['ia'] = array( 'VisualEditorSandbox' => array( 'Cassa_a_sablo_visual' ), ); -/** Macedonian (Македонски) */ +/** Korean (한국어) */ +$specialPageAliases['ko'] = array( + 'VisualEditorSandbox' => array( '시각편집실험실' ), +); + +/** Macedonian (македонски) */ $specialPageAliases['mk'] = array( 'VisualEditorSandbox' => array( 'ПесокЛиковенУредник' ), ); \ No newline at end of file diff --git a/modules/parser/mediawiki.WikitextSerializer.js b/modules/parser/mediawiki.WikitextSerializer.js index b76a984997..f3fd08664f 100644 --- a/modules/parser/mediawiki.WikitextSerializer.js +++ b/modules/parser/mediawiki.WikitextSerializer.js @@ -68,7 +68,7 @@ WSP._listEndHandler = function( state, token ) { WSP._listItemHandler = function ( bullet, state, token ) { //console.warn( JSON.stringify( state.listStack ) ); var stack = state.listStack; - state.needParagraphLines = true; + // state.needParagraphLines = true; if (stack.length === 0) { return bullet; } else { @@ -262,7 +262,11 @@ WSP.tagToWikitext = { caption: { start: WSP._serializeTableTag.bind(null, "|+", ' |', 1) }, p: { start: function( state, token ) { - if (state.needParagraphLines) { + if (state.listStack.length > 0) { + // SSS FIXME: Other tags that have similar requirements within lists? + // Paragraphs within lists are not expanded + return ''; + } else if (state.needParagraphLines) { return WSP.getNewLines( state, 2 ); } else { state.needParagraphLines = true; @@ -362,6 +366,27 @@ WSP.getNewLines = function ( state, n ) { return out; }; +WSP.defaultHTMLTagHandler = { + start: WSP._serializeHTMLTag, + end : WSP._serializeHTMLEndTag +}; + +WSP.getTokenHandler = function(state, token) { + if (token.dataAttribs.stx === 'html') return this.defaultHTMLTagHandler; + + var tname = token.name; + if (tname === "p" && state.listStack.length > 0) { + // We dont want paragraphs in list context expanded. + // Retain them as html tags. + // + // SSS FIXME: any other cases like this? + return this.defaultHTMLTagHandler; + } else { + var handler = this.tagToWikitext[tname]; + return handler ? handler : this.defaultHTMLTagHandler; + } +}; + /** * Serialize a token. */ @@ -369,45 +394,21 @@ WSP._serializeToken = function ( state, token ) { state.prevToken = state.curToken; state.curToken = token; var handler, - res = '', + res, dropContent = state.dropContent; //console.warn( 'st: ' + JSON.stringify( token ) ); switch( token.constructor ) { case TagTk: case SelfclosingTagTk: - if ( token.dataAttribs.stx === 'html' ) { - res = WSP._serializeHTMLTag( state, token ); - } else { - handler = this.tagToWikitext[token.name]; - if ( handler ) { - if ( handler.start ) { - res = handler.start( state, token ); - } - } else { - res = WSP._serializeHTMLTag( state, token ); - } - } + handler = WSP.getTokenHandler(state, token); + res = handler.start ? handler.start( state, token ) : null; break; case EndTagTk: - if ( token.dataAttribs.stx === 'html' ) { - res = WSP._serializeHTMLEndTag( state, token ); - } else { - handler = this.tagToWikitext[token.name]; - if ( handler ) { - if ( handler.end ) { - res = handler.end( state, token ); - } - } else { - res = WSP._serializeHTMLEndTag( state, token ); - } - } + handler = WSP.getTokenHandler(state, token); + res = handler.end ? handler.end( state, token ) : null; break; case String: - if ( state.textHandler ) { - res = state.textHandler( token ); - } else { - res = token; - } + res = state.textHandler ? state.textHandler( token ) : token; break; case CommentTk: res = ''; @@ -416,13 +417,15 @@ WSP._serializeToken = function ( state, token ) { res = '\n'; break; case EOFTk: + res = null; break; default: + res = null; console.warn( 'Unhandled token type ' + JSON.stringify( token ) ); break; } //console.warn( 'res: ' + JSON.stringify( res ) ); - if ( res !== '' ) { + if (res) { var nls = res.match( /(?:\r?\n)+$/ ); if ( nls ) { if ( nls[0] === res ) {