jenkins-bot has submitted this change and it was merged.
Change subject: Fix pattern for matching wikitext headings
......................................................................
Fix pattern for matching wikitext headings
Fix the back-reference to \1 (1st set of brakcets).
Add an test to make sure the example sequences actually trigger the
wikitextString handler, and tweak test to ensure that the start-of-line
restriction in the heading regexp doesn't affect link matches.
Change-Id: I76187a12292a4923d1ee2505cfb955431ac252bb
---
M
modules/ve-mw/tests/ui/datatransferhandlers/ve.ui.MWWikitextStringTransferHandler.test.js
M modules/ve-mw/ui/datatransferhandlers/ve.ui.MWWikitextStringTransferHandler.js
2 files changed, 22 insertions(+), 5 deletions(-)
Approvals:
Cscott: Looks good to me, but someone else must approve
Jforrester: Looks good to me, but someone else must approve
Esanders: Looks good to me, approved
jenkins-bot: Verified
diff --git
a/modules/ve-mw/tests/ui/datatransferhandlers/ve.ui.MWWikitextStringTransferHandler.test.js
b/modules/ve-mw/tests/ui/datatransferhandlers/ve.ui.MWWikitextStringTransferHandler.test.js
index d57deb9..33c1521 100644
---
a/modules/ve-mw/tests/ui/datatransferhandlers/ve.ui.MWWikitextStringTransferHandler.test.js
+++
b/modules/ve-mw/tests/ui/datatransferhandlers/ve.ui.MWWikitextStringTransferHandler.test.js
@@ -15,7 +15,7 @@
/* Tests */
function runWikitextStringHandlerTest( assert, server, string, mimeType,
expectedResponse, expectedData, annotations, msg ) {
- var handler, i, j,
+ var handler, i, j, name,
done = assert.async(),
item = ve.ui.DataTransferItem.static.newFromString( string,
mimeType ),
doc = ve.dm.example.createExampleDocument(),
@@ -39,6 +39,10 @@
}
}
}
+
+ // Check we match the wikitext string handler
+ name = ve.ui.dataTransferHandlerFactory.getHandlerNameForItem( item );
+ assert.strictEqual( name, 'wikitextString', msg + ': triggers match
function' );
// Invoke the handler
handler = ve.ui.dataTransferHandlerFactory.create( 'wikitextString',
mockSurface, item );
@@ -65,9 +69,12 @@
cases = [
{
msg: 'Simple link',
- pasteString: '[[Foo]]',
+ // Put link in the middle of text to verify
that the
+ // start-of-line and end-or-line anchors on the
heading
+ // identification pattern don't affect link
identification
+ pasteString: 'some [[Foo]] text',
pasteType: 'text/plain',
- parsoidResponse: '<body
data-parsoid=\'{"dsr":[0,7,0,0]}\' lang="en" class="mw-content-ltr sitedir-ltr
ltr mw-body mw-body-content mediawiki" dir="ltr"><p
data-parsoid=\'{"dsr":[0,7,0,0]}\'><a rel="mw:WikiLink" href="./Foo"
title="Foo"
data-parsoid=\'{"stx":"simple","a":{"href":"./Foo"},"sa":{"href":"Foo"},"dsr":[0,7,2,2]}\'>Foo</a></p></body>',
+ parsoidResponse: '<body
data-parsoid=\'{"dsr":[0,17,0,0]}\' lang="en" class="mw-content-ltr sitedir-ltr
ltr mw-body mw-body-content mediawiki" dir="ltr"><p
data-parsoid=\'{"dsr":[0,17,0,0]}\'>some <a rel="mw:WikiLink" href="./Foo"
title="Foo"
data-parsoid=\'{"stx":"simple","a":{"href":"./Foo"},"sa":{"href":"Foo"},"dsr":[5,12,2,2]}\'>Foo</a>
text</p></body>',
annotations: [ {
type: 'link/mwInternal',
attributes: {
@@ -79,9 +86,19 @@
}
} ],
expectedData: [
+ 's',
+ 'o',
+ 'm',
+ 'e',
+ ' ',
[ 'F', [ 0 ] ],
[ 'o', [ 0 ] ],
[ 'o', [ 0 ] ],
+ ' ',
+ 't',
+ 'e',
+ 'x',
+ 't',
{ type: 'internalList' },
{ type: '/internalList' }
]
@@ -226,7 +243,7 @@
}
];
- QUnit.expect( cases.length );
+ QUnit.expect( cases.length * 2 );
for ( i = 0; i < cases.length; i++ ) {
runWikitextStringHandlerTest( assert, this.server, cases[ i
].pasteString, cases[ i ].pasteType, cases[ i ].parsoidResponse, cases[ i
].expectedData, cases[ i ].annotations, cases[ i ].msg );
}
diff --git
a/modules/ve-mw/ui/datatransferhandlers/ve.ui.MWWikitextStringTransferHandler.js
b/modules/ve-mw/ui/datatransferhandlers/ve.ui.MWWikitextStringTransferHandler.js
index e520c2b..f03e63a 100644
---
a/modules/ve-mw/ui/datatransferhandlers/ve.ui.MWWikitextStringTransferHandler.js
+++
b/modules/ve-mw/ui/datatransferhandlers/ve.ui.MWWikitextStringTransferHandler.js
@@ -43,7 +43,7 @@
* which occur on a single line of max 80 characters.
*/
ve.ui.MWWikitextStringTransferHandler.static.matchRegExp =
- /(^\s*(={2,6})[^=\r\n]{1,80}\1\s*$)|\[\[.{1,80}\]\]|\{\{.{1,80}\}\}/m;
+ /(^\s*(={2,6})[^=\r\n]{1,80}\2\s*$)|\[\[.{1,80}\]\]|\{\{.{1,80}\}\}/m;
ve.ui.MWWikitextStringTransferHandler.static.matchFunction = function ( item )
{
var text = item.getAsString();
--
To view, visit https://gerrit.wikimedia.org/r/233201
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I76187a12292a4923d1ee2505cfb955431ac252bb
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/extensions/VisualEditor
Gerrit-Branch: master
Gerrit-Owner: Esanders <[email protected]>
Gerrit-Reviewer: Cscott <[email protected]>
Gerrit-Reviewer: Esanders <[email protected]>
Gerrit-Reviewer: Jforrester <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits