Greater than sign in javascript script in Racket

I have trouble with the xexpr conversion of a script.
I run a very simple case extracted from a much larger program:

#lang web-server
    (require xml net/url)
(xexpr->string '(script "SetTimeOut(() => {let d = new Date();" ))

The result, run in drracket:

"<script>SetTimeOut(() =&gt; {let d = new Date();</script>"

That > should still be a greater-than sign. It is no longer correct javascript.
A bug? Or am I doing it wrong?

1 Like

You can use html-unescaped-tags to prevent the incorrect transformation.

1 Like

The parameter current-unescaped-tags holds tags that needs unescaped contents.
You need to set to html-unescaped-tags. If I recall correctly this was done
to have backward compatibility with older code.

(parameterize ([current-unescaped-tags html-unescaped-tags])
  (xexpr->string '(script "SetTimeOut(() => {let d = new Date();" )))

If you already happen to be using the txexpr package (or don't mind an extra dependency) it also includes a function xexpr->html that skips the content of <script> or <style> blocks.