Skip to content

Commit

Permalink
Fix comment highlight in TCL lexer (#2041)
Browse files Browse the repository at this point in the history
  • Loading branch information
tancnle committed Apr 7, 2024
1 parent e8120fb commit 71b9df7
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
9 changes: 7 additions & 2 deletions lib/rouge/lexers/tcl.rb
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
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}

0 comments on commit 71b9df7

Please sign in to comment.