Skip to content

Commit 9b4bd01

Browse files
committed
fix: sp token treated like html token
1 parent ff6a122 commit 9b4bd01

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

token_visualizer/token_html.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,9 +120,10 @@ def tokens_info_to_html(tokens: List[Token], special_for_newline: bool = True) -
120120
hover_html = single_token_html(token)
121121
rgb = color_token_by_logprob(token.logprob, min_logprob, max_logprob)
122122
token_text = token.text
123-
is_newline = repr("\n")[1:-1] in token.text
123+
token_text = token_text.replace("<", "&lt;").replace(">", "&gt;") # make token like <func_call> display correctly # noqa
124+
is_newline = repr("\n")[1:-1] in token_text
124125
if special_for_newline and is_newline:
125-
token_text = f'<span class="ppl-pseudo-token">{token.text}</span>'
126+
token_text = f'<span class="ppl-pseudo-token">{token_text}</span>'
126127
token_html = f'<span class="ppl-token" style="background: {rgb};">{token_text}{hover_html}</span>' # noqa
127128
if is_newline:
128129
token_html += "<br>"

0 commit comments

Comments
 (0)