User "Wikinaut" posted a comment on MediaWiki.r94702.

Full URL: http://www.mediawiki.org/wiki/Special:Code/MediaWiki/94702#c21035
Commit summary:

Fix a regression in search highlighting from r90092

Followup on r94609, r94681 test cases.
This fixes the test case with a period that was failing; problem was not the 
period, but the space before.
The changed regex in r90092 ended up including the preceding whitespace in the 
match, so the position of the match was coming up one character before the 
actual word -- thus offsetting the highlight by one char.

Changed from search to match, using the regex's index property (same as search 
returns) and adding in the length of the first match component which covers the 
space/whatever

Comment:

Summary: works.

Further comment regarding the way, the highlighter works (it splits the 
"needle" into space-separated "needles", which are then searched and marked).

Hi, I succesfully and for the first time used 
http://localhost/tests/qunit/?filter=jquery.highlightText%3A%20Check . this is 
a neat tool, thanks for the hint. In my local copy I added some more test 
vectors, which I will commit later.

The current function $.highlightText says clearly in the beginning
"// Split our pattern string at spaces and run our highlight function on the 
results"

Thus the result of the highlighter of "Blue Öyster Haystack" with needle "Blue 
Ö" is

<pre>
<span class="highlight">Blue</span> <span class="highlight">Ö</span>yster 
Haystack
</pre>

i.e. "Blue" and "Ö" matched and marked separately.

Others (like me) would (perhaps) expect to receive
<pre>
<span class="highlight">Blue Ö</span>yster Haystack
</pre>
which looks smarter when you have the highlight function in suggestions.js with 
extension Vector.

I just wanted to point out, that the current function indeed treats a sequence 
of words as single space-separated terms, which are then searched, and the 
matches are highlighted ''separately''. I am going to add test vectors and 
expected results for this behaviour.

_______________________________________________
MediaWiki-CodeReview mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-codereview

Reply via email to