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

syntax highlighting doesn't understand heredocs #58

Open
masukomi opened this issue Aug 29, 2022 · 3 comments
Open

syntax highlighting doesn't understand heredocs #58

masukomi opened this issue Aug 29, 2022 · 3 comments

Comments

@masukomi
Copy link

The contents of a heredoc are highlighted as if they were code, instead of a string.
See attached screenshot.

screenshot showing heredoc highlighting in emacs

@tbrowder
Copy link
Member

Maybe so, but I wish an emacs dev could fix it.

@finanalyst
Copy link

There is a big problem with syntax highlighting of Raku in general because it has slangs, or sub languages. The slangs are Pod, regex, and quoting. So, a syntax highlighter developer will tend to chose a single way of colouring all of a Pod/regex/quoting section.
The two examples you have given above are different in that text within a single quote is obviously a string, which is coloured green.
The first is a quoted text, which the highlighter treats as code. This may be a reasonable choice for say qq which interpolates or qx which can execute.
Another problem I have found with syntax hightlighting that no none raku highlighter manages is the ending of a line with a quote, or double quotes, eg

say qq:to/MSG/ if True;
stuff in message
MSG
say "two messages" ~ q:to/MSG1/ ~ "and secondly " ~ q:to/MSG2/;
This is message one
MSG1
This is message two
MSG2

Similar sorts of problems exist with POD and regex, which need their own colouring rules.
Raku is a bit beyond most other languages.

@masukomi
Copy link
Author

masukomi commented Oct 13, 2022

Raku is a bit beyond most other languages.

this is true, but with regards to heredocs specifically: They're not notably different from Ruby's heredocs which basically every editor handles by just making all the contents be highlighted like any other string regardless of it they can be interpolated or not.

I don't see q:to/END/;...END as being notably different for the purposes of highlighting from <<~END...END

With regards to your example of embedded heredocs, as a human i'm not even sure what the "right" way to highlight that is so i wouldn't complain about an editor's highlighter saying "screw it. it's a comment"

examples of ruby heredocs follow.

emacs highlights the following heredocs pretty similarily to what github is doing.

I feel like "perfect" isn't required here. I think a simple "just treat it like a string" is fine.

    type  = "healthy"
    table = "food"

    query = <<-SQL
SELECT * FROM #{table}
WHERE #{type} = true
SQL

    query = <<~SQL
    SELECT * FROM #{table}
    WHERE #{type} = true
    SQL

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

No branches or pull requests

3 participants