Expressions with slashes are highlighted incorrectly

蓝咒 提交于 2019-12-10 20:17:32

问题


First off: I'm not talking about multi line commenting, I don't think. The problem is occurring when there is a space between the / and the * such as

draw.arc(x, y, radius, Math.PI/2, Math.PI/2, true);

In dreamweaver, the text

/2,Math.PI/

Goes green.

I've googled but to no avail. I'm sure it's something dumb but I'm stumped.

Also note: still occurs when the Math.PI formula is defined as a variable


回答1:


Dreamweaver is interpreting that as a regex for syntax highlighting.

The regex notation /regex/ is the most notoriously difficult part to parse in all of Javascript.

Your code is fine. You could try adding spaces around the /. I've often seen that work.




回答2:


As stated below, it's a parsing issue with Dreamweaver - interpreting your syntax as a regular expression.

A solution to this problem would be to create a variable for that value. Additionally, it's more efficient than doing the same operation more than once.

var piOver2 = Math.PI / 2;

draw.arc(x, y, radius, piOver2, piOver2, true);



回答3:


It is something dumb: Dreamweaver has a bug in it. Your code must still execute. That is a perfectly valid sequence of characters, that does not result in a comment.



来源:https://stackoverflow.com/questions/19750685/expressions-with-slashes-are-highlighted-incorrectly

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!