Sublime Forum

Syntax highlighting for JS in html attributes (ex: onclick)

#1

Is it possible to get Sublime Text 3 to use javascript syntax highlighting on javascript in the attributes of HTML elements (stuff like onclick, onkeypress, etc)?

For example, if I wanted highlighting for the JS here:

<div id="search">
	<div class="searchdiv"><input id="searchfield" onkeypress="if (event.keyCode == 13) {doSearch(this.value,1);}"/></div> 
	<div class="test" onclick="doSearch(document.getElementById('searchfield').value,1)" ><canvas id="searchbtn2" width="68px" height="68px"/></div>
	<div class="test"></div>
	<div class="test"></div>
	<div class="test" onclick="doSearch(document.getElementById('searchfield').value,Math.max(window.currentpage-1,1))"><canvas id="prevbtn" width="68px" height="68px"/></div>
	<div class="test" onclick="doSearch(document.getElementById('searchfield').value,(window.currentpage+1))"><canvas id="nextbtn" width="68px" height="68px"/></div>
</div>

Thanks

0 Likes

#2

I hate to come back and bump my thread, but… anyone have any thoughts on this? It seems like it would be a common thing to want to do.

0 Likes