[pmwiki-users] Highlighting Pagelist Results [was:Recipe Update: Fox]

Hans design5 at softflow.co.uk
Tue Jan 29 12:47:29 CST 2008

Tuesday, January 29, 2008, 6:20:06 PM, The Editor wrote:

>> I have the /i qualifier switched for all preg match and replace calls.

> Thank you! Works great... I don't suppose there's a way to get the
> output to keep the same case as the original. Using this everything
> gets switched to lowercase.

Hmm, not for me. It stays as it was.

>> > 2) When doing a boolean like apples && oranges--I also get the matches
>> > but not the display
>> apples & oranges would need to be entered as regex: apples|oranges

> Yes, I know. It's just I'm using the actual search term entered in the
> regex for the highlighting. I could try and do some substitutions or
> something, but it gets messy fast.

I use the following as the basic highlight pattern:

$row = preg_replace("/($pat)/".$qi,"'''$1'''", $row);

$pat is straight from the input. $qi can be i for insensitive search.
whatever match is found is just enclosed with '''    ''' markup, no
changing of case, and longer phrases work just as well.

I use more complicated highlight patterns for cases where the term is
inside escape markup [@ .... @] etc. to escape the escape!
This is the most tricky part really.

>> > 3) When searching for a phrase I get false matches. IE pages with the
>> > words--but not the phrase
>> can this be because you apply wordboundary character \b ?

> No, it's because of the problem above. "this is a phrase" in the
> search engine gets treated as "this && is && a && phrase" which of
> course does not occur. I don't think PmWiki yet has boolean operators
> like this, (or phrase searching for that matter) apart from the work
> you have been doing. And BoltWire indexes words but not phrases.

As said: "this is a phrase" will just be turned into
'''this is a phrase'''

There is no 'taking apart' happening like you describe.

"this is a phrase" will be literally matched.
To match any part I need to use this|is|a|phrase which is no phrase
any longer!
to match a text line to have both apples and oranges somewhere,
use (apples.*?oranges)|(oranges.*?apples)
which is rather complicated for a boolean AND.
But is it needed that much?

Most often someone looks for apples OR oranges; text lines which
contain any of the terms.


More information about the pmwiki-users mailing list