substring highlight
-
Hi all, first post here.
Is it possible to highlight a part of a string in some way? Doesn't really matter how it will be highlighted, whether via colour or with bold letters.
Thanks,
Louizos
-
The easiest way I can think to do this is to convert lowercase, to uppercase ( I would use Javascript it has great text parsing features). If you know all text is lowercase, you can then just return the text to lowercase when you go to hightlight another word/phrase.
The Text Draw actor doesn't offer format targeting, so there are limited options.
Another option, might be to Cut the text (only works if you have a know number of highlights... ideally 1) so that the first block is Non highlighted, then with another Text Draw Actor you place the Hightlighted text, and again flowup with another text draw actor with the remaining non-hightlighted text. -
I did give Javascript a try with the Javascript actor. This is the code:
function main() {
var result = '', str = arguments[0], start = arguments[1], end = arguments[2];
result += (str.substring(0, start) + '<span style="color:red">' + str.substring(start, end) + '</span>' + str.substring(end, str.length))
return result;
}
I do not understand though why I should convert everything to lower
case. Can't Javascript just parse the string at a specific point, being
case agnostic?
Anyway, the code I pasted above does parse the text according to its
second input, but this code does contain some HTML which doesn't work
with the Javascript actor. The output is a string parsed at the given
spot, but all the HTML stuff is displayed too. What do I have to write
to omit HTML altogether?
thanksLouizos
-
how are you getting the text? Can the html be stripped before Isadora?
Otherwise you may have to first remove any tags from the text... it should be possible to use regular expressions to remove anything found between '<' and '>'.
Or you could strip each tag individually.
-
I'm receiving the text as strings received via OSC. Not an Isadora-savvy, so can you provide an example as to how to use regular expressions to strip these? To be honest, I didn't even know there's a RegEx actor in Isadora.
-
@louizos well it may be easiest to strip these before being sent. I suggest looking at options in that side first. Perhaps unformatted is an option?
Regex is built into Javascript so it would be done in a short script.
If you can post a text example that you see getting I can workout some Regex to get the job done.