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 comment highlight in TCL lexer #2041

Merged
merged 1 commit into from
Apr 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions lib/rouge/lexers/tcl.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,9 @@ def self.detect?(text)

def self.gen_command_state(name='')
state(:"command#{name}") do
mixin :word
rule %r/#/, Comment, :comment

rule %r/##{NOT_CHARS[END_LINE]}+/, Comment::Single
mixin :word

rule %r/(?=#{CHARS[END_WORD]})/ do
push :"params#{name}"
Expand Down Expand Up @@ -163,6 +163,11 @@ def self.gen_delimiter_states(name, close, opts={})
rule %r/\\./m, Str::Escape
end

state :comment do
rule %r/.*[^\\]\n/, Comment, :pop!
rule %r/.*\\\n/, Comment
end

state :string do
rule %r/"/, Str::Double, :pop!
mixin :interp
Expand Down
13 changes: 13 additions & 0 deletions spec/visual/samples/tcl
Original file line number Diff line number Diff line change
Expand Up @@ -323,3 +323,16 @@ test parse-1.63 "unquoted dollar sign" {
} {x$}

testreport

# The braced form of variable substitution handles more complex variable names:
set greeting "Hello, ${first name}"

# "set" can always be used instead of variable substitution, and can handle all
# variable names:
set greeting "Hello, [set {first name}]"


# To unpack a list into the command, use the expansion operator, "{*}". These
# two commands are equivalent:
set name Neo
set {*}{name Neo}