Tapatalk

Is Python block comment syntax highlighting with triple quotes possible with UltraEdit?

Is Python block comment syntax highlighting with triple quotes possible with UltraEdit?

2
NewbieNewbie
2

PostMar 22, 2025#1

I have a question about Python syntax highlighting. Is block code highlighting possible?

I'm unable to get this to work. My understanding is that triple quotes """ or triple tics ''' at the beginning and end of comment blocks is how this is indicated in the source code. I've tried to figure this out but can't get it to work. Double and single quotes (" and ') are also the beginning and ending string delimiter, so I'm guessing that distinguishing that from block comments is a big part of the problem. Block comments get highlighted as strings not comments. Any ideas on how to do this? I don't know if I am supposed to start another topic, so I'll just tack this on to my previous question. Please move it if it should be separate.

Thanks.

6,826625
Grand MasterGrand Master
6,826625

PostMar 22, 2025#2

Python block comment syntax highlighting is not supported with UltraEdit < v2022.1.0.90 (v29.1.0.90 with former version numbering scheme) or UEStudio < v2022.1.0.90 (v22.1.0.90 with former version numbering scheme).

Python block comment syntax highlighting is supported with UltraEdit  v2022.1.0.90 or UEStudio v2022.1.0.90 by using in the Python syntax highlighting wordfile as first line either

Code: Select all

/L16"Python" PYTHON_LANG String Chars = "' Escape Char = \ Line Comment = # Block Comment On = ''' Block Comment Off = ''' Block Comment On Alt = """ Block Comment Off Alt = """ File Extensions = PY PYW
or

Code: Select all

/L16"Python" PYTHON_LANG String Chars = "' Escape Char = \ Line Comment = # Block Comment On = """ Block Comment Off = """ Block Comment On Alt = ''' Block Comment Off Alt = ''' File Extensions = PY PYW
The Python syntax highlighting wordfile is by default %APPDATA%\IDMComp\UltraEdit\wordfiles\python.uew or %APPDATA%\IDMComp\UEStudio\wordfiles\python.uew. Open the wordfile by opening in UltraEdit/UEStudio Advanced - Settings or Configuration - Syntax highlighting, selecting the installed wordfile Python, clicking on button Open, and closing the configuration dialog window.

I tested the Python block comment highlighting with UltraEdit v2022.0.0.102 (not working because of the reasons written by rtv0075), v2022.1.0.90 (working due to syntax highlighting parser overhaul as written in changes.txt of UE/UES v2022.1 and later versions) and currently latest v2024.3.0.13.

Which of the two possible lines is used depends on which type of block comment is preferred on using the commands Comment selection and Uncomment selection in traditional menu Edit or Block comment selection in submenu Comment and Remove block comment in submenu Uncomment of contemporary menu Coding or clicking on ribbon tab Coding on down arrow below the command Comment or right to the command Uncomment to open the appropriate pop-up menu and clicking on the command Block comment selection respectively Remove block comment.

Line comments, alternate line comments and block comments are all syntax highlighted with the color and the font style settings as defined for the language Python for color group Comments in the Manage Themes dialog window on tab Syntax. The color group Alternate block comments defines the color and font style for syntax highlighting alternate block comments. It is therefore possible to syntax highlight block comments with """ different to block comments with ''' or get them both syntax highlighted identical on using identical settings for the color groups Comments and Alternate block comments.

NOTE: There is according to the Python documentation Lexical analysis just one type of comments: line comments starting with #. A block enclosed in """ or ''' is in real a longstring (which can be a multi-line string) which is ignored on parsing the Python script file on not being assigned to a variable. See also Python Multiline Strings and Python Comments of W3 schools. The syntax highlighting definition above is not capable to distinguish between a longstring assigned to a string variable or passed to a function as parameter and a longstring used as block comment and being more or less ignored on parsing the Python script file.

2
NewbieNewbie
2

PostMar 22, 2025#3

Thank you again for all of your help. I really appreciate it.

51
NewbieNewbie
51

PostDec 03, 2025#4

Hey Mofi, 

I tried adding both variations of your example to enable colorizing of Python block comment highlighting but it doesn't appear to work. 

Can you attach your complete python.uew here so I can try it in my Mac version 2023.0.0.25 of UltraEdit? 

You can see in my screenshot that standard comments get "italicized" and colorized  but block quotes """ do not function correctly. 

I do not think the Block Comment Off = """ is getting detected after triple-quotation marks are found a second time. 

Thanks in advance, 

-Tim

blockquoteexample.png (246.38KiB)

6,826625
Grand MasterGrand Master
6,826625

PostDec 03, 2025#5

UltraEdit for Mac v2023.0.0.25 has obviously the syntax highlighting engine of UltraEdit for Windows < v2022.1.0.90 as everything between two """ is syntax highlighted with the settings for string highlighting in the attached screenshot. There is no possibility to get all text between two """ syntax highlighted as block comment with that syntax highlighting engine without completely disabling string highlighting or change the string highlighting to use only ' as string character and use """ for block comments.