File tree Expand file tree Collapse file tree 2 files changed +7
-0
lines changed
spec/std/crystal/syntax_highlighter Expand file tree Collapse file tree 2 files changed +7
-0
lines changed Original file line number Diff line number Diff line change @@ -162,4 +162,8 @@ describe Crystal::SyntaxHighlighter::HTML do
162162 it_highlights! " %w[foo"
163163 it_highlights! " %i[foo"
164164 end
165+
166+ # fix for https://forum.crystal-lang.org/t/question-about-the-crystal-syntax-highlighter/7283
167+ it_highlights %q( /#{l[""]}/
168+ "\\ n") , %( <span class="s">/</span><span class="i">\# {</span>l[<span class="s">""</span>]<span class="i">}</span><span class="s">/</span>\n <span class="s">"\\\\ n"</span>)
165169end
Original file line number Diff line number Diff line change @@ -84,6 +84,8 @@ abstract class Crystal::SyntaxHighlighter
8484 space_before = false
8585
8686 while true
87+ previous_delimiter_state = lexer.token.delimiter_state
88+
8789 token = lexer.next_token
8890
8991 case token.type
@@ -105,6 +107,7 @@ abstract class Crystal::SyntaxHighlighter
105107 highlight_token token, last_is_def
106108 else
107109 highlight_delimiter_state lexer, token
110+ token.delimiter_state = previous_delimiter_state
108111 end
109112 when .string_array_start?, .symbol_array_start?
110113 highlight_string_array lexer, token
You can’t perform that action at this time.
0 commit comments