diff --git a/lib/rouge/lexers/tcl.rb b/lib/rouge/lexers/tcl.rb index e73730ae3f..1bc6c8645f 100644 --- a/lib/rouge/lexers/tcl.rb +++ b/lib/rouge/lexers/tcl.rb @@ -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}" @@ -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 diff --git a/spec/visual/samples/tcl b/spec/visual/samples/tcl index 76b684f40f..eb3ec14d3d 100644 --- a/spec/visual/samples/tcl +++ b/spec/visual/samples/tcl @@ -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}