Page 1 of 1

Using strfmt "%m" with I and C subflags for customized highlighting

Posted: Thu Jun 02, 2011 6:29 pm
by barry.marcus
I've just started experimenting with marking up fetched URLs with the following basic code:

<fetch $theURL>
<strfmt "%mIes" $theQuery $ret>

However, I do not want to settle for the default markup style, i.e., different color background for each term. The documentation references a way to use inline styles to do this, but it's not clear to me how to proceed. Specifically, instead of having the hits appear as black on various colors, I would like ALL the hits to appear as red on whatever the background color happens to be. (This is OK for the URLs we will be fetching, since the fetched pages are very text-heavy and the background is always white.

A nudge in the direction of how to do this would be greatly appreciated. Thanks.

Using strfmt "%m" with I and C subflags for customized highlighting

Posted: Fri Jun 03, 2011 9:54 am
by mark
Use C instead of I to get classes instead of inline styles. Then predefine the classes "queryset1", "queryset2", etc. up to the max expected number of query terms. Define them all to be color red.

<fetch $theURL>
<strfmt "%mCes" $theQuery $ret>
<$markedup=$ret>
<style>
.queryset2 {color:red;}
.queryset3 {color:red;}
...
</style>
<send $markedup>

Using strfmt "%m" with I and C subflags for customized highlighting

Posted: Fri Jun 03, 2011 11:54 am
by barry.marcus
Thanks. That works well.

Now I'm wondering if there is a way to code it so that it does not matter how many terms there are in my query, since sometimes there will be just 2 or 3, and sometimes there may be as many as 40 or 50. It seems inelegant to have to list 50 styles (or loop 50 times) when they are all the same. The documentation for <fmtcp querysetcyclenum> and <fmtcp querysetclasses> and <fmtcp querysetstyles> seem to imply that styles can be "recycled" without having to explicitly declare every one. I'm thinking that I'd do something such as declare querysetcyclenum as 1 and then declare a single style (queryset1 ?). I can't seem to get that to work right, though.

Thanks.

Using strfmt "%m" with I and C subflags for customized highlighting

Posted: Fri Jun 03, 2011 2:10 pm
by mark
By default you'd really only need 10 styles since that's the default cycle number. Using
<fmtcp querysetcyclenum 1>
works for me so that it always uses the one class "queryset1". I didn't change any other fmtcp settings.

Using strfmt "%m" with I and C subflags for customized highlighting

Posted: Fri Jun 03, 2011 2:19 pm
by barry.marcus
Argh... Dumb mistake on my part. I was calling <fmtcp querysetcyclenum 1> *after* <strfmt>. When I put <fmtcp> call before <strfmt> it works just fine!

Thanks for your help, Mark.