renderer.article: Bold the title no matter what the trailing characters

Bug: T69229
Change-Id: I833c0dcae98010bc74b6b58ae8035aaac4e6465b
This commit is contained in:
Prateek Saxena 2015-01-02 16:27:35 +05:30
parent a43ef7ca51
commit df0b988eec
2 changed files with 14 additions and 2 deletions

View file

@ -155,7 +155,7 @@
title = title.replace( /([.?*+^$[\]\\(){}|-])/g, '\\$1' ); // Escape RegExp elements
var elements = [],
regExp = new RegExp( '(^|\\s)(' + title + ')(\\s|$)', 'ig' ),
regExp = new RegExp( '(^|\\s)(' + title + ')(|$)', 'ig' ),
boldIdentifier = '<bi-' + Math.random() + '>',
snip = '<snip-' + Math.random() + '>';

View file

@ -2,7 +2,7 @@
QUnit.module( 'ext.popups' );
QUnit.test( 'render.article.getProcessedElements', function ( assert ) {
QUnit.expect( 9 );
QUnit.expect( 11 );
function test ( extract, title, expected, msg ) {
var $div = $( '<div>' ).append(
@ -29,6 +29,12 @@
'Extract with text in parentheses'
);
test(
'Person, (was born in Location) is good', 'Person',
'<b>Person</b>, is good',
'Comma after title'
);
test(
'Person (was born in Location (at Time)) is good', 'Person',
'<b>Person</b> is good',
@ -41,6 +47,12 @@
'Extract with nested parentheses and random spaces'
);
test(
'I like trains', 'Train',
'I like <b>train</b>s',
'Make the simple plural bold'
);
test(
'Brackets ) are funny ( when not used properly', 'Brackets',
'<b>Brackets</b> ) are funny ( when not used properly',