Wordfile for subtitles files

Wordfile for subtitles files

1032
Power UserPower User
1032

    Feb 01, 2018#1

    Hi.

    I know that it isn't a language at all, but I'd like to have different colors for SRT subtitle files.
    It seems to be a very easy task, but I don't know how it could be done.

    Subtitle files has this syntax (from "An Affair to Remember (1957)" movie):
    1
    00:02:10,005 --> 00:02:13,676
    While the New York Stock Exchange
    showed signs of restlessness,

    2
    00:02:13,760 --> 00:02:16,971
    there was little or no uneasiness
    on the part of optimists.

    3
    00:02:17,054 --> 00:02:19,141
    Here's good news for you bachelors.

    4
    00:02:19,183 --> 00:02:22,437
    Competition for pretty girls
    will definitely be easier

    5
    00:02:22,520 --> 00:02:26,859
    now that Nickie Ferrante, the big
    dame hunter, is going out of circulation.
    The challenge is to put lines with subtitle number to one color, with time codes to other and text lines to another color.
    Like this:
    1
    00:02:10,005 --> 00:02:13,676
    While the New York Stock Exchange
    showed signs of restlessness,

    2
    00:02:13,760 --> 00:02:16,971
    there was little or no uneasiness
    on the part of optimists.

    3
    00:02:17,054 --> 00:02:19,141
    Here's good news for you bachelors.

    4
    00:02:19,183 --> 00:02:22,437
    Competition for pretty girls
    will definitely be easier

    5
    00:02:22,520 --> 00:02:26,859
    now that Nickie Ferrante, the big
    dame hunter, is going out of circulation.
    I tried to adapt other language, like Ruby, to achieve the goal, but failed.
    I appreciate any help.

    6,686585
    Grand MasterGrand Master
    6,686585

      Feb 01, 2018#2

      Try this wordfile:

      Code: Select all

      /L20"Subtitles" Noquote File Extensions = SRT
      /Delimiters = 
      /Function String = "%[0-2][0-9]:[,0-9:]+ --> [0-2][0-9]:[,0-9:]+$"
      /C1"Time codes"
      ** 00: 01: 02: 03: 04:
      -->
      
      Note: The second line must end with a single space, but can be also end with two spaces or with two spaces and a horizontal tab.

      Subtitle numbers are syntax highlighted with color defined for color group Numbers. It is not possible to take the context into account, i.e. get a number highlighted only as subtitle number if it is placed at start of a line which does not containing anything else than the number. So numbers in text and all strings starting with a digit after a space (or tab) are also highlighted with the settings defined for color group Numbers.

      Time codes are highlighted with the color defined for color group Time codes which consists of 5 substring definitions and "word" -->. Again the context cannot be taken into account. So if a string starting with one of the 5 substrings or --> is found by UltraEdit within text lines, those strings are also highlighted with color group  Time codes.

      Everything else is highlighted with color group Normal Text of which foreground and background colors can be customized like for the other color groups.

      The color groups Comments, Alternate Comments and Strings can be ignored as not used by this language definition.
      Best regards from an UC/UE/UES for Windows user from Austria

      1032
      Power UserPower User
      1032

        Feb 01, 2018#3

        Excellent, Mofi!

        🙂🙂🙂

        Thread solved very fast!
        Thank you very much.