lib/rouge/lexers/javascript.rb in rouge-3.23.0 vs lib/rouge/lexers/javascript.rb in rouge-3.24.0
- old
+ new
@@ -160,10 +160,14 @@
rule %r/`/ do
token Str::Double
push :template_string
end
+ # special case for the safe navigation operator ?.
+ # so that we don't start detecting a ternary expr
+ rule %r/[?][.]/, Punctuation
+
rule %r/[?]/ do
token Punctuation
push :ternary
push :expr_start
end
@@ -263,12 +267,13 @@
mixin :root
end
# template strings
state :template_string do
- rule %r/\${/, Punctuation, :template_string_expr
+ rule %r/[$]{/, Punctuation, :template_string_expr
rule %r/`/, Str::Double, :pop!
- rule %r/(\\\\|\\[\$`]|[^\$`]|\$(?!{))*/, Str::Double
+ rule %r/\\[$`]/, Str::Escape
+ rule %r/[$]/, Str::Double
end
state :template_string_expr do
rule %r/}/, Punctuation, :pop!
mixin :root