Hi folks, is there a good video that gives a practical explanation of how to use highlighters in the “hints” template please? If possible, I’m looking for a step by step guide that takes nothing for granted and gives plenty of examples designed to guide non coders. Best wishes and thanks.
To answer that what exactly are you trying to do with highlighters (so nothing is taken for granted in the answer)? As most users use the same tools in the overall app toolbox differently, there isn’t a one-size-fits-all solution. But, have you read these notes on the highlighter feature? It includes code examples of all the features you can set. Obviously as we don’t know your usage, it is difficult, in advance to write an individually tailored example.
So, what did you try? Why not post a document showing what you tried and explaining what you thought would happen vs. what happened. That would be a faster.
Note that whilst the system highlights—according to the syntax you set—any matching terms, altering such text to no longer match doesn’t remove the RHF ‘highlight’ formatting. IOW, this methods adds RTF styling to a note but doesn’t remove it. It is not a dynamic highlight depending on a match or not.
The a highlighter can remove highlights, too. For example, consider this simplified version of the syntax highlighter:
pattern: :.+ color: black pattern: yes|no|bold|italic|strike|underline case-sensitive: NO color: bright red
This makes everything black, but then makes some keywords bright red.
I stand corrected! Up to a point though, because…
Can the ‘default’ color use $TextColor? Otherwise, if I set the $TextColor to a dark blue, highlight resetting will fail as non-matched items will be the wrong colour in the note, i.e. black as opposed to dark blue. Indeed if another note used green text…
This isn’t to quibble. For 99% I’m sure the method posted will work just fine, as it will if all notes use the same non-default text colour (remembering to set the ‘reset’ highlight to the desired colour instead of black.
I assume the
pattern: :.+ must come first in the list of highlight rules otherwise it will reset everything as
.+ matches _all $Text`.
I’ve made a note to document this as I don’t think this aspect is explained anywhere in detail.
I don’t think this case is accounted for. Yes, rules are interpreted sequentially.
In the default Syntax highlighter in hints I see this:
That second colon looks superfluous and makes no regex sense in terms of the task of this highlight rule. This seems to work as well:
Interestingly, if the rules do run sequentially, e.g.:
Then anything coloured bright blue by the first pattern should immediately be reset to black by the second pattern. However, in a note using this built-in highlighter the word ‘strike’ is coloured bright blue and not black. Odd. As the OP wanted an ambiguity-free description I’m struggling. The highlighting seems to work as described.
Several other oddities:
- It seems like you need to de-/re-select a note in order for changes to the highlighter code note to be reflected by the highlighting
- I think re-setting is built-in but not via the
color: blackpattern. I removed the latter from the built-in ‘syntax’ highlighter file. Un-highlighting of word that were changed still worked, resetting black (current $TextColor)
- I turned off highlighting, set a notes $TextColor to red and reset the text (i.e. $Text is now ‘red’). I turned highlighting back on and items highlighted or re-coloured to red (i.e. $TextColor not black) when a word no longer matched a pattern. Adding back the removed pattern did no cause anything to turn black.
So, de-highlighting seems to be baked in (using $TextColor as base colour). Could be that the pattern:
pattern: :.+ color: black
Is an artefact from early design that got left in the built-in file but actually has no purpose?
The second rule says, "Turn everything black except text before the colon. That preserves the coloring of pattern in rule 1.
Yes, all this is an artifact of earlier designs, but it may be useful.