How to extend the set of matching delimiters for finding mismatching quotes and highlighting quotes in pure text files?

How to extend the set of matching delimiters for finding mismatching quotes and highlighting quotes in pure text files?

221
Basic UserBasic User
221

    Apr 05, 2023#1

    I have a plain text file (.txt) in which quotation marks are „ (open quote) and “ (close quote). Needless to say, they do not match!

    How can I get UE to help me find the unmatched ones?

    Thank you.

    6,686585
    Grand MasterGrand Master
    6,686585

      Apr 05, 2023#2

      There could be used for .txt files a custom syntax highlighting file which has multiple color groups for the various quotes. After downloading the attached syntax highlighting wordfile into the directory %APPDATA%\IDMComp\UltraEdit\wordfiles and restarting UltraEdit on currently running, open the Manage Themes dialog, select tab Syntax, select the Language Text and configure good visible text and background colors and perhaps use additionally the font style bold for the quotes.

      The syntax highlighting wordfile defines also and as brace strings. The matching double quotes are highlighted with the colors defined for Brace highlight on tab Editor in the Manage Themes dialog. There is no brace highlighting on other quotes and the commands Select to brace and Go to brace can be used for selecting the string between the correct double quotes respectively go to the matching double quote.

      There can be run from top of the file a regular expression replace for the other double quotes using ["] and use as replace string first just for correcting all double quotes one after the other with visual inspection at the beginning of a quoted text. Next run from top of the file again a regular expression replace searching for ["] and use as replace string now just for correcting all double quotes one after the other with visual inspection at the end of a quoted text.

      UltraEdit has no AI feature to understand the text and know like a human reader where a quoted text begins and where it ends and if a straight double quote must be used like in a code example or after a number on which " means inch or arcsecond.

      I have seen too many web pages with code examples in world wide web on which straight double quotes were replaced obviously automatically most likely by a word processing application by text quoting double quotes making the code examples invalid for usage. The result is that many beginners in code writing copy the code examples from such web pages and wonder why the script code does not work or the compiler outputs error messages on code compilation.
      text.uew (275 Bytes)   0
      Syntax highlighting wordfile for text files for highlighting quotes
      Best regards from an UC/UE/UES for Windows user from Austria

      221
      Basic UserBasic User
      221

        Apr 06, 2023#3

        Thank you very much for that wordfile.  I placed your text.uew in %APPDATA%\Roaming\IDMComp\UltraEdit\Wordfiles and used "Manage themes" (Classic view) to set the colors.  The text.uew file does not seem to have been changed by the management, and is still as you sent it. 

        Showing the different quotation marks in color is a great help.  But there are some problems, which might be due to my version of UE, which is 26.10.0.82 (from 2019).

        "Low double quote" always has its assigned color.  However "Left double quote" (which is used as the closing double quote in the language of my text) has the assigned color when it follows a comma, question mark or exclamation mark, but when it follows a full stop, it stays black.  The attached image shows some examples.

        "Go to matching brace" and "Select matching brace" don't do anything, and this was what I was hoping to use.  When positioned on a "low double quote" and either of these options is chosen from the menu, nothing happens.  It is the same whether or not the "left double quote" is correctly colored.

        Since I really want to modify the default highlighting of .txt files, not to completely replace it, perhaps I could start from the default .uew for .txt files (if there is such a file), and use your text.uew and http://wiki.ultraedit.com/Wordfiles as a guide.
        quotes.jpg (116.23KiB)

          Apr 06, 2023#4

          I've found that the first problem above is avoided if I highlight by setting the background colour rather than the foreground colour.  This is visually much better as well.

          The "Go to/Select matching brace" problem still remains.
          quotes2.jpg (122.88KiB)

          6,686585
          Grand MasterGrand Master
          6,686585

            Apr 06, 2023#5

            UltraEdit for Windows v24.00.0.42 to v26.00.0.72 have a bug regarding to characters with a code point value greater 127 decimal in a Windows-1252 encoded wordfile, i.e. non-ASCII characters in an one byte per character encoded wordfile. I reported this issue as detected by me. It was fixed with v26.10.0.14 which syntax highlights ANSI characters as it worked up to UE v23.20.0.43. I found also a workaround for this issue. The wordfile must be stored as UTF-8 (without BOM) or UTF-16 encoded Unicode file. Then the syntax highlighting of the quotes works independent on which characters are left and right as being now interpreted themselves as word delimiters as I could verify with restoring UE v26.00.0.72 from my archives.  UltraEdit 26.10.0.72 works in my test with Windows-1252, UTF-8 and  UTF-16 encoded text.uew. The default system ANSI code page is Windows-1252 on my PC because of having German as language and Austria as county configured for my account in the Windows settings and UltraEdit uses the default settings. I recommend to check your encoding settings at Advanced - Settings or Configuration - File handling - Encoding in UE v26.10.0.82. The attached screen shots are made with Windows-1252 encoded text.uew.

            Brace matching for the low and left double quote requires UltraEdit for Windows v2022.0.0.70 as I found out today. Former versions support brace matching only for ASCII characters independent on the character encoding of the wordfile. There is no possibility to get brace feature working for non-ASCII quotes in former versions of UltraEdit as far as could find out with some quick tests.

            The syntax highlighting wordfiles in GitHub repository or UltraEdit´s wordfiles download page are all user contributed and not deeply analyzed by an employee of UltraEdit, Inc. They are reviewed of being really a wordfile before they are added to the master branch and uploaded to the web server, but there is no syntax check made neither for the wordfile syntax nor how good the syntax highlighting wordfile really works for the language being highlighted. There is no "standard wordfile" for .txt files.

            It is up to you to customize the wordfile provided by me for your needs on .txt files highlighting. The line beginning with /Delimiters = can be extended with more characters to interpret as word delimiters on syntax highlighting the text in files with file extension txt. The order of the delimiters on the line does not matter although I sort them always alphabetically according to their code point values using an UltraEdit macro.

            Lines of Windows-1252 encoded text file for testing quotes highlighting:

            Code: Select all

            Test line 1: „Hello world.“
            Test line 2: "Straight quoted text."
            Test line 3: „Right double quoted text as in German.”
            Test line 4: ' and ‚ and ‘ are the single quotes.
            PS: The image format PNG is much better for screen shots than the format JPEG. The Portable Network Graphics format is supported by all applications supporting also the JPEG image format.
            quotes_highlighting_ue_26_10.png (61.71KiB)
            Syntax highlighting of quotes with UE v26.10.0.72
            manage_themes_for_quotes_ue_26_10.png (11.85KiB)
            Color configuration for quotes highlighting in manage themes dialog of UE v26.10.0.72
            Best regards from an UC/UE/UES for Windows user from Austria

            221
            Basic UserBasic User
            221

              Apr 08, 2023#6

              Hi, thank you for doing so much research on these problems.

              It would be of interest to confirm that v26.20.0.68 correctly highlights left double quote after a full stop when using foreground color highlighting, which was my problem with v26.10.0.82.

              To summarize the outcome, my highlighting problem is avoided by using background color, while my brace matching problem would require an update of UE. Many thanks again.

              6,686585
              Grand MasterGrand Master
              6,686585

                Apr 09, 2023#7

                I updated my previous post with screen shots of quotes highlighting as done by UltraEdit for Windows v26.10.0.72 on Windows-1252 encoded text file with Windows-1252 encoded syntax highlighting wordfile. There is no problem on interpreting all the quotes as word delimiters and highlight the quotes according to color configuration in the manage themes dialog window.
                Best regards from an UC/UE/UES for Windows user from Austria

                221
                Basic UserBasic User
                221

                  Apr 09, 2023#8

                  Hi, so the highlighting problem was absent in v26.10.0.72 but present in v26.10.0.82 (which is my version). I hope it has been fixed since then :-)

                  6,686585
                  Grand MasterGrand Master
                  6,686585

                    Apr 09, 2023#9

                    I am not aware of a public released 26.10.0.82. I have archived only version 26.10.0.72 and as next public released version 26.20.0.4. I see no difference between v26.10.0.72 and v26.20.0.4 regarding to syntax highlighting of the quotes. I do not understand why after a dot is interpreted as word delimiter on having configured just a background color for the color group with this quote character while the same text file with same wordfile is interpreted different on having configured just a text color for the color group with character . I can see the differences on your two screen shots, but it is completely unexplainable for me from a programmers point of view. Further, I do not understand why it makes a difference on comma or question mark left to in comparison to a dot. The character itself should be interpreted as word delimiter and therefore the character left and right should not matter at all. However, I have not UE version 26.10.0.82 and cannot analyze for that reason that strange syntax highlighting behavior by myself.
                    Best regards from an UC/UE/UES for Windows user from Austria

                    221
                    Basic UserBasic User
                    221

                      Apr 09, 2023#10

                      Thanks once again. UltraEdit, Inc. allowed me to download v26.10.0.82 in July 2019 as a solution to some problems with regular expressions in my previous version, v25.00.0.58. I am still using it. I am satisfied now that an upgrade would solve both the highlighting and the brace matching problems.