Sublime Forum

Server Side Scripting - Nested Syntax Highlighting

#1

I’m not sure if this is a problem with other server side scripting languages, but I code in ASP and if you ever nest ASP tags (<% %>) inside of any other script tag (like javascript) it trashes the syntax highlighting.

This is especially problematic if I have an ASP block inside of a javascript block and I use an ASP comment. Since syntax highlighting still treats the ASP like javascript, it takes that single quote (which is a comment in ASP) and treats it like the start of a string. The string coloring then wraps around each line until it hits another single quote somewhere in the file and so on and so forth screwing up the entire files syntax highlighting.

Since ASP is server-side its tags (<% %>) should always take precedence in syntax highlighting. This really needs to be fixed.

Example:
Copy and paste the below into a new file and set the syntax highlighting to ASP - HTML

		<script type="text/javascript">
			jQuery('#loaded').change(function() {
				var example = <% aspVariable ' this is my asp variable %>
				if (jQuery(this).val() === 'SCH') {
					toggleOpt2('2305EF50974D4C34962F3170ADF72BA6', false);
				} else {
					toggleOpt2('', true);
				}
			});
		</script>
0 Likes

#2

for the comment problem just fix the ASP.tmLanguage…
this line (’).$\n?
becomes this line (’)((?!%>).)

for the nested syntax you will have to change more files…

0 Likes