PyCharm complaining about unescaped XML character within <script> tag

My .html file:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns="http://www.w3.org/1999/html" lang="en">
<head>
...
<script type="application/javascript">
x = 1 < 2; //Error here

...

PyCharm marks the less than operator as an unescaped XML character.

Assuming that this is my fault, how can I convince PxCharm to NOT show this error?

1 comment
Comment actions Permalink

You are using <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> doctype.
This doctype prohibits usage of the unescaped symbols 'less-than' and 'ampersand' according to the spec: http://www.w3.org/TR/xhtml1/#h-4.8
So, PyCharm works as expected. You should change < into &lt; to make document valid.

Or, if you don't care about document validity, you can suppress the inspection: hit Alt+Enter, Right, then choose the desired option ('Disable inspection', 'Suppress for statement', etc.) from the popup

0

Please sign in to leave a comment.