Steve,

Just a quick response for now. As I am not exactly sure of the mechanism 
you are trying to use.

   - Are you aware of the freelinks plugin?, if the tiddler title exists it 
   will be highlighted in the text. It may be a more general solution.
      - This plugin is making use of other mechanisms to add the highlight 
      layer on the text, in fact generates links.
   - We now have search and contains operators that may make detecting a 
   string more easily. Rather than select="0" you could also use the First 
   operator.
   - The splitregexp is powerful but so too are the standard filters.
   - I would be tempted to keep the highlight outside the filter, but 
   that's me.
   - Perhaps try and concatenate the strings outside the filter
   - Sometimes wikifying is needed to ensure the value you expect is in use 
   but since you not using variables/macros to do this it may not be relevant 
   until you use them.

Regards
Tony


On Tuesday, July 21, 2020 at 6:55:57 AM UTC+10, steve wrote:
>
> Hello:
>
> I am working on a macro to highlight target strings within the text field 
> of a tiddler.  
> The use case is to make it easier to for me see where the targetStrings 
> are (if any).   
>
> My question is how to highlight the targetString in the macro (ie. 
> treating 
> the macro as a string) as opposed to (apparently) executing the macro 
> and highlighting the targetString in the output.
>
> !!! Here is the macro
> ```
> \define formatTid.highlightText(inputText targetString)
>
> <$set name="outputText" filter="[[$inputText$]] 
> +[splitregexp[\b$targetString$\b]join[@@color:blue;$targetString$@@]]" 
> select="0">
>
> | ''outputText''|<<outputText>> |
>
> \end
> <$macrocall $name="formatTid.highlightText" 
> inputText={{highlightTest.sentence!!text}} targetString="goFish"/>
> ```
>
> The macro works as expected (goFish is highlighted in blue) when the text 
> field contains
>
> ```
> This goFish is in a sentence.
> ```
>
> The macro works partially (i.e., goFish is highlighted only for the 
> comment).
>
> ```
> \define goFish()
>
> !!! This example has three instances of goFish.
>
> \end
> <<goFish>>
> ```
>

-- 
You received this message because you are subscribed to the Google Groups 
"TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tiddlywiki/fe78b28b-e58b-48d1-81b4-c1f061d2911do%40googlegroups.com.

Reply via email to