• Isadora
  • Get it
  • Forum
  • Help
  • ADD-ONS
  • Newsletter
  • Impressum
  • Dsgvo
  • Impressum
Forum

Navigation

    • Register
    • Login
    • Search
    • Categories
    • Recent
    • Popular
    • Tags

    substring highlight

    How To... ?
    2
    6
    1523
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • L
      Louizos last edited by

      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

      DusX 1 Reply Last reply Reply Quote 0
      • DusX
        DusX Tech Staff @Louizos last edited by

        @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.

        Troikatronix Technical Support

        • New Support Ticket Link: https://support.troikatronix.com/support/tickets/new
        • Isadora Add-ons: https://troikatronix.com/add-ons/
        • My Add-ons: https://troikatronix.com/add-ons/?u=dusx

        Running: Win 10 64bit, i7-8750H, M.2 PCIe SSD's, 16gb DDR4-2666, nVidia GTX 1070 | located in Ontario Canada.

        1 Reply Last reply Reply Quote 1
        • L
          Louizos last edited by

          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?


          thanks

          Louizos

          1 Reply Last reply Reply Quote 0
          • DusX
            DusX Tech Staff last edited by

            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.

            Troikatronix Technical Support

            • New Support Ticket Link: https://support.troikatronix.com/support/tickets/new
            • Isadora Add-ons: https://troikatronix.com/add-ons/
            • My Add-ons: https://troikatronix.com/add-ons/?u=dusx

            Running: Win 10 64bit, i7-8750H, M.2 PCIe SSD's, 16gb DDR4-2666, nVidia GTX 1070 | located in Ontario Canada.

            1 Reply Last reply Reply Quote 0
            • L
              Louizos last edited by

              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.

              DusX 1 Reply Last reply Reply Quote 0
              • DusX
                DusX Tech Staff @Louizos last edited by

                @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.

                Troikatronix Technical Support

                • New Support Ticket Link: https://support.troikatronix.com/support/tickets/new
                • Isadora Add-ons: https://troikatronix.com/add-ons/
                • My Add-ons: https://troikatronix.com/add-ons/?u=dusx

                Running: Win 10 64bit, i7-8750H, M.2 PCIe SSD's, 16gb DDR4-2666, nVidia GTX 1070 | located in Ontario Canada.

                1 Reply Last reply Reply Quote 0
                • First post
                  Last post