Skip to content

Commit

Permalink
Doc: use string array delimiter as-is input on highlight (#5297)
Browse files Browse the repository at this point in the history
Current highlighter implementation losts string array delimiter information,
and replaces it with `%w(` or `%i(`. Highlighter should respect user input,
and it can produce invalid Crystal code if string array item has `)`.
  • Loading branch information
makenowjust authored and bcardiff committed Nov 18, 2017
1 parent afacaba commit 1b95a69
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions src/compiler/crystal/tools/doc/highlighter.cr
Expand Up @@ -108,11 +108,7 @@ module Crystal::Doc::Highlighter

private def highlight_string_array(lexer, token, io)
start_highlight_class "s", io
if token.type == :STRING_ARRAY_START
io << "%w("
else
io << "%i("
end
HTML.escape(token.raw, io)
first = true
while true
lexer.next_string_array_token
Expand All @@ -122,7 +118,7 @@ module Crystal::Doc::Highlighter
HTML.escape(token.raw, io)
first = false
when :STRING_ARRAY_END
io << ")"
HTML.escape(token.raw, io)
end_highlight_class io
break
when :EOF
Expand Down

0 comments on commit 1b95a69

Please sign in to comment.