Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix handling of escaped quotes in CMake lexer #1473

Merged
merged 2 commits into from Mar 31, 2020

Conversation

pyrmont
Copy link
Contributor

@pyrmont pyrmont commented Mar 31, 2020

As identified in #1452, Rouge's CMake lexer doesn't handle escaped quotes correctly in unquoted arguments. It incorrectly treats the escaped quote as beginning a quoted argument. This PR fixes that error.

It will close #1452.

@pyrmont pyrmont added the needs-review The PR needs to be reviewed label Mar 31, 2020
@pyrmont pyrmont self-assigned this Mar 31, 2020
@pyrmont
Copy link
Contributor Author

pyrmont commented Mar 31, 2020

@danilaml I'm still not sure I've understood the CMake language spec correctly. The code now tokenises \" in an unquoted argument as Text. In practice, it looks like this:

cmake

Is that what it should look like? It's still interpolating the argument inside the escaped quotes (which GitHub doesn't do).

@danilaml
Copy link
Contributor

@pyrmont It seems correct to me. At the very least, it's much better than highlighting everything past \" and until some unescaped " as a string.
I think GitHub just uses the regular text style for ${} args, so they don't stand out when they are in an unquoted context, contrary to

message("This ${arg}")

@pyrmont
Copy link
Contributor Author

pyrmont commented Mar 31, 2020

@danilaml Cool. I realised the screenshot was a little misleading: I had highlighted foo but that's not something Rouge is doing. In any case, will merge this in now. Thanks for the contribution! :)

@pyrmont pyrmont merged commit 96315eb into rouge-ruby:master Mar 31, 2020
@pyrmont pyrmont deleted the bugfix.cmake-escaped-quotes branch March 31, 2020 18:05
@pyrmont pyrmont removed the needs-review The PR needs to be reviewed label Mar 31, 2020
mattt pushed a commit to NSHipster/rouge that referenced this pull request May 21, 2020
Rouge's CMake lexer doesn't handle escaped quotes correctly in unquoted
arguments. It incorrectly treats the escaped quote as beginning a
quoted argument. This commit fixes that error.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

CMake syntax highlight gets confused by the naked escaped quote
2 participants