views:

329

answers:

0

The PHP and HTML syntax highlighting schemes in Notepad++ are generally pretty good at recognizing and highlighting JavaScript sections within a file, except that they don't recognize \ (backslash) as a JavaScript line continuation character, as in:

var legend = '<h2>Legend</h2>\
<ul>\
  <li><img src="red.gif" />Sunday</li>\
  <li><img src="blue.gif" />Monday</li>\
  <li><img src="cyan.gif" />Tuesday</li>\
  <li><img src="green.gif" />Wednesday</li>\
  <li><img src="magenta.gif" />Thursday</li>\
  <li><img src="black.gif" />Friday</li>\
</ul>';

When the snippet above is in an actual JavaScript file, Notepad++ correctly highlights everything within the single quotes as one long string (as the parser here seems to do). When it's part of a script in a PHP or HTML file, though, Notepad++ chokes on the backslashes and smashes the highlighting in the rest of the script block. Is there a way to fix this?