Skip to content

Commit 341a764

Browse files
committed
Separate ASHX syntax. Rename syntax file
1 parent f7d2350 commit 341a764

4 files changed

Lines changed: 81 additions & 1 deletion

File tree

ashx.sublime-syntax

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
%YAML 1.2
2+
---
3+
# http://www.sublimetext.com/docs/3/syntax.html
4+
name: .Net Web Handler (ASHX)
5+
first_line_match: <%@\s*WebHandler
6+
file_extensions:
7+
- ashx
8+
scope: source.cs.ashx
9+
contexts:
10+
main:
11+
- match: ''
12+
set: scope:source.cs
13+
with_prototype:
14+
- include: directive-type
15+
- include: directive
16+
17+
directive-generic-attribute:
18+
- match: '\b(\w+)\s*(=)\s*((")[^"]*("))\s*'
19+
captures:
20+
1: entity.other.attribute-name.cshtml
21+
2: punctuation.separator.key-value.cshtml
22+
3: string.quoted.double.cshtml
23+
4: punctuation.definition.string.begin.cshtml
24+
5: punctuation.definition.string.end.cshtml
25+
26+
directive-end:
27+
- match: '%>'
28+
scope: punctuation.section.embedded.end.cshtml
29+
pop: true
30+
31+
directive:
32+
# https://msdn.microsoft.com/en-us/library/xz702w3e(v=vs.100).aspx
33+
- match: '<%@'
34+
scope: punctuation.section.embedded.begin.cshtml
35+
set:
36+
- meta_scope: meta.block.processing-directive.cshtml
37+
- include: directive-type
38+
- include: directive-other
39+
- include: directive-end
40+
41+
directive-type:
42+
# https://msdn.microsoft.com/en-us/library/ms366713(v=vs.100).aspx
43+
- match: '\b(?i:WebHandler)\b'
44+
scope: constant.language.processing-directive.type.cshtml entity.name.class.cs
45+
set:
46+
- meta_scope: meta.block.processing-directive.contents.type.cshtml
47+
- include: directive-generic-attribute
48+
- include: directive-end
49+
50+
directive-other:
51+
# https://msdn.microsoft.com/en-us/library/xz702w3e(v=vs.100).aspx
52+
- match: '\b(?i:Import|Implements|Assembly|OutputCache|Reference)\b'
53+
scope: punctuation.section.embedded.begin.cshtml
54+
push:
55+
- meta_scope: meta.block.processing-directive.contents.cshtml
56+
- include: directive-generic-attribute
57+
- include: directive-end

tests/syntax_test_ashx.ashx

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// SYNTAX TEST "Packages/HTML (C#)/ashx.sublime-syntax"
2+
3+
<%@ WebHandler Language="C#" Class="Handler" %>
4+
5+
using System;
6+
using System.Web;
7+
8+
public class Handler : IHttpHandler
9+
{
10+
public void ProcessRequest(HttpContext context)
11+
{
12+
context.Response.ContentType = "text/plain";
13+
context.Response.Write("Hello World");
14+
}
15+
16+
public bool IsReusable
17+
{
18+
get
19+
{
20+
return false;
21+
}
22+
}
23+
}

tests/syntax_test_aspx.aspx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// SYNTAX TEST "Packages/HTML (C#)/HTML-C#.sublime-syntax"
1+
// SYNTAX TEST "Packages/HTML (C#)/cshtml.sublime-syntax"
22

33
<%@ Page Debug="true" Title="" AutoEventWireup="true" Inherits="System.Web.UI.Page" %>
44
// <- punctuation.section.embedded.begin.cshtml

0 commit comments

Comments
 (0)