diff --git a/spec/std/crystal/syntax_highlighter/html_spec.cr b/spec/std/crystal/syntax_highlighter/html_spec.cr index fc1a3d25672c..84e7c69ff410 100644 --- a/spec/std/crystal/syntax_highlighter/html_spec.cr +++ b/spec/std/crystal/syntax_highlighter/html_spec.cr @@ -73,7 +73,7 @@ describe Crystal::SyntaxHighlighter::HTML do == < <= > >= != =~ !~ & | ^ ~ ** >> << % ).each do |op| - it_highlights %(def #{op}), %(def #{op}) + it_highlights %(def #{op}), %(def #{HTML.escape(op)}) end it_highlights %(def //), %(def //) diff --git a/src/crystal/syntax_highlighter/html.cr b/src/crystal/syntax_highlighter/html.cr index f453895f25bb..3f146b662485 100644 --- a/src/crystal/syntax_highlighter/html.cr +++ b/src/crystal/syntax_highlighter/html.cr @@ -52,7 +52,7 @@ class Crystal::SyntaxHighlighter::HTML < Crystal::SyntaxHighlighter when .string? span "s" { ::HTML.escape(value, @io) } when .ident? - span "m", &.print value + span "m" { ::HTML.escape(value, @io) } when .keyword?, .self? span "k", &.print value when .primitive_literal?