framework icon indicating copy to clipboard operation
framework copied to clipboard

Backslashes aren’t unescaped within PRE elements

Open mbostock opened this issue 2 years ago • 1 comments

Consider the following HTML:

<pre>${test}</pre>

The ${test} is interpreted as a live expression, so if test is not defined, you’ll see an error:

RuntimeError: test is not defined

You can prevent the live expression using a backslash:

<pre>$\{test}</pre>

However, the resulting backslash is still rendered in the output, producing:

$\{test}

A workaround is to use &dollar; instead:

<pre>&dollar;{test}</pre>

This is probably something we should fix in #597.

mbostock avatar Jan 31 '24 05:01 mbostock

There is also <pre>$&zwj;{test}</pre> (I know, not a very helpful comment!)

Fil avatar May 22 '24 16:05 Fil