Skip to content

Commit 71b9df7

Browse files
authored
Fix comment highlight in TCL lexer (rouge-ruby#2041)
1 parent e8120fb commit 71b9df7

File tree

2 files changed

+20
-2
lines changed

2 files changed

+20
-2
lines changed

lib/rouge/lexers/tcl.rb

+7-2
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,9 @@ def self.detect?(text)
5757

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

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

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

166+
state :comment do
167+
rule %r/.*[^\\]\n/, Comment, :pop!
168+
rule %r/.*\\\n/, Comment
169+
end
170+
166171
state :string do
167172
rule %r/"/, Str::Double, :pop!
168173
mixin :interp

spec/visual/samples/tcl

+13
Original file line numberDiff line numberDiff line change
@@ -323,3 +323,16 @@ test parse-1.63 "unquoted dollar sign" {
323323
} {x$}
324324

325325
testreport
326+
327+
# The braced form of variable substitution handles more complex variable names:
328+
set greeting "Hello, ${first name}"
329+
330+
# "set" can always be used instead of variable substitution, and can handle all
331+
# variable names:
332+
set greeting "Hello, [set {first name}]"
333+
334+
335+
# To unpack a list into the command, use the expansion operator, "{*}". These
336+
# two commands are equivalent:
337+
set name Neo
338+
set {*}{name Neo}

0 commit comments

Comments
 (0)