kopoli / robot-mode

Emacs major mode for editing Robot Framework files.
GNU General Public License v3.0
8 stars 3 forks source link

Syntax highlighting issue if value contains single " #15

Closed amittendulkar closed 2 months ago

amittendulkar commented 3 months ago

If any value contains a single " character, the syntax highlighting is not able to identify skipping the string highlighting.

Here is a screenshot,

image

You can see that the another value and Another Keyword are assumed to be part of the string continuation even if the 2nd element of the list (value with single " in it) has ended.

kopoli commented 3 months ago

Does this syntax work in other editors and is it accepted by robot framework ?

In the documentation (with a quick search) the double quotes are used as a pair in values. E.g.: http://robotframework.org/robotframework/latest/RobotFrameworkUserGuide.html#space-and-empty-variables

I would expect that when a single double quote would be present in a value, then it would be escaped with \. E.g. in the following way:

    ${mylist}=    Create List     1    value with single \" in it   another value
amittendulkar commented 2 months ago

It is supported in VS Code with "Robot Framework Language Server" extension. The exntension repository is at, https://github.com/robocorp/robotframework-lsp

Here is a screenshot from VS Code,

image

If you refer to http://robotframework.org/robotframework/latest/RobotFrameworkUserGuide.html#escaping under "Escaping special characters" you will notice that the double quote is not mentioned as a special character and so there is no need to escape it.

kopoli commented 2 months ago

In my opinion, as a person reading source code, having a single double-quote or a single-quote in an argument is unexpected. I get that it's technically possible with Robot framework as the separator is a block of multiple spaces, but to my eye it would look like a syntax error (which it is in many other programming languages).

In what kind of situations is it beneficial to have keyword values with just single double quotes ? Is it possible to escape them (with the \" syntax) in those situations ?

amittendulkar commented 2 months ago

It is possible to escape single/double quote. There might be a situation whether we want to check presence of a pattern in a log file that starts with a double-quote and we might not be bothered about the dynamic part coming before the double quote. I agree that we can give the .* (or any other matching) regexp to include the balancing double quote in the same line. I will close the issue.