Custom code syntax highlighting is broken

Code inside <script> tag highlights as commented text until first right curly brace used {. Functionality is not impaired, but DX is:

A code block can be used as a workaround: