Sublime Forum

Classic ASP syntax selection

#1

Whenever I open an ASP file, the syntax selected is HTML (ASP). How do I get it to correctly identify ASP code only pages?
Code pages start with:
<script runat="server" language="vbscript">

0 Likes

#2

ASP files are HTML files with VBScript in <% ... %> template tags.

A file containing VBScript only, would have a *.vbs or *.asa extension. But placing HTML tags such as <script ...> there would result in syntax error.

0 Likes

#3

No syntax error, it’s allowed.
http://www.newobjects.com/pages/ndl/alp/asp-structure.htm

0 Likes

#4

*.asp extension is bound to HTML (ASP).sublime-syntax which has been the case and default since day one. Any example in the linked page has this structure.

*.asa extension is bound to ASP.sublime-syntax since day 1, which is just plain VBScript (or what you call “ASP code only”).

The name “HTML (ASP)” just illustrates it being extended from HTML.sublime-syntax or basically containing html with VBScript in <% %>, like PHP with its <? ... ?> which also is based on HTML this way.

It used to have been named “HTML-ASP” in ST3. Only the name changed nothing else.

Hence it is unclear to me what the issue is.

0 Likes

#5

Regardless of how things have been day 1, .asp files can be pure code and generally start with a script tag. I don’t know if it’s possible but in order to use the correct syntax highlighter, the file needs to be interrogated further.
I have never seen a web app use .asa files for anything other than the global.asa file.

0 Likes

#6

From the link you provided:

The ASP pages are text files in which some script elements are embedded.

Most often the ASP pages are HTML pages with embedded VBScript or JScript. By default ALP assumes that the pages contain HTML, but there is no problem to implement ASP pages that generate plain text, XML or any other textual content. It is possible, of course, certain ASP page to contain only script and no static non-script content at all.

Just like PHP, asp files are clearly a text file that allows embedding VBScript or JScript. Script tags are not valid VBScript, thus the syntax highlighting you want isn’t plain VBScript. I’m also not sure what issue you’re having; is the code highlighted incorrectly?

1 Like

#7

I guess the only thing missing is embedding VBScript in <script tags as we do for JavaScript / CSS in HTML by default.

<script runat="server" language="vbscript">
 ' embedded vbscript
</script>

I’d work on a fix, but I somehow lost overview with all those pending syntax PRs. Some of those HTML related might be useful or required to create a fix without merge conflicts.

1 Like

#8
<script runat="server" language="vbscript">
 ' This is not recognized as VB code. The single quote, for example, is not seen as a comment but instead as unclosed quotes. Switching syntax to ASP fixes it.
</script>
0 Likes

#9

Right, that’s clearly a missing feature in the HTML (ASP) syntax highlighting as deathaxe pointed out. But my point is that <script ...> is not VBScript; that code you pasted is very clearly HTML with a script tag for embedding VBScript, so the “HTML (ASP)” syntax is the correct language to use for ASP files.

0 Likes

#10

Anyone know if this was taken care of in build 4114? My trial has expired.

0 Likes

#11

Sublime Text trial periods are not time limited and don’t expire; however dev builds are only available to licensed users.

0 Likes

#12

The fix is merged into 4114

0 Likes

#13

I’m still not seeing this work in build 4121. Am I missing something?

0 Likes

#14

I was totally focused on type attribute so didn’t realize the language attributes being used to specify script syntax in ASP.

The following would be working already.

<script type="vbscript">
   ' comment
</script>

A fix is pending at

0 Likes